[FFmpeg-cvslog] calculate frame_num for recovery point "keyframe"
John Stebbins
git at videolan.org
Sun Sep 18 23:26:41 CEST 2011
ffmpeg | branch: master | John Stebbins <jstebbins.hb at gmail.com> | Sun Sep 18 13:10:52 2011 -0700| [53e37840bf205a24c3b3ad6d838805dc54a905bf] | committer: Michael Niedermayer
calculate frame_num for recovery point "keyframe"
recovery points that have non-zero recovery_frame_cnt resulted in
flagging incomplete frames as keyframes. This delays setting the
keyframe flag till the frame has been fully constructed.
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=53e37840bf205a24c3b3ad6d838805dc54a905bf
---
libavcodec/h264.c | 14 ++++++++++++--
libavcodec/h264.h | 7 +++++++
2 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/libavcodec/h264.c b/libavcodec/h264.c
index 9e2b554..044be6b 100644
--- a/libavcodec/h264.c
+++ b/libavcodec/h264.c
@@ -3714,9 +3714,19 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size){
if((err = decode_slice_header(hx, h)))
break;
+ if (h->sei_recovery_frame_cnt >= 0) {
+ h->recovery_frame = (h->frame_num + h->sei_recovery_frame_cnt) %
+ (1 << h->sps.log2_max_frame_num);
+ }
+
s->current_picture_ptr->f.key_frame |=
- (hx->nal_unit_type == NAL_IDR_SLICE) ||
- (h->sei_recovery_frame_cnt >= 0);
+ (hx->nal_unit_type == NAL_IDR_SLICE);
+
+ if (h->recovery_frame == h->frame_num) {
+ s->current_picture_ptr->f.key_frame |= 1;
+ h->recovery_frame = -1;
+ }
+
h->sync |= !!s->current_picture_ptr->f.key_frame;
h->sync |= 3*!!(s->flags2 & CODEC_FLAG2_SHOW_ALL);
s->current_picture_ptr->sync = h->sync;
diff --git a/libavcodec/h264.h b/libavcodec/h264.h
index ed4afdd..47d6d7f 100644
--- a/libavcodec/h264.h
+++ b/libavcodec/h264.h
@@ -571,6 +571,13 @@ typedef struct H264Context{
* frames.
*/
int sei_recovery_frame_cnt;
+ /**
+ * recovery_frame is the frame_num at which the next frame should
+ * be fully constructed.
+ *
+ * Set to -1 when not expecting a recovery point.
+ */
+ int recovery_frame;
int luma_weight_flag[2]; ///< 7.4.3.2 luma_weight_lX_flag
int chroma_weight_flag[2]; ///< 7.4.3.2 chroma_weight_lX_flag
More information about the ffmpeg-cvslog
mailing list