comparison dnxhdenc.c @ 5971:405be936dac4 libavcodec

dnxhd 720p encoding and decoding support
author bcoudurier
date Sun, 02 Dec 2007 19:27:19 +0000
parents e1ac22f75cf6
children f855600f6f0f
comparison
equal deleted inserted replaced
5970:e1ac22f75cf6 5971:405be936dac4
169 static int dnxhd_encode_init(AVCodecContext *avctx) 169 static int dnxhd_encode_init(AVCodecContext *avctx)
170 { 170 {
171 DNXHDEncContext *ctx = avctx->priv_data; 171 DNXHDEncContext *ctx = avctx->priv_data;
172 int i, index; 172 int i, index;
173 173
174 if (avctx->width == 1920 && avctx->height == 1080) {
174 if (avctx->flags & CODEC_FLAG_INTERLACED_DCT) { 175 if (avctx->flags & CODEC_FLAG_INTERLACED_DCT) {
175 if (avctx->bit_rate == 120000000) 176 if (avctx->bit_rate == 120000000)
176 ctx->cid = 1242; 177 ctx->cid = 1242;
177 else if (avctx->bit_rate == 185000000) 178 else if (avctx->bit_rate == 185000000)
178 ctx->cid = 1243; 179 ctx->cid = 1243;
182 else if (avctx->bit_rate == 185000000) 183 else if (avctx->bit_rate == 185000000)
183 ctx->cid = 1238; 184 ctx->cid = 1238;
184 else if (avctx->bit_rate == 36000000) 185 else if (avctx->bit_rate == 36000000)
185 ctx->cid = 1253; 186 ctx->cid = 1253;
186 } 187 }
187 if (!ctx->cid || avctx->width != 1920 || avctx->height != 1080 || avctx->pix_fmt != PIX_FMT_YUV422P) { 188 } else if (avctx->width == 1280 && avctx->height == 720 &&
189 !(avctx->flags & CODEC_FLAG_INTERLACED_DCT)) {
190 if (avctx->bit_rate == 90000000)
191 ctx->cid = 1251;
192 else if (avctx->bit_rate == 60000000)
193 ctx->cid = 1252;
194 }
195 if (!ctx->cid || avctx->pix_fmt != PIX_FMT_YUV422P) {
188 av_log(avctx, AV_LOG_ERROR, "video parameters incompatible with DNxHD\n"); 196 av_log(avctx, AV_LOG_ERROR, "video parameters incompatible with DNxHD\n");
189 return -1; 197 return -1;
190 } 198 }
191 199
192 index = ff_dnxhd_get_cid_table(ctx->cid); 200 index = ff_dnxhd_get_cid_table(ctx->cid);
419 dsp->get_pixels(ctx->blocks[0], ptr_y , ctx->m.linesize); 427 dsp->get_pixels(ctx->blocks[0], ptr_y , ctx->m.linesize);
420 dsp->get_pixels(ctx->blocks[1], ptr_y + 8, ctx->m.linesize); 428 dsp->get_pixels(ctx->blocks[1], ptr_y + 8, ctx->m.linesize);
421 dsp->get_pixels(ctx->blocks[2], ptr_u , ctx->m.uvlinesize); 429 dsp->get_pixels(ctx->blocks[2], ptr_u , ctx->m.uvlinesize);
422 dsp->get_pixels(ctx->blocks[3], ptr_v , ctx->m.uvlinesize); 430 dsp->get_pixels(ctx->blocks[3], ptr_v , ctx->m.uvlinesize);
423 431
424 if (mb_y+1 == ctx->m.mb_height) { 432 if (mb_y+1 == ctx->m.mb_height && ctx->m.avctx->height == 1080) {
425 if (ctx->interlaced) { 433 if (ctx->interlaced) {
426 dnxhd_get_pixels_4x8(ctx->blocks[4], ptr_y + ctx->dct_y_offset , ctx->m.linesize); 434 dnxhd_get_pixels_4x8(ctx->blocks[4], ptr_y + ctx->dct_y_offset , ctx->m.linesize);
427 dnxhd_get_pixels_4x8(ctx->blocks[5], ptr_y + ctx->dct_y_offset + 8, ctx->m.linesize); 435 dnxhd_get_pixels_4x8(ctx->blocks[5], ptr_y + ctx->dct_y_offset + 8, ctx->m.linesize);
428 dnxhd_get_pixels_4x8(ctx->blocks[6], ptr_u + ctx->dct_uv_offset , ctx->m.uvlinesize); 436 dnxhd_get_pixels_4x8(ctx->blocks[6], ptr_u + ctx->dct_uv_offset , ctx->m.uvlinesize);
429 dnxhd_get_pixels_4x8(ctx->blocks[7], ptr_v + ctx->dct_uv_offset , ctx->m.uvlinesize); 437 dnxhd_get_pixels_4x8(ctx->blocks[7], ptr_v + ctx->dct_uv_offset , ctx->m.uvlinesize);