summaryrefslogtreecommitdiff
path: root/libavcodec/h264_parser.c
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2016-03-21 16:14:31 +0100
committerAnton Khirnov <anton@khirnov.net>2016-04-24 10:06:24 +0200
commitc8dcff0cdb17d0aa03ac729eba12d1a20f1f59c8 (patch)
treeb86b624464e77fe4d82a4ccef0b5fec64ff639c7 /libavcodec/h264_parser.c
parent113aeee6aed35cb786a9f6d69b0cb210f498b9da (diff)
h264: factor out calculating the POC count into a separate file
This will allow decoupling the parser from the decoder.
Diffstat (limited to 'libavcodec/h264_parser.c')
-rw-r--r--libavcodec/h264_parser.c34
1 files changed, 18 insertions, 16 deletions
diff --git a/libavcodec/h264_parser.c b/libavcodec/h264_parser.c
index d62eb73515..991a84128a 100644
--- a/libavcodec/h264_parser.c
+++ b/libavcodec/h264_parser.c
@@ -47,6 +47,7 @@ typedef struct H264ParseContext {
ParseContext pc;
H264ParamSets ps;
H264DSPContext h264dsp;
+ H264POCContext poc;
int got_first;
} H264ParseContext;
@@ -274,10 +275,10 @@ static inline int parse_nal_units(AVCodecParserContext *s,
case NAL_IDR_SLICE:
s->key_frame = 1;
- h->prev_frame_num = 0;
- h->prev_frame_num_offset = 0;
- h->prev_poc_msb =
- h->prev_poc_lsb = 0;
+ p->poc.prev_frame_num = 0;
+ p->poc.prev_frame_num_offset = 0;
+ p->poc.prev_poc_msb =
+ p->poc.prev_poc_lsb = 0;
/* fall through */
case NAL_SLICE:
get_ue_golomb(&nal.gb); // skip first_mb_in_slice
@@ -310,7 +311,7 @@ static inline int parse_nal_units(AVCodecParserContext *s,
h->ps.pps = p->ps.pps;
sps = p->ps.sps;
- h->frame_num = get_bits(&nal.gb, sps->log2_max_frame_num);
+ p->poc.frame_num = get_bits(&nal.gb, sps->log2_max_frame_num);
s->coded_width = 16 * sps->mb_width;
s->coded_height = 16 * sps->mb_height;
@@ -357,26 +358,27 @@ static inline int parse_nal_units(AVCodecParserContext *s,
if (h->nal_unit_type == NAL_IDR_SLICE)
get_ue_golomb(&nal.gb); /* idr_pic_id */
if (sps->poc_type == 0) {
- h->poc_lsb = get_bits(&nal.gb, sps->log2_max_poc_lsb);
+ p->poc.poc_lsb = get_bits(&nal.gb, sps->log2_max_poc_lsb);
if (p->ps.pps->pic_order_present == 1 &&
h->picture_structure == PICT_FRAME)
- h->delta_poc_bottom = get_se_golomb(&nal.gb);
+ p->poc.delta_poc_bottom = get_se_golomb(&nal.gb);
}
if (sps->poc_type == 1 &&
!sps->delta_pic_order_always_zero_flag) {
- h->delta_poc[0] = get_se_golomb(&nal.gb);
+ p->poc.delta_poc[0] = get_se_golomb(&nal.gb);
if (p->ps.pps->pic_order_present == 1 &&
h->picture_structure == PICT_FRAME)
- h->delta_poc[1] = get_se_golomb(&nal.gb);
+ p->poc.delta_poc[1] = get_se_golomb(&nal.gb);
}
/* Decode POC of this picture.
* The prev_ values needed for decoding POC of the next picture are not set here. */
field_poc[0] = field_poc[1] = INT_MAX;
- ff_init_poc(h, field_poc, &s->output_picture_number);
+ ff_h264_init_poc(field_poc, &s->output_picture_number, sps,
+ &p->poc, h->picture_structure, nal.ref_idc);
/* Continue parsing to check if MMCO_RESET is present.
* FIXME: MMCO_RESET could appear in non-first slice.
@@ -389,15 +391,15 @@ static inline int parse_nal_units(AVCodecParserContext *s,
}
/* Set up the prev_ values for decoding POC of the next picture. */
- h->prev_frame_num = got_reset ? 0 : h->frame_num;
- h->prev_frame_num_offset = got_reset ? 0 : h->frame_num_offset;
+ p->poc.prev_frame_num = got_reset ? 0 : p->poc.frame_num;
+ p->poc.prev_frame_num_offset = got_reset ? 0 : p->poc.frame_num_offset;
if (h->nal_ref_idc != 0) {
if (!got_reset) {
- h->prev_poc_msb = h->poc_msb;
- h->prev_poc_lsb = h->poc_lsb;
+ p->poc.prev_poc_msb = p->poc.poc_msb;
+ p->poc.prev_poc_lsb = p->poc.poc_lsb;
} else {
- h->prev_poc_msb = 0;
- h->prev_poc_lsb =
+ p->poc.prev_poc_msb = 0;
+ p->poc.prev_poc_lsb =
h->picture_structure == PICT_BOTTOM_FIELD ? 0 : field_poc[0];
}
}