Commit bad101ab authored by Michael Niedermayer's avatar Michael Niedermayer

Merge commit '89ef08c9'

* commit '89ef08c9':
  DNxHD: K&R formatting cosmetics

Conflicts:
	libavcodec/dnxhd_parser.c
	libavcodec/dnxhddec.c
	libavcodec/dnxhdenc.c
Merged-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parents d9fef740 89ef08c9
......@@ -46,7 +46,7 @@ static int dnxhd_find_frame_end(DNXHDParserContext *dctx,
if (!pic_found) {
for (i = 0; i < buf_size; i++) {
state = (state<<8) | buf[i];
state = (state << 8) | buf[i];
if ((state & 0xffffffffff00LL) == DNXHD_HEADER_PREFIX) {
i++;
pic_found = 1;
......@@ -61,14 +61,14 @@ static int dnxhd_find_frame_end(DNXHDParserContext *dctx,
if (!buf_size) /* EOF considered as end of frame */
return 0;
for (; i < buf_size; i++) {
state = (state<<8) | buf[i];
state = (state << 8) | buf[i];
if ((state & 0xffffffffff00LL) == DNXHD_HEADER_PREFIX) {
if (!interlaced || dctx->cur_field) {
pc->frame_start_found = 0;
pc->state64 = -1;
dctx->interlaced = interlaced;
dctx->cur_field = 0;
return i-5;
return i - 5;
} else {
/* continue, to get the second field */
dctx->interlaced = interlaced = (state&2)>>1;
......@@ -98,12 +98,12 @@ static int dnxhd_parse(AVCodecParserContext *s,
} else {
next = dnxhd_find_frame_end(dctx, buf, buf_size);
if (ff_combine_frame(pc, next, &buf, &buf_size) < 0) {
*poutbuf = NULL;
*poutbuf = NULL;
*poutbuf_size = 0;
return buf_size;
}
}
*poutbuf = buf;
*poutbuf = buf;
*poutbuf_size = buf_size;
return next;
}
......
......@@ -1067,7 +1067,7 @@ int avpriv_dnxhd_get_frame_size(int cid)
int ff_dnxhd_find_cid(AVCodecContext *avctx, int bit_depth)
{
int i, j;
int mbs = avctx->bit_rate/1000000;
int mbs = avctx->bit_rate / 1000000;
if (!mbs)
return 0;
for (i = 0; i < FF_ARRAY_ELEMS(ff_dnxhd_cid_table); i++) {
......
......@@ -57,9 +57,12 @@ typedef struct DNXHDContext {
#define DNXHD_VLC_BITS 9
#define DNXHD_DC_VLC_BITS 7
static void dnxhd_decode_dct_block_8(DNXHDContext *ctx, int16_t *block, int n, int qscale);
static void dnxhd_decode_dct_block_10(DNXHDContext *ctx, int16_t *block, int n, int qscale);
static void dnxhd_decode_dct_block_10_444(DNXHDContext *ctx, int16_t *block, int n, int qscale);
static void dnxhd_decode_dct_block_8(DNXHDContext *ctx, int16_t *block,
int n, int qscale);
static void dnxhd_decode_dct_block_10(DNXHDContext *ctx, int16_t *block,
int n, int qscale);
static void dnxhd_decode_dct_block_10_444(DNXHDContext *ctx, int16_t *block,
int n, int qscale);
static av_cold int dnxhd_decode_init(AVCodecContext *avctx)
{
......@@ -99,14 +102,16 @@ static int dnxhd_init_vlc(DNXHDContext *ctx, uint32_t cid)
ctx->cid_table->run_bits, 1, 1,
ctx->cid_table->run_codes, 2, 2, 0);
ff_init_scantable(ctx->dsp.idct_permutation, &ctx->scantable, ff_zigzag_direct);
ff_init_scantable(ctx->dsp.idct_permutation, &ctx->scantable,
ff_zigzag_direct);
ctx->cid = cid;
}
return 0;
}
static int dnxhd_decode_header(DNXHDContext *ctx, AVFrame *frame,
const uint8_t *buf, int buf_size, int first_field)
const uint8_t *buf, int buf_size,
int first_field)
{
static const uint8_t header_prefix[] = { 0x00, 0x00, 0x02, 0x80, 0x01 };
static const uint8_t header_prefix444[] = { 0x00, 0x00, 0x02, 0x80, 0x02 };
......@@ -123,7 +128,8 @@ static int dnxhd_decode_header(DNXHDContext *ctx, AVFrame *frame,
ctx->cur_field = buf[5] & 1;
frame->interlaced_frame = 1;
frame->top_field_first = first_field ^ ctx->cur_field;
av_log(ctx->avctx, AV_LOG_DEBUG, "interlaced %d, cur field %d\n", buf[5] & 3, ctx->cur_field);
av_log(ctx->avctx, AV_LOG_DEBUG,
"interlaced %d, cur field %d\n", buf[5] & 3, ctx->cur_field);
}
ctx->height = AV_RB16(buf + 0x18);
......@@ -170,22 +176,24 @@ static int dnxhd_decode_header(DNXHDContext *ctx, AVFrame *frame,
return AVERROR_INVALIDDATA;
}
ctx->mb_width = ctx->width>>4;
ctx->mb_width = ctx->width >> 4;
ctx->mb_height = buf[0x16d];
av_dlog(ctx->avctx, "mb width %d, mb height %d\n", ctx->mb_width, ctx->mb_height);
av_dlog(ctx->avctx,
"mb width %d, mb height %d\n", ctx->mb_width, ctx->mb_height);
if ((ctx->height+15)>>4 == ctx->mb_height && frame->interlaced_frame)
if ((ctx->height + 15) >> 4 == ctx->mb_height && frame->interlaced_frame)
ctx->height <<= 1;
if (ctx->mb_height > 68 ||
(ctx->mb_height << frame->interlaced_frame) > (ctx->height+15)>>4) {
av_log(ctx->avctx, AV_LOG_ERROR, "mb height too big: %d\n", ctx->mb_height);
(ctx->mb_height << frame->interlaced_frame) > (ctx->height + 15) >> 4) {
av_log(ctx->avctx, AV_LOG_ERROR,
"mb height too big: %d\n", ctx->mb_height);
return AVERROR_INVALIDDATA;
}
for (i = 0; i < ctx->mb_height; i++) {
ctx->mb_scan_index[i] = AV_RB32(buf + 0x170 + (i<<2));
ctx->mb_scan_index[i] = AV_RB32(buf + 0x170 + (i << 2));
av_dlog(ctx->avctx, "mb scan index %d\n", ctx->mb_scan_index[i]);
if (buf_size < ctx->mb_scan_index[i] + 0x280LL) {
av_log(ctx->avctx, AV_LOG_ERROR, "invalid mb scan index\n");
......@@ -213,12 +221,12 @@ static av_always_inline void dnxhd_decode_dct_block(DNXHDContext *ctx,
OPEN_READER(bs, &ctx->gb);
if (!ctx->is_444) {
if (n&2) {
component = 1 + (n&1);
if (n & 2) {
component = 1 + (n & 1);
scale = ctx->chroma_scale;
weight_matrix = ctx->cid_table->chroma_weight;
} else {
component = 0;
component = 0;
scale = ctx->luma_scale;
weight_matrix = ctx->cid_table->luma_weight;
}
......@@ -274,13 +282,13 @@ static av_always_inline void dnxhd_decode_dct_block(DNXHDContext *ctx,
break;
}
j = ctx->scantable.permutated[i];
j = ctx->scantable.permutated[i];
level *= scale[i];
if (level_bias < 32 || weight_matrix[i] != level_bias)
level += level_bias;
level >>= level_shift;
block[j] = (level^sign) - sign;
block[j] = (level ^ sign) - sign;
UPDATE_CACHE(bs, &ctx->gb);
GET_VLC(index1, bs, &ctx->gb, ctx->ac_vlc.table,
......@@ -308,7 +316,8 @@ static void dnxhd_decode_dct_block_10_444(DNXHDContext *ctx, int16_t *block,
dnxhd_decode_dct_block(ctx, block, n, qscale, 6, 32, 6);
}
static int dnxhd_decode_macroblock(DNXHDContext *ctx, AVFrame *frame, int x, int y)
static int dnxhd_decode_macroblock(DNXHDContext *ctx, AVFrame *frame,
int x, int y)
{
int shift1 = ctx->bit_depth == 10;
int dct_linesize_luma = frame->linesize[0];
......@@ -409,8 +418,8 @@ static int dnxhd_decode_macroblocks(DNXHDContext *ctx, AVFrame *frame,
return 0;
}
static int dnxhd_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
AVPacket *avpkt)
static int dnxhd_decode_frame(AVCodecContext *avctx, void *data,
int *got_frame, AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
......@@ -422,7 +431,7 @@ static int dnxhd_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
av_dlog(avctx, "frame size %d\n", buf_size);
decode_coding_unit:
decode_coding_unit:
if ((ret = dnxhd_decode_header(ctx, picture, buf, buf_size, first_field)) < 0)
return ret;
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment