diff mbox

[FFmpeg-devel] avcodec/h264: Declare the local variable decode_chroma as const.

Message ID 20170720173119.13779-1-wtc@google.com
State Accepted
Commit 99c5ac20397ec1814d6a50bed74cadd421ad8b9d
Headers show

Commit Message

Wan-Teh Chang July 20, 2017, 5:31 p.m. UTC
ff_h264_decode_mb_cabac() and ff_h264_decode_mb_cavlc() are very long
functions. Declaring decode_chroma as const makes it clear the variable
doesn't change after initialization.

Signed-off-by: Wan-Teh Chang <wtc@google.com>
---
 libavcodec/h264_cabac.c | 4 ++--
 libavcodec/h264_cavlc.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

Comments

Michael Niedermayer July 20, 2017, 10:20 p.m. UTC | #1
On Thu, Jul 20, 2017 at 10:31:19AM -0700, Wan-Teh Chang wrote:
> ff_h264_decode_mb_cabac() and ff_h264_decode_mb_cavlc() are very long
> functions. Declaring decode_chroma as const makes it clear the variable
> doesn't change after initialization.
> 
> Signed-off-by: Wan-Teh Chang <wtc@google.com>
> ---
>  libavcodec/h264_cabac.c | 4 ++--
>  libavcodec/h264_cavlc.c | 4 ++--
>  2 files changed, 4 insertions(+), 4 deletions(-)

applied

thx

[...]
diff mbox

Patch

diff --git a/libavcodec/h264_cabac.c b/libavcodec/h264_cabac.c
index 0973e30be9..345834645c 100644
--- a/libavcodec/h264_cabac.c
+++ b/libavcodec/h264_cabac.c
@@ -1916,8 +1916,8 @@  int ff_h264_decode_mb_cabac(const H264Context *h, H264SliceContext *sl)
     const SPS *sps = h->ps.sps;
     int mb_xy;
     int mb_type, partition_count, cbp = 0;
-    int dct8x8_allowed= h->ps.pps->transform_8x8_mode;
-    int decode_chroma = sps->chroma_format_idc == 1 || sps->chroma_format_idc == 2;
+    int dct8x8_allowed = h->ps.pps->transform_8x8_mode;
+    const int decode_chroma = sps->chroma_format_idc == 1 || sps->chroma_format_idc == 2;
     const int pixel_shift = h->pixel_shift;
 
     mb_xy = sl->mb_xy = sl->mb_x + sl->mb_y*h->mb_stride;
diff --git a/libavcodec/h264_cavlc.c b/libavcodec/h264_cavlc.c
index f01e76070c..187b1c64e2 100644
--- a/libavcodec/h264_cavlc.c
+++ b/libavcodec/h264_cavlc.c
@@ -704,8 +704,8 @@  int ff_h264_decode_mb_cavlc(const H264Context *h, H264SliceContext *sl)
     int mb_xy;
     int partition_count;
     unsigned int mb_type, cbp;
-    int dct8x8_allowed= h->ps.pps->transform_8x8_mode;
-    int decode_chroma = h->ps.sps->chroma_format_idc == 1 || h->ps.sps->chroma_format_idc == 2;
+    int dct8x8_allowed = h->ps.pps->transform_8x8_mode;
+    const int decode_chroma = h->ps.sps->chroma_format_idc == 1 || h->ps.sps->chroma_format_idc == 2;
     const int pixel_shift = h->pixel_shift;
 
     mb_xy = sl->mb_xy = sl->mb_x + sl->mb_y*h->mb_stride;