This is in preparation for another patch that will stop needless reallocations of the unit array.
Unified · Split
| @@ -199,18 +199,18 @@ static int filter_units_init(AVBSFContext *bsf) · 198 unmodified lines | ||
| 199 | 199 | ctx->cbc->nb_decompose_unit_types = 0; |
| 200 | 200 | |
| 201 | 201 | if (bsf->par_in->extradata) { |
| 202 | − CodedBitstreamFragment ps; | |
| 202 | + CodedBitstreamFragment *frag = &ctx->fragment; | |
| 203 | 203 | |
| 204 | − err = ff_cbs_read_extradata(ctx->cbc, &ps, bsf->par_in); | |
| 204 | + err = ff_cbs_read_extradata(ctx->cbc, frag, bsf->par_in); | |
| 205 | 205 | if (err < 0) { |
| 206 | 206 | av_log(bsf, AV_LOG_ERROR, "Failed to read extradata.\n"); |
| 207 | 207 | } else { |
| 208 | − err = ff_cbs_write_extradata(ctx->cbc, bsf->par_out, &ps); | |
| 208 | + err = ff_cbs_write_extradata(ctx->cbc, bsf->par_out, frag); | |
| 209 | 209 | if (err < 0) |
| 210 | 210 | av_log(bsf, AV_LOG_ERROR, "Failed to write extradata.\n"); |
| 211 | 211 | } |
| 212 | 212 | |
| 213 | − ff_cbs_fragment_uninit(ctx->cbc, &ps); | |
| 213 | + ff_cbs_fragment_uninit(ctx->cbc, frag); | |
| 214 | 214 | } |
| 215 | 215 | |
| 216 | 216 | return err; |
| @@ -28,6 +28,7 @@ · 27 unmodified lines | ||
| 28 | 28 | |
| 29 | 29 | typedef struct TraceHeadersContext { |
| 30 | 30 | CodedBitstreamContext *cbc; |
| 31 | + CodedBitstreamFragment fragment; | |
| 31 | 32 | } TraceHeadersContext; |
| 32 | 33 | |
| 33 | 34 | |
| @@ -44,13 +45,13 @@ static int trace_headers_init(AVBSFContext *bsf) · 10 unmodified lines | ||
| 44 | 45 | ctx->cbc->trace_level = AV_LOG_INFO; |
| 45 | 46 | |
| 46 | 47 | if (bsf->par_in->extradata) { |
| 47 | − CodedBitstreamFragment ps; | |
| 48 | + CodedBitstreamFragment *frag = &ctx->fragment; | |
| 48 | 49 | |
| 49 | 50 | av_log(bsf, AV_LOG_INFO, "Extradata\n"); |
| 50 | 51 | |
| 51 | − err = ff_cbs_read_extradata(ctx->cbc, &ps, bsf->par_in); | |
| 52 | + err = ff_cbs_read_extradata(ctx->cbc, frag, bsf->par_in); | |
| 52 | 53 | |
| 53 | − ff_cbs_fragment_uninit(ctx->cbc, &ps); | |
| 54 | + ff_cbs_fragment_uninit(ctx->cbc, frag); | |
| 54 | 55 | } |
| 55 | 56 | |
| 56 | 57 | return err; |
| @@ -66,7 +67,7 @@ static void trace_headers_close(AVBSFContext *bsf) · 9 unmodified lines | ||
| 66 | 67 | static int trace_headers(AVBSFContext *bsf, AVPacket *pkt) |
| 67 | 68 | { |
| 68 | 69 | TraceHeadersContext *ctx = bsf->priv_data; |
| 69 | − CodedBitstreamFragment au; | |
| 70 | + CodedBitstreamFragment *frag = &ctx->fragment; | |
| 70 | 71 | char tmp[256] = { 0 }; |
| 71 | 72 | int err; |
| 72 | 73 | |
| @@ -92,9 +93,9 @@ static int trace_headers(AVBSFContext *bsf, AVPacket *pkt) · 19 unmodified lines | ||
| 92 | 93 | |
| 93 | 94 | av_log(bsf, AV_LOG_INFO, "Packet: %d bytes%s.\n", pkt->size, tmp); |
| 94 | 95 | |
| 95 | − err = ff_cbs_read_packet(ctx->cbc, &au, pkt); | |
| 96 | + err = ff_cbs_read_packet(ctx->cbc, frag, pkt); | |
| 96 | 97 | |
| 97 | − ff_cbs_fragment_uninit(ctx->cbc, &au); | |
| 98 | + ff_cbs_fragment_uninit(ctx->cbc, frag); | |
| 98 | 99 | |
| 99 | 100 | if (err < 0) |
| 100 | 101 | av_packet_unref(pkt); |