[FFmpeg-devel] [PATCH 1/4] cbs_mpeg2: Correct and use enum values
James Almer
jamrial at gmail.com
Tue Apr 23 23:38:31 EEST 2019
On 4/23/2019 5:32 PM, Andreas Rheinhardt wrote:
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>
> ---
> libavcodec/cbs_mpeg2.c | 30 +++++++++++++++-----------
> libavcodec/cbs_mpeg2.h | 2 +-
> libavcodec/cbs_mpeg2_syntax_template.c | 10 ++++-----
> 3 files changed, 23 insertions(+), 19 deletions(-)
>
> diff --git a/libavcodec/cbs_mpeg2.c b/libavcodec/cbs_mpeg2.c
> index 8b8b266563..cdde68ea38 100644
> --- a/libavcodec/cbs_mpeg2.c
> +++ b/libavcodec/cbs_mpeg2.c
> @@ -215,13 +215,16 @@ static int cbs_mpeg2_read_unit(CodedBitstreamContext *ctx,
> return err; \
> } \
> break;
> - START(0x00, MPEG2RawPictureHeader, picture_header, NULL);
> - START(0xb2, MPEG2RawUserData, user_data,
> - &cbs_mpeg2_free_user_data);
> - START(0xb3, MPEG2RawSequenceHeader, sequence_header, NULL);
> - START(0xb5, MPEG2RawExtensionData, extension_data, NULL);
> - START(0xb8, MPEG2RawGroupOfPicturesHeader,
> - group_of_pictures_header, NULL);
> + START(MPEG2_START_PICTURE, MPEG2RawPictureHeader,
> + picture_header, NULL);
> + START(MPEG2_START_USER_DATA, MPEG2RawUserData,
> + user_data, &cbs_mpeg2_free_user_data);
> + START(MPEG2_START_SEQUENCE_HEADER, MPEG2RawSequenceHeader,
> + sequence_header, NULL);
> + START(MPEG2_START_EXTENSION, MPEG2RawExtensionData,
> + extension_data, NULL);
> + START(MPEG2_START_GROUP, MPEG2RawGroupOfPicturesHeader,
> + group_of_pictures_header, NULL);
> #undef START
> default:
> av_log(ctx->log_ctx, AV_LOG_ERROR, "Unknown start code %02"PRIx32".\n",
> @@ -244,11 +247,12 @@ static int cbs_mpeg2_write_header(CodedBitstreamContext *ctx,
> case start_code: \
> err = cbs_mpeg2_write_ ## func(ctx, pbc, unit->content); \
> break;
> - START(0x00, MPEG2RawPictureHeader, picture_header);
> - START(0xb2, MPEG2RawUserData, user_data);
> - START(0xb3, MPEG2RawSequenceHeader, sequence_header);
> - START(0xb5, MPEG2RawExtensionData, extension_data);
> - START(0xb8, MPEG2RawGroupOfPicturesHeader, group_of_pictures_header);
> + START(MPEG2_START_PICTURE, MPEG2RawPictureHeader, picture_header);
> + START(MPEG2_START_USER_DATA, MPEG2RawUserData, user_data);
> + START(MPEG2_START_SEQUENCE_HEADER, MPEG2RawSequenceHeader, sequence_header);
> + START(MPEG2_START_EXTENSION, MPEG2RawExtensionData, extension_data);
> + START(MPEG2_START_GROUP, MPEG2RawGroupOfPicturesHeader,
> + group_of_pictures_header);
> #undef START
> default:
> av_log(ctx->log_ctx, AV_LOG_ERROR, "Write unimplemented for start "
> @@ -331,7 +335,7 @@ static int cbs_mpeg2_write_unit(CodedBitstreamContext *ctx,
>
> init_put_bits(&pbc, priv->write_buffer, priv->write_buffer_size);
>
> - if (unit->type >= 0x01 && unit->type <= 0xaf)
> + if (MPEG2_START_IS_SLICE(unit->type))
> err = cbs_mpeg2_write_slice(ctx, unit, &pbc);
> else
> err = cbs_mpeg2_write_header(ctx, unit, &pbc);
> diff --git a/libavcodec/cbs_mpeg2.h b/libavcodec/cbs_mpeg2.h
> index 92caa99dc1..7565695acb 100644
> --- a/libavcodec/cbs_mpeg2.h
> +++ b/libavcodec/cbs_mpeg2.h
> @@ -51,7 +51,7 @@ enum {
> MPEG2_EXTENSION_PICTURE_CODING = 0x8,
> MPEG2_EXTENSION_PICTURE_SPATIAL_SCALABLE = 0x9,
> MPEG2_EXTENSION_PICTURE_TEMPORAL_SCALABLE = 0xa,
> - MPEG2_EXTENSION_CAMAERA_PARAMETERS = 0xb,
> + MPEG2_EXTENSION_CAMERA_PARAMETERS = 0xb,
> MPEG2_EXTENSION_ITU_T = 0xc,
> };
>
> diff --git a/libavcodec/cbs_mpeg2_syntax_template.c b/libavcodec/cbs_mpeg2_syntax_template.c
> index 88cf453b17..10aaea7734 100644
> --- a/libavcodec/cbs_mpeg2_syntax_template.c
> +++ b/libavcodec/cbs_mpeg2_syntax_template.c
> @@ -303,19 +303,19 @@ static int FUNC(extension_data)(CodedBitstreamContext *ctx, RWContext *rw,
> ui(4, extension_start_code_identifier);
>
> switch (current->extension_start_code_identifier) {
> - case 1:
> + case MPEG2_EXTENSION_SEQUENCE:
> return FUNC(sequence_extension)
> (ctx, rw, ¤t->data.sequence);
> - case 2:
> + case MPEG2_EXTENSION_SEQUENCE_DISPLAY:
> return FUNC(sequence_display_extension)
> (ctx, rw, ¤t->data.sequence_display);
> - case 3:
> + case MPEG2_EXTENSION_QUANT_MATRIX:
> return FUNC(quant_matrix_extension)
> (ctx, rw, ¤t->data.quant_matrix);
> - case 7:
> + case MPEG2_EXTENSION_PICTURE_DISPLAY:
> return FUNC(picture_display_extension)
> (ctx, rw, ¤t->data.picture_display);
> - case 8:
> + case MPEG2_EXTENSION_PICTURE_CODING:
> return FUNC(picture_coding_extension)
> (ctx, rw, ¤t->data.picture_coding);
> default:
LGTM, but Mark has the last word since it's his code.
More information about the ffmpeg-devel
mailing list