Message ID | AM7PR03MB66601C5B5DF7C915C6734E438F299@AM7PR03MB6660.eurprd03.prod.outlook.com |
---|---|
State | Accepted |
Commit | d64e27f5213001c86c8374f373d0513fe5d2e251 |
Headers | show |
Series | [FFmpeg-devel,1/7] avcodec/cbs_mpeg2: Remove redundant counter | expand |
Context | Check | Description |
---|---|---|
andriy/make_x86 | success | Make finished |
andriy/make_fate_x86 | success | Make fate finished |
Andreas Rheinhardt: > Use -1 as the position in ff_cbs_insert_unit_data() > which implicitly reuses frag->nb_units as the counter. > > Also switch to a do-while-loop, as it is more natural > than a for-loop now that the counter is gone. > > Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> > --- > libavcodec/cbs_mpeg2.c | 12 +++++------- > 1 file changed, 5 insertions(+), 7 deletions(-) > > diff --git a/libavcodec/cbs_mpeg2.c b/libavcodec/cbs_mpeg2.c > index 26400f279f..4395bbf047 100644 > --- a/libavcodec/cbs_mpeg2.c > +++ b/libavcodec/cbs_mpeg2.c > @@ -148,7 +148,8 @@ static int cbs_mpeg2_split_fragment(CodedBitstreamContext *ctx, > CodedBitstreamUnitType unit_type; > uint32_t start_code = -1; > size_t unit_size; > - int err, i, final = 0; > + int err; > + int final = 0; > > start = avpriv_find_start_code(frag->data, frag->data + frag->data_size, > &start_code); > @@ -157,7 +158,7 @@ static int cbs_mpeg2_split_fragment(CodedBitstreamContext *ctx, > return AVERROR_INVALIDDATA; > } > > - for (i = 0;; i++) { > + do { > unit_type = start_code & 0xff; > > if (start == frag->data + frag->data_size) { > @@ -185,16 +186,13 @@ static int cbs_mpeg2_split_fragment(CodedBitstreamContext *ctx, > final = 1; > } > > - err = ff_cbs_insert_unit_data(frag, i, unit_type, (uint8_t*)start, > + err = ff_cbs_insert_unit_data(frag, -1, unit_type, (uint8_t*)start, > unit_size, frag->data_ref); > if (err < 0) > return err; > > - if (final) > - break; > - > start = end; > - } > + } while (!final); > > return 0; > } Will apply this patchset tomorrow unless there are objections. - Andreas
diff --git a/libavcodec/cbs_mpeg2.c b/libavcodec/cbs_mpeg2.c index 26400f279f..4395bbf047 100644 --- a/libavcodec/cbs_mpeg2.c +++ b/libavcodec/cbs_mpeg2.c @@ -148,7 +148,8 @@ static int cbs_mpeg2_split_fragment(CodedBitstreamContext *ctx, CodedBitstreamUnitType unit_type; uint32_t start_code = -1; size_t unit_size; - int err, i, final = 0; + int err; + int final = 0; start = avpriv_find_start_code(frag->data, frag->data + frag->data_size, &start_code); @@ -157,7 +158,7 @@ static int cbs_mpeg2_split_fragment(CodedBitstreamContext *ctx, return AVERROR_INVALIDDATA; } - for (i = 0;; i++) { + do { unit_type = start_code & 0xff; if (start == frag->data + frag->data_size) { @@ -185,16 +186,13 @@ static int cbs_mpeg2_split_fragment(CodedBitstreamContext *ctx, final = 1; } - err = ff_cbs_insert_unit_data(frag, i, unit_type, (uint8_t*)start, + err = ff_cbs_insert_unit_data(frag, -1, unit_type, (uint8_t*)start, unit_size, frag->data_ref); if (err < 0) return err; - if (final) - break; - start = end; - } + } while (!final); return 0; }
Use -1 as the position in ff_cbs_insert_unit_data() which implicitly reuses frag->nb_units as the counter. Also switch to a do-while-loop, as it is more natural than a for-loop now that the counter is gone. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> --- libavcodec/cbs_mpeg2.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)