diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2013-08-29 22:06:07 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2013-08-29 22:52:04 +0200 |
commit | c4224fff1b0ac3fb67daf5e36184afa609ce8f90 (patch) | |
tree | 4e65b0160b6cff79e56dccb8549d56f2ebbfd776 /libavcodec/snowdec.c | |
parent | ec120efaa90ac2232749b03e65900fdbabb77475 (diff) | |
download | ffmpeg-c4224fff1b0ac3fb67daf5e36184afa609ce8f90.tar.gz |
avcodec/snow: gray support
Fixes Ticket839
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/snowdec.c')
-rw-r--r-- | libavcodec/snowdec.c | 46 |
1 files changed, 30 insertions, 16 deletions
diff --git a/libavcodec/snowdec.c b/libavcodec/snowdec.c index 8da2f17ffb..8bd4dc19c9 100644 --- a/libavcodec/snowdec.c +++ b/libavcodec/snowdec.c @@ -163,8 +163,10 @@ static int decode_q_branch(SnowContext *s, int level, int x, int y){ if(type){ pred_mv(s, &mx, &my, 0, left, top, tr); l += get_symbol(&s->c, &s->block_state[32], 1); - cb+= get_symbol(&s->c, &s->block_state[64], 1); - cr+= get_symbol(&s->c, &s->block_state[96], 1); + if (s->nb_planes > 2) { + cb+= get_symbol(&s->c, &s->block_state[64], 1); + cr+= get_symbol(&s->c, &s->block_state[96], 1); + } }else{ if(s->ref_frames > 1) ref= get_symbol(&s->c, &s->block_state[128 + 1024 + 32*ref_context], 0); @@ -243,7 +245,7 @@ static void correlate_slice_buffered(SnowContext *s, slice_buffer * sb, SubBand static void decode_qlogs(SnowContext *s){ int plane_index, level, orientation; - for(plane_index=0; plane_index<3; plane_index++){ + for(plane_index=0; plane_index < s->nb_planes; plane_index++){ for(level=0; level<s->spatial_decomposition_count; level++){ for(orientation=level ? 1:0; orientation<4; orientation++){ int q; @@ -286,22 +288,34 @@ static int decode_header(SnowContext *s){ s->temporal_decomposition_count= get_symbol(&s->c, s->header_state, 0); GET_S(s->spatial_decomposition_count, 0 < tmp && tmp <= MAX_DECOMPOSITIONS) s->colorspace_type= get_symbol(&s->c, s->header_state, 0); - s->chroma_h_shift= get_symbol(&s->c, s->header_state, 0); - s->chroma_v_shift= get_symbol(&s->c, s->header_state, 0); - - if(s->chroma_h_shift == 1 && s->chroma_v_shift==1){ - s->avctx->pix_fmt= AV_PIX_FMT_YUV420P; - }else if(s->chroma_h_shift == 0 && s->chroma_v_shift==0){ - s->avctx->pix_fmt= AV_PIX_FMT_YUV444P; - }else if(s->chroma_h_shift == 2 && s->chroma_v_shift==2){ - s->avctx->pix_fmt= AV_PIX_FMT_YUV410P; + if (s->colorspace_type == 1) { + s->avctx->pix_fmt= AV_PIX_FMT_GRAY8; + s->nb_planes = 1; + } else if(s->colorspace_type == 0) { + s->chroma_h_shift= get_symbol(&s->c, s->header_state, 0); + s->chroma_v_shift= get_symbol(&s->c, s->header_state, 0); + + if(s->chroma_h_shift == 1 && s->chroma_v_shift==1){ + s->avctx->pix_fmt= AV_PIX_FMT_YUV420P; + }else if(s->chroma_h_shift == 0 && s->chroma_v_shift==0){ + s->avctx->pix_fmt= AV_PIX_FMT_YUV444P; + }else if(s->chroma_h_shift == 2 && s->chroma_v_shift==2){ + s->avctx->pix_fmt= AV_PIX_FMT_YUV410P; + } else { + av_log(s, AV_LOG_ERROR, "unsupported color subsample mode %d %d\n", s->chroma_h_shift, s->chroma_v_shift); + s->chroma_h_shift = s->chroma_v_shift = 1; + s->avctx->pix_fmt= AV_PIX_FMT_YUV420P; + return AVERROR_INVALIDDATA; + } + s->nb_planes = 3; } else { - av_log(s, AV_LOG_ERROR, "unsupported color subsample mode %d %d\n", s->chroma_h_shift, s->chroma_v_shift); + av_log(s, AV_LOG_ERROR, "unsupported color space\n"); s->chroma_h_shift = s->chroma_v_shift = 1; s->avctx->pix_fmt= AV_PIX_FMT_YUV420P; return AVERROR_INVALIDDATA; } + s->spatial_scalability= get_rac(&s->c, s->header_state); // s->rate_scalability= get_rac(&s->c, s->header_state); GET_S(s->max_ref_frames, tmp < (unsigned)MAX_REF_FRAMES) @@ -312,7 +326,7 @@ static int decode_header(SnowContext *s){ if(!s->keyframe){ if(get_rac(&s->c, s->header_state)){ - for(plane_index=0; plane_index<2; plane_index++){ + for(plane_index=0; plane_index<FFMIN(s->nb_planes, 2); plane_index++){ int htaps, i, sum=0; Plane *p= &s->plane[plane_index]; p->diag_mc= get_rac(&s->c, s->header_state); @@ -418,7 +432,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, s->spatial_idwt_buffer)) < 0) return res; - for(plane_index=0; plane_index<3; plane_index++){ + for(plane_index=0; plane_index < s->nb_planes; plane_index++){ Plane *p= &s->plane[plane_index]; p->fast_mc= p->diag_mc && p->htaps==6 && p->hcoeff[0]==40 && p->hcoeff[1]==-10 @@ -436,7 +450,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, if ((res = decode_blocks(s)) < 0) return res; - for(plane_index=0; plane_index<3; plane_index++){ + for(plane_index=0; plane_index < s->nb_planes; plane_index++){ Plane *p= &s->plane[plane_index]; int w= p->width; int h= p->height; |