Browse code

h264_mp4toannexb_bsf: account for consecutive IDR pictures.

If there are consecutive IDR pictures, then SPS/PPS should be prepended
to all of them, not only the first one.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>

Benoit Fouet authored on 2014/07/31 22:32:14
Showing 1 changed files
... ...
@@ -179,6 +179,11 @@ static int h264_mp4toannexb_filter(AVBitStreamFilterContext *bsfc,
179 179
         if (ctx->first_idr && (unit_type == 7 || unit_type == 8))
180 180
             ctx->idr_sps_pps_seen = 1;
181 181
 
182
+        /* if this is a new IDR picture following an IDR picture, reset the idr flag.
183
+         * Just check first_mb_in_slice to be 0 as this is the simplest solution.
184
+         * This could be checking idr_pic_id instead, but would complexify the parsing. */
185
+        if (!ctx->first_idr && unit_type == 5 && (buf[1] & 0x80))
186
+            ctx->first_idr = 1;
182 187
 
183 188
         /* prepend only to the first type 5 NAL unit of an IDR picture, if no sps/pps are already present */
184 189
         if (ctx->first_idr && unit_type == 5 && !ctx->idr_sps_pps_seen) {