Mercurial > libavcodec.hg
comparison huffyuv.c @ 2373:f977a8871c2c libavcodec
split ffhuffyuv into 2 codecs:
"huffyuv" is compatible with the official version
"ffvhuff" contains our improvements
author | lorenm |
---|---|
date | Sun, 28 Nov 2004 18:29:38 +0000 |
parents | 26560d4fdb1f |
children | b36811e1386a |
comparison
equal
deleted
inserted
replaced
2372:2d95a6cd757a | 2373:f977a8871c2c |
---|---|
493 | 493 |
494 avctx->coded_frame= &s->picture; | 494 avctx->coded_frame= &s->picture; |
495 | 495 |
496 switch(avctx->pix_fmt){ | 496 switch(avctx->pix_fmt){ |
497 case PIX_FMT_YUV420P: | 497 case PIX_FMT_YUV420P: |
498 if(avctx->strict_std_compliance>=0){ | |
499 av_log(avctx, AV_LOG_ERROR, "Warning: YV12-huffyuv is not supported by windows huffyuv use a different colorspace or use (v)strict=-1\n"); | |
500 return -1; | |
501 } | |
502 s->bitstream_bpp= 12; | 498 s->bitstream_bpp= 12; |
503 break; | 499 break; |
504 case PIX_FMT_YUV422P: | 500 case PIX_FMT_YUV422P: |
505 s->bitstream_bpp= 16; | 501 s->bitstream_bpp= 16; |
506 break; | 502 break; |
510 } | 506 } |
511 avctx->bits_per_sample= s->bitstream_bpp; | 507 avctx->bits_per_sample= s->bitstream_bpp; |
512 s->decorrelate= s->bitstream_bpp >= 24; | 508 s->decorrelate= s->bitstream_bpp >= 24; |
513 s->predictor= avctx->prediction_method; | 509 s->predictor= avctx->prediction_method; |
514 s->interlaced= avctx->flags&CODEC_FLAG_INTERLACED_ME ? 1 : 0; | 510 s->interlaced= avctx->flags&CODEC_FLAG_INTERLACED_ME ? 1 : 0; |
515 if(s->interlaced != ( height > 288 )){ | |
516 av_log(avctx, AV_LOG_INFO, "using huffyuv 2.2.0 or newer interlacing flag\n"); | |
517 } | |
518 if(avctx->context_model==1){ | 511 if(avctx->context_model==1){ |
519 s->context= avctx->context_model; | 512 s->context= avctx->context_model; |
520 if(avctx->strict_std_compliance>=0){ | |
521 av_log(avctx, AV_LOG_ERROR, "Warning: per-frame huffman tables are not supported by windows huffyuv; use context=0 or use (v)strict=-1\n"); | |
522 return -1; | |
523 } | |
524 if(s->flags & (CODEC_FLAG_PASS1|CODEC_FLAG_PASS2)){ | 513 if(s->flags & (CODEC_FLAG_PASS1|CODEC_FLAG_PASS2)){ |
525 av_log(avctx, AV_LOG_ERROR, "context=1 is not compatible with 2 pass huffyuv encoding\n"); | 514 av_log(avctx, AV_LOG_ERROR, "context=1 is not compatible with 2 pass huffyuv encoding\n"); |
526 return -1; | 515 return -1; |
527 } | 516 } |
528 av_log(avctx, AV_LOG_INFO, "using per-frame huffman tables\n"); | |
529 }else s->context= 0; | 517 }else s->context= 0; |
518 | |
519 if(avctx->codec->id==CODEC_ID_HUFFYUV){ | |
520 if(avctx->pix_fmt==PIX_FMT_YUV420P){ | |
521 av_log(avctx, AV_LOG_ERROR, "Error: YV12 is not supported by huffyuv; use vcodec=ffvhuff or format=422p\n"); | |
522 return -1; | |
523 } | |
524 if(avctx->context_model){ | |
525 av_log(avctx, AV_LOG_ERROR, "Error: per-frame huffman tables are not supported by huffyuv; use vcodec=ffvhuff\n"); | |
526 return -1; | |
527 } | |
528 if(s->interlaced != ( height > 288 )) | |
529 av_log(avctx, AV_LOG_INFO, "using huffyuv 2.2.0 or newer interlacing flag\n"); | |
530 }else if(avctx->strict_std_compliance>=0){ | |
531 av_log(avctx, AV_LOG_ERROR, "This codec is under development; files encoded with it may not be decodeable with future versions!!! Set vstrict=-1 to use it anyway.\n"); | |
532 return -1; | |
533 } | |
530 | 534 |
531 ((uint8_t*)avctx->extradata)[0]= s->predictor; | 535 ((uint8_t*)avctx->extradata)[0]= s->predictor; |
532 ((uint8_t*)avctx->extradata)[1]= s->bitstream_bpp; | 536 ((uint8_t*)avctx->extradata)[1]= s->bitstream_bpp; |
533 ((uint8_t*)avctx->extradata)[2]= 0x20 | (s->interlaced ? 0x10 : 0); | 537 ((uint8_t*)avctx->extradata)[2]= 0x20 | (s->interlaced ? 0x10 : 0); |
534 if(s->context) | 538 if(s->context) |
1170 { | 1174 { |
1171 AVOPTION_CODEC_INT("prediction_method", "prediction_method", prediction_method, 0, 2, 0), | 1175 AVOPTION_CODEC_INT("prediction_method", "prediction_method", prediction_method, 0, 2, 0), |
1172 AVOPTION_END() | 1176 AVOPTION_END() |
1173 }; | 1177 }; |
1174 | 1178 |
1179 static const AVOption ffvhuff_options[] = | |
1180 { | |
1181 AVOPTION_CODEC_INT("prediction_method", "prediction_method", prediction_method, 0, 2, 0), | |
1182 AVOPTION_CODEC_INT("context_model", "context_model", context_model, 0, 2, 0), | |
1183 AVOPTION_END() | |
1184 }; | |
1185 | |
1186 | |
1175 AVCodec huffyuv_decoder = { | 1187 AVCodec huffyuv_decoder = { |
1176 "huffyuv", | 1188 "huffyuv", |
1177 CODEC_TYPE_VIDEO, | 1189 CODEC_TYPE_VIDEO, |
1178 CODEC_ID_HUFFYUV, | 1190 CODEC_ID_HUFFYUV, |
1179 sizeof(HYuvContext), | 1191 sizeof(HYuvContext), |
1183 decode_frame, | 1195 decode_frame, |
1184 CODEC_CAP_DR1 | CODEC_CAP_DRAW_HORIZ_BAND, | 1196 CODEC_CAP_DR1 | CODEC_CAP_DRAW_HORIZ_BAND, |
1185 NULL | 1197 NULL |
1186 }; | 1198 }; |
1187 | 1199 |
1200 AVCodec ffvhuff_decoder = { | |
1201 "ffvhuff", | |
1202 CODEC_TYPE_VIDEO, | |
1203 CODEC_ID_FFVHUFF, | |
1204 sizeof(HYuvContext), | |
1205 decode_init, | |
1206 NULL, | |
1207 decode_end, | |
1208 decode_frame, | |
1209 CODEC_CAP_DR1 | CODEC_CAP_DRAW_HORIZ_BAND, | |
1210 NULL | |
1211 }; | |
1212 | |
1188 #ifdef CONFIG_ENCODERS | 1213 #ifdef CONFIG_ENCODERS |
1189 | 1214 |
1190 AVCodec huffyuv_encoder = { | 1215 AVCodec huffyuv_encoder = { |
1191 "huffyuv", | 1216 "huffyuv", |
1192 CODEC_TYPE_VIDEO, | 1217 CODEC_TYPE_VIDEO, |
1196 encode_frame, | 1221 encode_frame, |
1197 encode_end, | 1222 encode_end, |
1198 .options = huffyuv_options, | 1223 .options = huffyuv_options, |
1199 }; | 1224 }; |
1200 | 1225 |
1226 AVCodec ffvhuff_encoder = { | |
1227 "ffvhuff", | |
1228 CODEC_TYPE_VIDEO, | |
1229 CODEC_ID_FFVHUFF, | |
1230 sizeof(HYuvContext), | |
1231 encode_init, | |
1232 encode_frame, | |
1233 encode_end, | |
1234 .options = ffvhuff_options, | |
1235 }; | |
1236 | |
1201 #endif //CONFIG_ENCODERS | 1237 #endif //CONFIG_ENCODERS |