diff options
author | Sasi Inguva <isasi-at-google.com@ffmpeg.org> | 2016-09-15 13:36:16 -0700 |
---|---|---|
committer | Michael Niedermayer <michael@niedermayer.cc> | 2016-09-19 19:51:13 +0200 |
commit | 2dbedc20ce2f92e8c76e4284441d881906fabe5d (patch) | |
tree | 1faf04165e94be0f4d90a673ae18037bee51ba77 | |
parent | 778af68c708ed0807889d40d3e3d514cb6bec702 (diff) | |
download | ffmpeg-2dbedc20ce2f92e8c76e4284441d881906fabe5d.tar.gz |
lavc: Add a flag in AVPacket to discard packet after decoding. Discard frames after decoding based on the flag.
Signed-off-by: Sasi Inguva <isasi@google.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r-- | libavcodec/avcodec.h | 6 | ||||
-rw-r--r-- | libavcodec/utils.c | 15 |
2 files changed, 20 insertions, 1 deletions
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 01f9b29773..db1061ddb5 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -1621,6 +1621,12 @@ typedef struct AVPacket { } AVPacket; #define AV_PKT_FLAG_KEY 0x0001 ///< The packet contains a keyframe #define AV_PKT_FLAG_CORRUPT 0x0002 ///< The packet content is corrupted +/** + * Flag is used to discard packets which are required to maintain valid + * decoder state but are not required for output and should be dropped + * after decoding. + **/ +#define AV_PKT_FLAG_DISCARD 0x0004 enum AVSideDataParamChangeFlags { AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT = 0x0001, diff --git a/libavcodec/utils.c b/libavcodec/utils.c index 0f6d0e7fe8..4734a70ae2 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -784,6 +784,12 @@ int ff_init_buffer_info(AVCodecContext *avctx, AVFrame *frame) } } add_metadata_from_side_data(pkt, frame); + + if (pkt->flags & AV_PKT_FLAG_DISCARD) { + frame->flags |= AV_FRAME_FLAG_DISCARD; + } else { + frame->flags = (frame->flags & ~AV_FRAME_FLAG_DISCARD); + } } else { frame->pkt_pts = AV_NOPTS_VALUE; av_frame_set_pkt_pos (frame, -1); @@ -2247,7 +2253,9 @@ fail: if(ret == tmp.size) ret = avpkt->size; } - + if (picture->flags & AV_FRAME_FLAG_DISCARD) { + *got_picture_ptr = 0; + } if (*got_picture_ptr) { if (!avctx->refcounted_frames) { int err = unrefcount_frame(avci, picture); @@ -2343,6 +2351,11 @@ int attribute_align_arg avcodec_decode_audio4(AVCodecContext *avctx, frame->sample_rate = avctx->sample_rate; } + + if (frame->flags & AV_FRAME_FLAG_DISCARD) { + *got_frame_ptr = 0; + } + side= av_packet_get_side_data(avctx->internal->pkt, AV_PKT_DATA_SKIP_SAMPLES, &side_size); if(side && side_size>=10) { avctx->internal->skip_samples = AV_RL32(side); |