summaryrefslogtreecommitdiff
path: root/libavcodec/dnxhdenc.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2011-07-21 16:27:55 +0200
committerMichael Niedermayer <michaelni@gmx.at>2011-07-21 16:28:53 +0200
commitf93f6963babf08a7bcf85b9a57f37266dc0a4ae0 (patch)
treed9729ad7db8cb9f9a6a5483ac960ef7a56310072 /libavcodec/dnxhdenc.c
parent8c2863b87f651bfce061d5b0e03cd756b049a553 (diff)
parente5985185d2eda942333ebbb72bd7d043ffe40be7 (diff)
Merge remote-tracking branch 'qatar/master'
* qatar/master: rv30: return AVERROR(EINVAL) instead of EINVAL build: add -L flags before existing LDFLAGS simple_idct: whitespace cosmetics simple_idct: make repeated code a macro dsputil: remove huge #if 0 block simple_idct: change 10-bit add/put stride from pixels to bytes dsputil: allow 9/10-bit functions for non-h264 codecs dnxhd: rename some data tables dnxhdenc: remove inline from function only called through pointer dnxhdenc: whitespace cosmetics swscale: mark YUV422P10(LE,BE) as supported for output configure: add -xc99 to LDFLAGS for Sun CC Remove unused and non-compiling vestigial g729 decoder Remove unused code under G729_BITEXACT #ifdef. mpegvideo: fix invalid picture unreferencing. dsputil: Remove extra blank line at end. dsputil: Replace a LONG_MAX check with HAVE_FAST_64BIT. simple_idct: add 10-bit version Conflicts: Makefile libavcodec/g729data.h libavcodec/g729dec.c libavcodec/rv30.c tests/ref/lavfi/pixdesc tests/ref/lavfi/pixfmts_copy tests/ref/lavfi/pixfmts_null tests/ref/lavfi/pixfmts_scale tests/ref/lavfi/pixfmts_vflip Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/dnxhdenc.c')
-rw-r--r--libavcodec/dnxhdenc.c64
1 files changed, 33 insertions, 31 deletions
diff --git a/libavcodec/dnxhdenc.c b/libavcodec/dnxhdenc.c
index 8b63bbb19b..57ae8e205b 100644
--- a/libavcodec/dnxhdenc.c
+++ b/libavcodec/dnxhdenc.c
@@ -41,7 +41,7 @@ static const AVClass class = { "dnxhd", av_default_item_name, options, LIBAVUTIL
#define LAMBDA_FRAC_BITS 10
-static av_always_inline void dnxhd_get_pixels_8x4(DCTELEM *restrict block, const uint8_t *pixels, int line_size)
+static void dnxhd_get_pixels_8x4(DCTELEM *restrict block, const uint8_t *pixels, int line_size)
{
int i;
for (i = 0; i < 4; i++) {
@@ -52,10 +52,10 @@ static av_always_inline void dnxhd_get_pixels_8x4(DCTELEM *restrict block, const
pixels += line_size;
block += 8;
}
- memcpy(block , block- 8, sizeof(*block)*8);
- memcpy(block+ 8, block-16, sizeof(*block)*8);
- memcpy(block+16, block-24, sizeof(*block)*8);
- memcpy(block+24, block-32, sizeof(*block)*8);
+ memcpy(block, block - 8, sizeof(*block) * 8);
+ memcpy(block + 8, block - 16, sizeof(*block) * 8);
+ memcpy(block + 16, block - 24, sizeof(*block) * 8);
+ memcpy(block + 24, block - 32, sizeof(*block) * 8);
}
static int dnxhd_init_vlc(DNXHDEncContext *ctx)
@@ -64,9 +64,9 @@ static int dnxhd_init_vlc(DNXHDEncContext *ctx)
int max_level = 1<<(ctx->cid_table->bit_depth+2);
FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->vlc_codes, max_level*4*sizeof(*ctx->vlc_codes), fail);
- FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->vlc_bits , max_level*4*sizeof(*ctx->vlc_bits ), fail);
- FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->run_codes, 63*2 , fail);
- FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->run_bits , 63 , fail);
+ FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->vlc_bits, max_level*4*sizeof(*ctx->vlc_bits) , fail);
+ FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->run_codes, 63*2, fail);
+ FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->run_bits, 63, fail);
ctx->vlc_codes += max_level*2;
ctx->vlc_bits += max_level*2;
@@ -119,8 +119,8 @@ static int dnxhd_init_qmat(DNXHDEncContext *ctx, int lbias, int cbias)
uint16_t weight_matrix[64] = {1,}; // convert_matrix needs uint16_t*
int qscale, i;
- FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->qmatrix_l, (ctx->m.avctx->qmax+1) * 64 * sizeof(int) , fail);
- FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->qmatrix_c, (ctx->m.avctx->qmax+1) * 64 * sizeof(int) , fail);
+ FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->qmatrix_l, (ctx->m.avctx->qmax+1) * 64 * sizeof(int), fail);
+ FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->qmatrix_c, (ctx->m.avctx->qmax+1) * 64 * sizeof(int), fail);
FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->qmatrix_l16, (ctx->m.avctx->qmax+1) * 64 * 2 * sizeof(uint16_t), fail);
FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->qmatrix_c16, (ctx->m.avctx->qmax+1) * 64 * 2 * sizeof(uint16_t), fail);
@@ -218,7 +218,7 @@ static int dnxhd_encode_init(AVCodecContext *avctx)
FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->slice_size, ctx->m.mb_height*sizeof(uint32_t), fail);
FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->slice_offs, ctx->m.mb_height*sizeof(uint32_t), fail);
FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->mb_bits, ctx->m.mb_num *sizeof(uint16_t), fail);
- FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->mb_qscale, ctx->m.mb_num *sizeof(uint8_t) , fail);
+ FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->mb_qscale, ctx->m.mb_num *sizeof(uint8_t), fail);
ctx->frame.key_frame = 1;
ctx->frame.pict_type = AV_PICTURE_TYPE_I;
@@ -341,7 +341,7 @@ static av_always_inline int dnxhd_ssd_block(DCTELEM *qblock, DCTELEM *block)
int score = 0;
int i;
for (i = 0; i < 64; i++)
- score += (block[i]-qblock[i])*(block[i]-qblock[i]);
+ score += (block[i] - qblock[i]) * (block[i] - qblock[i]);
return score;
}
@@ -369,26 +369,28 @@ static av_always_inline void dnxhd_get_blocks(DNXHDEncContext *ctx, int mb_x, in
const uint8_t *ptr_v = ctx->thread[0]->src[2] + ((mb_y << 4) * ctx->m.uvlinesize) + (mb_x << 3);
DSPContext *dsp = &ctx->m.dsp;
- dsp->get_pixels(ctx->blocks[0], ptr_y , ctx->m.linesize);
+ dsp->get_pixels(ctx->blocks[0], ptr_y, ctx->m.linesize);
dsp->get_pixels(ctx->blocks[1], ptr_y + 8, ctx->m.linesize);
- dsp->get_pixels(ctx->blocks[2], ptr_u , ctx->m.uvlinesize);
- dsp->get_pixels(ctx->blocks[3], ptr_v , ctx->m.uvlinesize);
+ dsp->get_pixels(ctx->blocks[2], ptr_u, ctx->m.uvlinesize);
+ dsp->get_pixels(ctx->blocks[3], ptr_v, ctx->m.uvlinesize);
if (mb_y+1 == ctx->m.mb_height && ctx->m.avctx->height == 1080) {
if (ctx->interlaced) {
- ctx->get_pixels_8x4_sym(ctx->blocks[4], ptr_y + ctx->dct_y_offset , ctx->m.linesize);
+ ctx->get_pixels_8x4_sym(ctx->blocks[4], ptr_y + ctx->dct_y_offset, ctx->m.linesize);
ctx->get_pixels_8x4_sym(ctx->blocks[5], ptr_y + ctx->dct_y_offset + 8, ctx->m.linesize);
- ctx->get_pixels_8x4_sym(ctx->blocks[6], ptr_u + ctx->dct_uv_offset , ctx->m.uvlinesize);
- ctx->get_pixels_8x4_sym(ctx->blocks[7], ptr_v + ctx->dct_uv_offset , ctx->m.uvlinesize);
+ ctx->get_pixels_8x4_sym(ctx->blocks[6], ptr_u + ctx->dct_uv_offset, ctx->m.uvlinesize);
+ ctx->get_pixels_8x4_sym(ctx->blocks[7], ptr_v + ctx->dct_uv_offset, ctx->m.uvlinesize);
} else {
- dsp->clear_block(ctx->blocks[4]); dsp->clear_block(ctx->blocks[5]);
- dsp->clear_block(ctx->blocks[6]); dsp->clear_block(ctx->blocks[7]);
+ dsp->clear_block(ctx->blocks[4]);
+ dsp->clear_block(ctx->blocks[5]);
+ dsp->clear_block(ctx->blocks[6]);
+ dsp->clear_block(ctx->blocks[7]);
}
} else {
- dsp->get_pixels(ctx->blocks[4], ptr_y + ctx->dct_y_offset , ctx->m.linesize);
+ dsp->get_pixels(ctx->blocks[4], ptr_y + ctx->dct_y_offset, ctx->m.linesize);
dsp->get_pixels(ctx->blocks[5], ptr_y + ctx->dct_y_offset + 8, ctx->m.linesize);
- dsp->get_pixels(ctx->blocks[6], ptr_u + ctx->dct_uv_offset , ctx->m.uvlinesize);
- dsp->get_pixels(ctx->blocks[7], ptr_v + ctx->dct_uv_offset , ctx->m.uvlinesize);
+ dsp->get_pixels(ctx->blocks[6], ptr_u + ctx->dct_uv_offset, ctx->m.uvlinesize);
+ dsp->get_pixels(ctx->blocks[7], ptr_v + ctx->dct_uv_offset, ctx->m.uvlinesize);
}
}
@@ -496,14 +498,14 @@ static void dnxhd_setup_threads_slices(DNXHDEncContext *ctx)
for (mb_y = 0; mb_y < ctx->m.mb_height; mb_y++) {
int thread_size;
ctx->slice_offs[mb_y] = offset;
- ctx->slice_size[mb_y] = 0;
- for (mb_x = 0; mb_x < ctx->m.mb_width; mb_x++) {
- unsigned mb = mb_y * ctx->m.mb_width + mb_x;
- ctx->slice_size[mb_y] += ctx->mb_bits[mb];
- }
- ctx->slice_size[mb_y] = (ctx->slice_size[mb_y]+31)&~31;
- ctx->slice_size[mb_y] >>= 3;
- thread_size = ctx->slice_size[mb_y];
+ ctx->slice_size[mb_y] = 0;
+ for (mb_x = 0; mb_x < ctx->m.mb_width; mb_x++) {
+ unsigned mb = mb_y * ctx->m.mb_width + mb_x;
+ ctx->slice_size[mb_y] += ctx->mb_bits[mb];
+ }
+ ctx->slice_size[mb_y] = (ctx->slice_size[mb_y]+31)&~31;
+ ctx->slice_size[mb_y] >>= 3;
+ thread_size = ctx->slice_size[mb_y];
offset += thread_size;
}
}