summaryrefslogtreecommitdiff
path: root/libavcodec/h264_parser.c
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2016-03-22 13:31:21 +0100
committerAnton Khirnov <anton@khirnov.net>2016-04-24 10:06:24 +0200
commit728d90a0c1973661a9e73da697bf4f90c9d19577 (patch)
treeb779fb0b411780ff68ac21e5de31265f4d194409 /libavcodec/h264_parser.c
parentc8dcff0cdb17d0aa03ac729eba12d1a20f1f59c8 (diff)
h264: decouple h264_sei from the h264 decoder
Make the SEI parsing independent of the H264Context, to allow decoupling the parser from the decoder.
Diffstat (limited to 'libavcodec/h264_parser.c')
-rw-r--r--libavcodec/h264_parser.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/libavcodec/h264_parser.c b/libavcodec/h264_parser.c
index 991a84128a..7c674b8f91 100644
--- a/libavcodec/h264_parser.c
+++ b/libavcodec/h264_parser.c
@@ -37,6 +37,7 @@
#include "get_bits.h"
#include "golomb.h"
#include "h264.h"
+#include "h264_sei.h"
#include "h264data.h"
#include "internal.h"
#include "mpegutils.h"
@@ -48,6 +49,7 @@ typedef struct H264ParseContext {
H264ParamSets ps;
H264DSPContext h264dsp;
H264POCContext poc;
+ H264SEIContext sei;
int got_first;
} H264ParseContext;
@@ -216,7 +218,7 @@ static inline int parse_nal_units(AVCodecParserContext *s,
s->picture_structure = AV_PICTURE_STRUCTURE_UNKNOWN;
h->avctx = avctx;
- ff_h264_reset_sei(h);
+ ff_h264_sei_uninit(&p->sei);
if (!buf_size)
return 0;
@@ -270,7 +272,7 @@ static inline int parse_nal_units(AVCodecParserContext *s,
nal.size_bits);
break;
case NAL_SEI:
- ff_h264_decode_sei(h);
+ ff_h264_sei_decode(&p->sei, &nal.gb, &p->ps, avctx);
break;
case NAL_IDR_SLICE:
s->key_frame = 1;
@@ -284,7 +286,7 @@ static inline int parse_nal_units(AVCodecParserContext *s,
get_ue_golomb(&nal.gb); // skip first_mb_in_slice
slice_type = get_ue_golomb_31(&nal.gb);
s->pict_type = ff_h264_golomb_to_pict_type[slice_type % 5];
- if (h->sei_recovery_frame_cnt >= 0) {
+ if (p->sei.recovery_point.recovery_frame_cnt >= 0) {
/* key frame, since recovery_frame_cnt is set */
s->key_frame = 1;
}
@@ -405,7 +407,7 @@ static inline int parse_nal_units(AVCodecParserContext *s,
}
if (sps->pic_struct_present_flag) {
- switch (h->sei_pic_struct) {
+ switch (p->sei.picture_timing.pic_struct) {
case SEI_PIC_STRUCT_TOP_FIELD:
case SEI_PIC_STRUCT_BOTTOM_FIELD:
s->repeat_pict = 0;
@@ -436,7 +438,7 @@ static inline int parse_nal_units(AVCodecParserContext *s,
if (h->picture_structure == PICT_FRAME) {
s->picture_structure = AV_PICTURE_STRUCTURE_FRAME;
if (sps->pic_struct_present_flag) {
- switch (h->sei_pic_struct) {
+ switch (p->sei.picture_timing.pic_struct) {
case SEI_PIC_STRUCT_TOP_BOTTOM:
case SEI_PIC_STRUCT_TOP_BOTTOM_TOP:
s->field_order = AV_FIELD_TT;
@@ -521,10 +523,10 @@ static int h264_parse(AVCodecParserContext *s,
parse_nal_units(s, avctx, buf, buf_size);
- if (h->sei_cpb_removal_delay >= 0) {
- s->dts_sync_point = h->sei_buffering_period_present;
- s->dts_ref_dts_delta = h->sei_cpb_removal_delay;
- s->pts_dts_delta = h->sei_dpb_output_delay;
+ if (p->sei.picture_timing.cpb_removal_delay >= 0) {
+ s->dts_sync_point = p->sei.buffering_period.present;
+ s->dts_ref_dts_delta = p->sei.picture_timing.cpb_removal_delay;
+ s->pts_dts_delta = p->sei.picture_timing.dpb_output_delay;
} else {
s->dts_sync_point = INT_MIN;
s->dts_ref_dts_delta = INT_MIN;
@@ -581,6 +583,8 @@ static void h264_close(AVCodecParserContext *s)
av_free(pc->buffer);
ff_h264_free_context(h);
+ ff_h264_sei_uninit(&p->sei);
+
for (i = 0; i < FF_ARRAY_ELEMS(p->ps.sps_list); i++)
av_buffer_unref(&p->ps.sps_list[i]);