[FFmpeg-devel] [PATCH 18/21] avformat/matroskadec: Combine two arrays

Steve Lhomme robux4 at ycbcr.xyz
Sun Apr 7 10:59:44 EEST 2019


On 3/27/2019 12:18 PM, Andreas Rheinhardt via ffmpeg-devel wrote:
> By including SimpleBlocks and Blocksgroups twice in the same EbmlSyntax
> array (with different semantics), one can reduce the duplication of the
> other values.
>
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at googlemail.com>
> ---
>   libavformat/matroskadec.c | 13 +++----------
>   1 file changed, 3 insertions(+), 10 deletions(-)
>
> diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
> index 3adcb3e86d..60f58cefa9 100644
> --- a/libavformat/matroskadec.c
> +++ b/libavformat/matroskadec.c
> @@ -704,25 +704,18 @@ static const EbmlSyntax matroska_blockgroup[] = {
>   };
>   
>   static const EbmlSyntax matroska_cluster_parsing[] = {
> -    { MATROSKA_ID_CLUSTERTIMECODE, EBML_UINT, 0, offsetof(MatroskaCluster, timecode) },
> -    { MATROSKA_ID_BLOCKGROUP,      EBML_NEST, 0, 0, { .n = matroska_blockgroup } },
>       { MATROSKA_ID_SIMPLEBLOCK,     EBML_BIN,  0, offsetof(MatroskaBlock, bin) },
> -    { MATROSKA_ID_CLUSTERPOSITION, EBML_NONE },
> -    { MATROSKA_ID_CLUSTERPREVSIZE, EBML_NONE },
> -    { 0 }
> -};
> -
> -static const EbmlSyntax matroska_cluster_initial[] = {
> +    { MATROSKA_ID_BLOCKGROUP,      EBML_NEST, 0, 0, { .n = matroska_blockgroup } },
>       { MATROSKA_ID_CLUSTERTIMECODE, EBML_UINT, 0, offsetof(MatroskaCluster, timecode) },
> -    { MATROSKA_ID_BLOCKGROUP,      EBML_STOP },
>       { MATROSKA_ID_SIMPLEBLOCK,     EBML_STOP },
> +    { MATROSKA_ID_BLOCKGROUP,      EBML_STOP },
>       { MATROSKA_ID_CLUSTERPOSITION, EBML_NONE },
>       { MATROSKA_ID_CLUSTERPREVSIZE, EBML_NONE },
>       { 0 }
>   };
>   
>   static const EbmlSyntax matroska_cluster_enter[] = {
> -    { MATROSKA_ID_CLUSTER,     EBML_NEST, 0, 0, { .n = matroska_cluster_initial } },
> +    { MATROSKA_ID_CLUSTER,     EBML_NEST, 0, 0, { .n = &matroska_cluster_parsing[2] } },

To avoid breaking this optimisation when the code is changed you might 
use some static_assert to make sure that matroska_cluster_parsing[2].id 
is MATROSKA_ID_CLUSTERTIMECODE
>       { 0 }
>   };
>   
> -- 
> 2.19.2
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".



More information about the ffmpeg-devel mailing list