...
|
...
|
@@ -28,6 +28,7 @@
|
28
|
28
|
typedef struct H264BSFContext {
|
29
|
29
|
uint8_t length_size;
|
30
|
30
|
uint8_t first_idr;
|
|
31
|
+ uint8_t idr_sps_pps_seen;
|
31
|
32
|
int extradata_parsed;
|
32
|
33
|
} H264BSFContext;
|
33
|
34
|
|
...
|
...
|
@@ -155,6 +156,7 @@ static int h264_mp4toannexb_filter(AVBitStreamFilterContext *bsfc,
|
155
|
155
|
return ret;
|
156
|
156
|
ctx->length_size = ret;
|
157
|
157
|
ctx->first_idr = 1;
|
|
158
|
+ ctx->idr_sps_pps_seen = 0;
|
158
|
159
|
ctx->extradata_parsed = 1;
|
159
|
160
|
}
|
160
|
161
|
|
...
|
...
|
@@ -174,8 +176,12 @@ static int h264_mp4toannexb_filter(AVBitStreamFilterContext *bsfc,
|
174
|
174
|
if (buf + nal_size > buf_end || nal_size < 0)
|
175
|
175
|
goto fail;
|
176
|
176
|
|
177
|
|
- /* prepend only to the first type 5 NAL unit of an IDR picture */
|
178
|
|
- if (ctx->first_idr && (unit_type == 5 || unit_type == 7 || unit_type == 8)) {
|
|
177
|
+ if (ctx->first_idr && (unit_type == 7 || unit_type == 8))
|
|
178
|
+ ctx->idr_sps_pps_seen = 1;
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+ /* prepend only to the first type 5 NAL unit of an IDR picture, if no sps/pps are already present */
|
|
182
|
+ if (ctx->first_idr && unit_type == 5 && !ctx->idr_sps_pps_seen) {
|
179
|
183
|
if ((ret=alloc_and_copy(poutbuf, poutbuf_size,
|
180
|
184
|
avctx->extradata, avctx->extradata_size,
|
181
|
185
|
buf, nal_size)) < 0)
|
...
|
...
|
@@ -185,8 +191,10 @@ static int h264_mp4toannexb_filter(AVBitStreamFilterContext *bsfc,
|
185
|
185
|
if ((ret=alloc_and_copy(poutbuf, poutbuf_size,
|
186
|
186
|
NULL, 0, buf, nal_size)) < 0)
|
187
|
187
|
goto fail;
|
188
|
|
- if (!ctx->first_idr && unit_type == 1)
|
|
188
|
+ if (!ctx->first_idr && unit_type == 1) {
|
189
|
189
|
ctx->first_idr = 1;
|
|
190
|
+ ctx->idr_sps_pps_seen = 0;
|
|
191
|
+ }
|
190
|
192
|
}
|
191
|
193
|
|
192
|
194
|
buf += nal_size;
|