[FFmpeg-devel] [PATCH] avcodec/h264_parser: export sei recovery frame count as side data
Timothy Gu
timothygu99 at gmail.com
Thu May 15 02:53:37 CEST 2014
On May 14, 2014 3:51 PM, "Michael Niedermayer" <michaelni at gmx.at> wrote:
>
> TODO: split between API addition and h264 parser change
>
> Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
> ---
> libavcodec/avcodec.h | 13 +++++++++++++
> libavcodec/h264_parser.c | 2 ++
> libavcodec/parser.c | 1 +
> libavformat/utils.c | 6 ++++++
> 4 files changed, 22 insertions(+)
>
> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> index 9a24c96..61176be 100644
> --- a/libavcodec/avcodec.h
> +++ b/libavcodec/avcodec.h
> @@ -1115,6 +1115,12 @@ enum AVPacketSideDataType {
> * side data includes updated metadata which appeared in the stream.
> */
> AV_PKT_DATA_METADATA_UPDATE,
> +
> + AV_PKT_DATA_DECODER_RECOVERY,
> + /**
> + * signed LE 32bit integer specifying the number of codec specific
units
> + * (frames(h264) or POC(HEVC)) until the decoder output is clear or
artifacts
> + */
Larger enum value? Also, the Doxygen should be before the declaration.
> };
>
> typedef struct AVPacketSideData {
> @@ -4263,6 +4269,13 @@ typedef struct AVCodecParserContext {
> * For example, this corresponds to H.264 PicOrderCnt.
> */
> int output_picture_number;
> +
> + /**
> + * Number of frames or POC units until decoding is practically clear
of artifacts.
> + * The exact unit depends on the video standard, H.264 stores frame
count,
> + * HEVC, POC.
> + */
> + int recovery_frame_cnt;
> } AVCodecParserContext;
>
> typedef struct AVCodecParser {
> diff --git a/libavcodec/h264_parser.c b/libavcodec/h264_parser.c
> index ea0ab98..6fa04c8 100644
> --- a/libavcodec/h264_parser.c
> +++ b/libavcodec/h264_parser.c
> @@ -491,6 +491,8 @@ static int h264_parse(AVCodecParserContext *s,
>
> parse_nal_units(s, avctx, buf, buf_size);
>
> + s->recovery_frame_cnt = h->sei_recovery_frame_cnt;
> +
> 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;
> diff --git a/libavcodec/parser.c b/libavcodec/parser.c
> index 3169e25..74525b9 100644
> --- a/libavcodec/parser.c
> +++ b/libavcodec/parser.c
> @@ -84,6 +84,7 @@ found:
> s->dts_sync_point = INT_MIN;
> s->dts_ref_dts_delta = INT_MIN;
> s->pts_dts_delta = INT_MIN;
> + s->recovery_frame_cnt = INT_MIN;
> return s;
>
> err_out:
> diff --git a/libavformat/utils.c b/libavformat/utils.c
> index d84d605..45ce945 100644
> --- a/libavformat/utils.c
> +++ b/libavformat/utils.c
> @@ -1135,6 +1135,12 @@ static void compute_pkt_fields(AVFormatContext *s,
AVStream *st,
> if (s->flags & AVFMT_FLAG_NOFILLIN)
> return;
>
> + if (pc && pc->recovery_frame_cnt >= 0) {
> + uint8_t *side_data = av_packet_new_side_data(pkt,
AV_PKT_DATA_DECODER_RECOVERY, 4);
> + if (side_data)
> + AV_WL32(side_data, pc->recovery_frame_cnt);
> + }
> +
> if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO && pkt->dts !=
AV_NOPTS_VALUE) {
> if (pkt->dts == pkt->pts && st->last_dts_for_order_check !=
AV_NOPTS_VALUE) {
> if (st->last_dts_for_order_check <= pkt->dts) {
> --
> 1.7.9.5
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
More information about the ffmpeg-devel
mailing list