It is only used to store a few local variables within one function,
which is better accomplished by just declaring them on stack explicitly.
... | ... |
@@ -42,7 +42,6 @@ typedef struct HEVCParserContext { |
42 | 42 |
H2645Packet pkt; |
43 | 43 |
HEVCParamSets ps; |
44 | 44 |
HEVCSEI sei; |
45 |
- SliceHeader sh; |
|
46 | 45 |
|
47 | 46 |
int is_avc; |
48 | 47 |
int nal_length_size; |
... | ... |
@@ -58,26 +57,28 @@ static int hevc_parse_slice_header(AVCodecParserContext *s, H2645NAL *nal, |
58 | 58 |
HEVCParserContext *ctx = s->priv_data; |
59 | 59 |
HEVCParamSets *ps = &ctx->ps; |
60 | 60 |
HEVCSEI *sei = &ctx->sei; |
61 |
- SliceHeader *sh = &ctx->sh; |
|
62 | 61 |
GetBitContext *gb = &nal->gb; |
63 | 62 |
const HEVCWindow *ow; |
64 | 63 |
int i, num = 0, den = 0; |
65 | 64 |
|
66 |
- sh->first_slice_in_pic_flag = get_bits1(gb); |
|
65 |
+ unsigned int pps_id, first_slice_in_pic_flag, dependent_slice_segment_flag; |
|
66 |
+ enum HEVCSliceType slice_type; |
|
67 |
+ |
|
68 |
+ first_slice_in_pic_flag = get_bits1(gb); |
|
67 | 69 |
s->picture_structure = sei->picture_timing.picture_struct; |
68 | 70 |
s->field_order = sei->picture_timing.picture_struct; |
69 | 71 |
|
70 | 72 |
if (IS_IRAP_NAL(nal)) { |
71 | 73 |
s->key_frame = 1; |
72 |
- sh->no_output_of_prior_pics_flag = get_bits1(gb); |
|
74 |
+ skip_bits1(gb); // no_output_of_prior_pics_flag |
|
73 | 75 |
} |
74 | 76 |
|
75 |
- sh->pps_id = get_ue_golomb(gb); |
|
76 |
- if (sh->pps_id >= HEVC_MAX_PPS_COUNT || !ps->pps_list[sh->pps_id]) { |
|
77 |
- av_log(avctx, AV_LOG_ERROR, "PPS id out of range: %d\n", sh->pps_id); |
|
77 |
+ pps_id = get_ue_golomb(gb); |
|
78 |
+ if (pps_id >= HEVC_MAX_PPS_COUNT || !ps->pps_list[pps_id]) { |
|
79 |
+ av_log(avctx, AV_LOG_ERROR, "PPS id out of range: %d\n", pps_id); |
|
78 | 80 |
return AVERROR_INVALIDDATA; |
79 | 81 |
} |
80 |
- ps->pps = (HEVCPPS*)ps->pps_list[sh->pps_id]->data; |
|
82 |
+ ps->pps = (HEVCPPS*)ps->pps_list[pps_id]->data; |
|
81 | 83 |
|
82 | 84 |
if (ps->pps->sps_id >= HEVC_MAX_SPS_COUNT || !ps->sps_list[ps->pps->sps_id]) { |
83 | 85 |
av_log(avctx, AV_LOG_ERROR, "SPS id out of range: %d\n", ps->pps->sps_id); |
... | ... |
@@ -109,51 +110,53 @@ static int hevc_parse_slice_header(AVCodecParserContext *s, H2645NAL *nal, |
109 | 109 |
av_reduce(&avctx->framerate.den, &avctx->framerate.num, |
110 | 110 |
num, den, 1 << 30); |
111 | 111 |
|
112 |
- if (!sh->first_slice_in_pic_flag) { |
|
112 |
+ if (!first_slice_in_pic_flag) { |
|
113 |
+ unsigned int slice_segment_addr; |
|
113 | 114 |
int slice_address_length; |
114 | 115 |
|
115 | 116 |
if (ps->pps->dependent_slice_segments_enabled_flag) |
116 |
- sh->dependent_slice_segment_flag = get_bits1(gb); |
|
117 |
+ dependent_slice_segment_flag = get_bits1(gb); |
|
117 | 118 |
else |
118 |
- sh->dependent_slice_segment_flag = 0; |
|
119 |
+ dependent_slice_segment_flag = 0; |
|
119 | 120 |
|
120 | 121 |
slice_address_length = av_ceil_log2_c(ps->sps->ctb_width * |
121 | 122 |
ps->sps->ctb_height); |
122 |
- sh->slice_segment_addr = get_bitsz(gb, slice_address_length); |
|
123 |
- if (sh->slice_segment_addr >= ps->sps->ctb_width * ps->sps->ctb_height) { |
|
123 |
+ slice_segment_addr = get_bitsz(gb, slice_address_length); |
|
124 |
+ if (slice_segment_addr >= ps->sps->ctb_width * ps->sps->ctb_height) { |
|
124 | 125 |
av_log(avctx, AV_LOG_ERROR, "Invalid slice segment address: %u.\n", |
125 |
- sh->slice_segment_addr); |
|
126 |
+ slice_segment_addr); |
|
126 | 127 |
return AVERROR_INVALIDDATA; |
127 | 128 |
} |
128 | 129 |
} else |
129 |
- sh->dependent_slice_segment_flag = 0; |
|
130 |
+ dependent_slice_segment_flag = 0; |
|
130 | 131 |
|
131 |
- if (sh->dependent_slice_segment_flag) |
|
132 |
+ if (dependent_slice_segment_flag) |
|
132 | 133 |
return 0; /* break; */ |
133 | 134 |
|
134 | 135 |
for (i = 0; i < ps->pps->num_extra_slice_header_bits; i++) |
135 | 136 |
skip_bits(gb, 1); // slice_reserved_undetermined_flag[] |
136 | 137 |
|
137 |
- sh->slice_type = get_ue_golomb(gb); |
|
138 |
- if (!(sh->slice_type == HEVC_SLICE_I || sh->slice_type == HEVC_SLICE_P || |
|
139 |
- sh->slice_type == HEVC_SLICE_B)) { |
|
138 |
+ slice_type = get_ue_golomb(gb); |
|
139 |
+ if (!(slice_type == HEVC_SLICE_I || slice_type == HEVC_SLICE_P || |
|
140 |
+ slice_type == HEVC_SLICE_B)) { |
|
140 | 141 |
av_log(avctx, AV_LOG_ERROR, "Unknown slice type: %d.\n", |
141 |
- sh->slice_type); |
|
142 |
+ slice_type); |
|
142 | 143 |
return AVERROR_INVALIDDATA; |
143 | 144 |
} |
144 |
- s->pict_type = sh->slice_type == HEVC_SLICE_B ? AV_PICTURE_TYPE_B : |
|
145 |
- sh->slice_type == HEVC_SLICE_P ? AV_PICTURE_TYPE_P : |
|
146 |
- AV_PICTURE_TYPE_I; |
|
145 |
+ s->pict_type = slice_type == HEVC_SLICE_B ? AV_PICTURE_TYPE_B : |
|
146 |
+ slice_type == HEVC_SLICE_P ? AV_PICTURE_TYPE_P : |
|
147 |
+ AV_PICTURE_TYPE_I; |
|
147 | 148 |
|
148 | 149 |
if (ps->pps->output_flag_present_flag) |
149 |
- sh->pic_output_flag = get_bits1(gb); |
|
150 |
+ skip_bits1(gb); // pic_output_flag |
|
150 | 151 |
|
151 | 152 |
if (ps->sps->separate_colour_plane_flag) |
152 |
- sh->colour_plane_id = get_bits(gb, 2); |
|
153 |
+ skip_bits(gb, 2); // colour_plane_id |
|
153 | 154 |
|
154 | 155 |
if (!IS_IDR_NAL(nal)) { |
155 |
- sh->pic_order_cnt_lsb = get_bits(gb, ps->sps->log2_max_poc_lsb); |
|
156 |
- s->output_picture_number = ctx->poc = ff_hevc_compute_poc(ps->sps, ctx->pocTid0, sh->pic_order_cnt_lsb, nal->type); |
|
156 |
+ int pic_order_cnt_lsb = get_bits(gb, ps->sps->log2_max_poc_lsb); |
|
157 |
+ s->output_picture_number = ctx->poc = |
|
158 |
+ ff_hevc_compute_poc(ps->sps, ctx->pocTid0, pic_order_cnt_lsb, nal->type); |
|
157 | 159 |
} else |
158 | 160 |
s->output_picture_number = ctx->poc = 0; |
159 | 161 |
|