]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/h264.c
mpegvideo_enc: separate declarations and statements
[ffmpeg] / libavcodec / h264.c
index 109a1095308487e9301db4fd814ca41e4e4eed62..a9a10513e39e4ba7ea7e94876673a21645a77802 100644 (file)
@@ -1530,7 +1530,11 @@ static void decode_postinit(H264Context *h, int setup_finished){
                 h->next_outputed_poc = INT_MIN;
             }
         } else {
-            h->next_outputed_poc = out->poc;
+            if (out_idx == 0 && pics > 1 && h->delayed_pic[0]->f.key_frame) {
+                h->next_outputed_poc = INT_MIN;
+            } else {
+                h->next_outputed_poc = out->poc;
+            }
         }
         h->mmco_reset = 0;
     }else{
@@ -3755,7 +3759,7 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size){
         int consumed;
         int dst_length;
         int bit_length;
-        const uint8_t *ptr;
+        uint8_t *ptr;
         int i, nalsize = 0;
         int err;
 
@@ -3805,6 +3809,9 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size){
         }
 
         if (h->is_avc && (nalsize != consumed) && nalsize){
+            // set trailing bits in the last partial byte to zero
+            if (bit_length & 7)
+                ptr[bit_length >> 3] = ptr[bit_length >> 3] & (0xff << 8 - (bit_length & 7));
             av_log(h->s.avctx, AV_LOG_DEBUG, "AVC: Consumed only %d bytes instead of %d\n", consumed, nalsize);
         }