[FFmpeg-devel] [PATCH 5/5] dnxhddec: replace some 0s by DNXHD_VARIABLE
Christophe Gisquet
christophe.gisquet at gmail.com
Fri Oct 2 21:00:46 CEST 2015
A series of 0 in a table can be confusing, and the corresponding checks
strange, so using a macro instead of that magic is more readable.
---
libavcodec/dnxhddata.c | 10 +++++-----
libavcodec/dnxhddata.h | 3 +++
libavcodec/dnxhddec.c | 6 ++++--
3 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/libavcodec/dnxhddata.c b/libavcodec/dnxhddata.c
index 32e10ab..b97b19f 100644
--- a/libavcodec/dnxhddata.c
+++ b/libavcodec/dnxhddata.c
@@ -1064,35 +1064,35 @@ const CIDEntry ff_dnxhd_cid_table[] = {
dnxhd_1237_ac_flags,
dnxhd_1237_run_codes, dnxhd_1237_run_bits, dnxhd_1237_run,
{ 80, 90, 100, 110 } },
- { 1270, 0, 0, 0, 0, 0, 6, 0, 4,
+ { 1270, DNXHD_VARIABLE, DNXHD_VARIABLE, 0, DNXHD_VARIABLE, DNXHD_VARIABLE, 6, DNXHD_VARIABLE, 4,
dnxhd_1235_luma_weight, dnxhd_1235_luma_weight,
dnxhd_1235_dc_codes, dnxhd_1235_dc_bits,
dnxhd_1235_ac_codes, dnxhd_1235_ac_bits, dnxhd_1235_ac_level,
dnxhd_1235_ac_flags,
dnxhd_1235_run_codes, dnxhd_1235_run_bits, dnxhd_1235_run,
{ 0 } },
- { 1271, 0, 0, 0, 0, 0, 6, 0, 4,
+ { 1271, DNXHD_VARIABLE, DNXHD_VARIABLE, 0, DNXHD_VARIABLE, DNXHD_VARIABLE, 6, DNXHD_VARIABLE, 4,
dnxhd_1241_luma_weight, dnxhd_1241_chroma_weight,
dnxhd_1235_dc_codes, dnxhd_1235_dc_bits,
dnxhd_1235_ac_codes, dnxhd_1235_ac_bits, dnxhd_1235_ac_level,
dnxhd_1235_ac_flags,
dnxhd_1235_run_codes, dnxhd_1235_run_bits, dnxhd_1235_run,
{ 0 } },
- { 1272, 0, 0, 0, 0, 0, 4, 8, 4,
+ { 1272, DNXHD_VARIABLE, DNXHD_VARIABLE, 0, DNXHD_VARIABLE, DNXHD_VARIABLE, 4, 8, 4,
dnxhd_1238_luma_weight, dnxhd_1238_chroma_weight,
dnxhd_1237_dc_codes, dnxhd_1237_dc_bits,
dnxhd_1238_ac_codes, dnxhd_1238_ac_bits, dnxhd_1238_ac_level,
dnxhd_1238_ac_flags,
dnxhd_1235_run_codes, dnxhd_1235_run_bits, dnxhd_1238_run,
{ 0 } },
- { 1273, 0, 0, 0, 0, 0, 4, 8, 3,
+ { 1273, DNXHD_VARIABLE, DNXHD_VARIABLE, 0, DNXHD_VARIABLE, DNXHD_VARIABLE, 4, 8, 3,
dnxhd_1237_luma_weight, dnxhd_1237_chroma_weight,
dnxhd_1237_dc_codes, dnxhd_1237_dc_bits,
dnxhd_1237_ac_codes, dnxhd_1237_ac_bits, dnxhd_1237_ac_level,
dnxhd_1237_ac_flags,
dnxhd_1237_run_codes, dnxhd_1237_run_bits, dnxhd_1237_run,
{ 0 } },
- { 1274, 0, 0, 0, 0, 0, 4, 8, 3,
+ { 1274, DNXHD_VARIABLE, DNXHD_VARIABLE, 0, DNXHD_VARIABLE, DNXHD_VARIABLE, 4, 8, 3,
dnxhd_1237_luma_weight, dnxhd_1237_chroma_weight,
dnxhd_1237_dc_codes, dnxhd_1237_dc_bits,
dnxhd_1237_ac_codes, dnxhd_1237_ac_bits, dnxhd_1237_ac_level,
diff --git a/libavcodec/dnxhddata.h b/libavcodec/dnxhddata.h
index 8cc27e8..62926ce 100644
--- a/libavcodec/dnxhddata.h
+++ b/libavcodec/dnxhddata.h
@@ -26,6 +26,9 @@
#include "avcodec.h"
#include "libavutil/internal.h"
+/** Indicate that a CIDEntry value must be read in the bitstream */
+#define DNXHD_VARIABLE 0
+
typedef struct CIDEntry {
int cid;
unsigned int width, height;
diff --git a/libavcodec/dnxhddec.c b/libavcodec/dnxhddec.c
index 8cd4db9..9bbbd84 100644
--- a/libavcodec/dnxhddec.c
+++ b/libavcodec/dnxhddec.c
@@ -111,7 +111,8 @@ static int dnxhd_init_vlc(DNXHDContext *ctx, uint32_t cid)
av_log(ctx->avctx, AV_LOG_ERROR, "unsupported cid %d\n", cid);
return AVERROR(ENOSYS);
}
- if (ff_dnxhd_cid_table[index].bit_depth != ctx->bit_depth && ff_dnxhd_cid_table[index].bit_depth != 0) {
+ if (ff_dnxhd_cid_table[index].bit_depth != ctx->bit_depth &&
+ ff_dnxhd_cid_table[index].bit_depth != DNXHD_VARIABLE) {
av_log(ctx->avctx, AV_LOG_ERROR, "bit depth mismatches %d %d\n", ff_dnxhd_cid_table[index].bit_depth, ctx->bit_depth);
return AVERROR_INVALIDDATA;
}
@@ -245,7 +246,8 @@ static int dnxhd_decode_header(DNXHDContext *ctx, AVFrame *frame,
// make sure profile size constraints are respected
// DNx100 allows 1920->1440 and 1280->960 subsampling
- if (ctx->width != ctx->cid_table->width && ctx->cid_table->width != 0) {
+ if (ctx->width != ctx->cid_table->width &&
+ ctx->cid_table->width != DNXHD_VARIABLE) {
av_reduce(&ctx->avctx->sample_aspect_ratio.num,
&ctx->avctx->sample_aspect_ratio.den,
ctx->width, ctx->cid_table->width, 255);
--
2.5.2
More information about the ffmpeg-devel
mailing list