[FFmpeg-devel] [RFC] ffv1: 16bit gray support
Paul B Mahol
onemda at gmail.com
Sat Feb 4 02:35:14 CET 2012
Signed-off-by: Paul B Mahol <onemda at gmail.com>
---
libavcodec/ffv1.c | 26 +++++++++++++++++++++++---
1 files changed, 23 insertions(+), 3 deletions(-)
diff --git a/libavcodec/ffv1.c b/libavcodec/ffv1.c
index 667b8ea..3cf218a 100644
--- a/libavcodec/ffv1.c
+++ b/libavcodec/ffv1.c
@@ -912,6 +912,18 @@ static av_cold int encode_init(AVCodecContext *avctx)
avctx->coded_frame= &s->picture;
switch(avctx->pix_fmt){
+ case PIX_FMT_GRAY16:
+ if(avctx->bits_per_raw_sample <=8){
+ av_log(avctx, AV_LOG_ERROR, "bits_per_raw_sample invalid\n");
+ return -1;
+ }
+ if(!s->ac){
+ av_log(avctx, AV_LOG_ERROR, "bits_per_raw_sample of more than 8 needs -coder 1 currently\n");
+ return -1;
+ }
+ s->colorspace= 2;
+ s->version= FFMAX(s->version, 1);
+ break;
case PIX_FMT_YUV420P9:
case PIX_FMT_YUV420P10:
case PIX_FMT_YUV422P10:
@@ -1105,8 +1117,10 @@ static int encode_slice(AVCodecContext *c, void *arg){
encode_plane(fs, p->data[2] + ps*cx+cy*p->linesize[2], chroma_width, chroma_height, p->linesize[2], 1);
if (fs->transparency)
encode_plane(fs, p->data[3] + ps*x + y*p->linesize[3], width, height, p->linesize[3], 2);
- }else{
+ }else if(f->colorspace==1){
encode_rgb_frame(fs, (uint32_t*)(p->data[0]) + ps*x + y*(p->linesize[0]/4), width, height, p->linesize[0]/4);
+ }else{
+ encode_plane(fs, p->data[0] + ps*x + y*p->linesize[0], width, height, p->linesize[0], 0);
}
emms_c();
@@ -1439,8 +1453,10 @@ static int decode_slice(AVCodecContext *c, void *arg){
decode_plane(fs, p->data[2] + ps*cx+cy*p->linesize[2], chroma_width, chroma_height, p->linesize[2], 1);
if (fs->transparency)
decode_plane(fs, p->data[3] + ps*x + y*p->linesize[3], width, height, p->linesize[3], 2);
- }else{
+ }else if (f->colorspace==1){
decode_rgb_frame(fs, (uint32_t*)p->data[0] + ps*x + y*(p->linesize[0]/4), width, height, p->linesize[0]/4);
+ }else{
+ decode_plane(fs, p->data[0] + ps*x + y*p->linesize[0], width, height, p->linesize[0], 0);
}
emms_c();
@@ -1630,6 +1646,10 @@ static int read_header(FFV1Context *f){
}
if(f->transparency) f->avctx->pix_fmt= PIX_FMT_RGB32;
else f->avctx->pix_fmt= PIX_FMT_0RGB32;
+ }else if(f->colorspace==2){
+ if(f->avctx->bits_per_raw_sample>8 && !f->transparency){
+ f->avctx->pix_fmt= PIX_FMT_GRAY16;
+ }
}else{
av_log(f->avctx, AV_LOG_ERROR, "colorspace not supported\n");
return -1;
@@ -1817,7 +1837,7 @@ AVCodec ff_ffv1_encoder = {
.encode = encode_frame,
.close = common_end,
.capabilities = CODEC_CAP_SLICE_THREADS,
- .pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_YUVA420P, PIX_FMT_YUV444P, PIX_FMT_YUVA444P, PIX_FMT_YUV440P, PIX_FMT_YUV422P, PIX_FMT_YUV411P, PIX_FMT_YUV410P, PIX_FMT_0RGB32, PIX_FMT_RGB32, PIX_FMT_YUV420P16, PIX_FMT_YUV422P16, PIX_FMT_YUV444P16, PIX_FMT_YUV420P9, PIX_FMT_YUV420P10, PIX_FMT_YUV422P10, PIX_FMT_NONE},
+ .pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_YUVA420P, PIX_FMT_YUV444P, PIX_FMT_YUVA444P, PIX_FMT_YUV440P, PIX_FMT_YUV422P, PIX_FMT_YUV411P, PIX_FMT_YUV410P, PIX_FMT_0RGB32, PIX_FMT_RGB32, PIX_FMT_YUV420P16, PIX_FMT_YUV422P16, PIX_FMT_YUV444P16, PIX_FMT_YUV420P9, PIX_FMT_YUV420P10, PIX_FMT_YUV422P10, PIX_FMT_GRAY16, PIX_FMT_NONE},
.long_name= NULL_IF_CONFIG_SMALL("FFmpeg video codec #1"),
};
#endif
--
1.7.7
More information about the ffmpeg-devel
mailing list