*/
-//#define DEBUG_SVQ1
#include "avcodec.h"
#include "dsputil.h"
#include "mpegvideo.h"
#undef NDEBUG
#include <assert.h>
-extern const uint8_t mvtab[33][2];
+extern const uint8_t ff_mvtab[33][2];
static VLC svq1_block_type;
static VLC svq1_motion_component;
#define SVQ1_CALC_CODEBOOK_ENTRIES(cbook)\
codebook = (const uint32_t *) cbook[level];\
- bit_cache = get_bits (bitbuf, 4*stages);\
+ if (stages > 0)\
+ bit_cache = get_bits (bitbuf, 4*stages);\
/* calculate codebook entries for this vector */\
for (j=0; j < stages; j++) {\
entries[j] = (((bit_cache >> (4*(stages - j - 1))) & 0xF) + 16*j) << (level + 1);\
}
if ((stages > 0) && (level >= 4)) {
-#ifdef DEBUG_SVQ1
- av_log(s->avctx, AV_LOG_INFO, "Error (svq1_decode_block_intra): invalid vector: stages=%i level=%i\n",stages,level);
-#endif
+ av_dlog(NULL,
+ "Error (svq1_decode_block_intra): invalid vector: stages=%i level=%i\n",
+ stages, level);
return -1; /* invalid vector */
}
if (stages == -1) continue; /* skip vector */
if ((stages > 0) && (level >= 4)) {
-#ifdef DEBUG_SVQ1
- av_log(s->avctx, AV_LOG_INFO, "Error (svq1_decode_block_non_intra): invalid vector: stages=%i level=%i\n",stages,level);
-#endif
+ av_dlog(NULL,
+ "Error (svq1_decode_block_non_intra): invalid vector: stages=%i level=%i\n",
+ stages, level);
return -1; /* invalid vector */
}
/* add median of motion vector predictors and clip result */
if (i == 1)
- mv->y = ((diff + mid_pred(pmv[0]->y, pmv[1]->y, pmv[2]->y)) << 26) >> 26;
+ mv->y = sign_extend(diff + mid_pred(pmv[0]->y, pmv[1]->y, pmv[2]->y), 6);
else
- mv->x = ((diff + mid_pred(pmv[0]->x, pmv[1]->x, pmv[2]->x)) << 26) >> 26;
+ mv->x = sign_extend(diff + mid_pred(pmv[0]->x, pmv[1]->x, pmv[2]->x), 6);
}
return 0;
if (result != 0)
{
-#ifdef DEBUG_SVQ1
- av_log(s->avctx, AV_LOG_INFO, "Error in svq1_motion_inter_block %i\n",result);
-#endif
+ av_dlog(s->avctx, "Error in svq1_motion_inter_block %i\n", result);
break;
}
result = svq1_decode_block_non_intra (bitbuf, current, pitch);
if (result != 0)
{
-#ifdef DEBUG_SVQ1
- av_log(s->avctx, AV_LOG_INFO, "Error in svq1_motion_inter_4v_block %i\n",result);
-#endif
+ av_dlog(s->avctx, "Error in svq1_motion_inter_4v_block %i\n", result);
break;
}
result = svq1_decode_block_non_intra (bitbuf, current, pitch);
static int svq1_decode_frame_header (GetBitContext *bitbuf,MpegEncContext *s) {
int frame_size_code;
- int temporal_reference;
- temporal_reference = get_bits (bitbuf, 8);
+ skip_bits(bitbuf, 8); /* temporal_reference */
/* frame type */
s->pict_type= get_bits (bitbuf, 2)+1;
if (result != 0)
{
-#ifdef DEBUG_SVQ1
- av_log(s->avctx, AV_LOG_INFO, "Error in svq1_decode_frame_header %i\n",result);
-#endif
+ av_dlog(s->avctx, "Error in svq1_decode_frame_header %i\n",result);
return result;
}
+ avcodec_set_dimensions(avctx, s->width, s->height);
//FIXME this avoids some confusion for "B frames" without 2 references
//this should be removed after libavcodec can handle more flexible picture types & ordering
|| avctx->skip_frame >= AVDISCARD_ALL)
return buf_size;
- if(MPV_frame_start(s, avctx) < 0)
+ if(ff_MPV_frame_start(s, avctx) < 0)
return -1;
pmv = av_malloc((FFALIGN(s->width, 16)/8 + 3) * sizeof(*pmv));
linesize= s->uvlinesize;
}
- current = s->current_picture.data[i];
+ current = s->current_picture.f.data[i];
if(s->pict_type==AV_PICTURE_TYPE_B){
- previous = s->next_picture.data[i];
+ previous = s->next_picture.f.data[i];
}else{
- previous = s->last_picture.data[i];
+ previous = s->last_picture.f.data[i];
}
if (s->pict_type == AV_PICTURE_TYPE_I) {
result = svq1_decode_block_intra (&s->gb, ¤t[x], linesize);
if (result != 0)
{
-//#ifdef DEBUG_SVQ1
av_log(s->avctx, AV_LOG_INFO, "Error in svq1_decode_block %i (keyframe)\n",result);
-//#endif
goto err;
}
}
linesize, pmv, x, y);
if (result != 0)
{
-#ifdef DEBUG_SVQ1
- av_log(s->avctx, AV_LOG_INFO, "Error in svq1_decode_delta_block %i\n",result);
-#endif
+ av_dlog(s->avctx, "Error in svq1_decode_delta_block %i\n",result);
goto err;
}
}
}
}
- *pict = *(AVFrame*)&s->current_picture;
+ *pict = s->current_picture.f;
- MPV_frame_end(s);
+ ff_MPV_frame_end(s);
*data_size=sizeof(AVFrame);
result = buf_size;
int i;
int offset = 0;
- MPV_decode_defaults(s);
+ ff_MPV_decode_defaults(s);
s->avctx = avctx;
s->width = (avctx->width+3)&~3;
avctx->pix_fmt = PIX_FMT_YUV410P;
avctx->has_b_frames= 1; // not true, but DP frames and these behave like unidirectional b frames
s->flags= avctx->flags;
- if (MPV_common_init(s) < 0) return -1;
+ if (ff_MPV_common_init(s) < 0) return -1;
INIT_VLC_STATIC(&svq1_block_type, 2, 4,
&ff_svq1_block_type_vlc[0][1], 2, 1,
&ff_svq1_block_type_vlc[0][0], 2, 1, 6);
INIT_VLC_STATIC(&svq1_motion_component, 7, 33,
- &mvtab[0][1], 2, 1,
- &mvtab[0][0], 2, 1, 176);
+ &ff_mvtab[0][1], 2, 1,
+ &ff_mvtab[0][0], 2, 1, 176);
for (i = 0; i < 6; i++) {
static const uint8_t sizes[2][6] = {{14, 10, 14, 18, 16, 18}, {10, 10, 14, 14, 14, 16}};
{
MpegEncContext *s = avctx->priv_data;
- MPV_common_end(s);
+ ff_MPV_common_end(s);
return 0;
}
AVCodec ff_svq1_decoder = {
- "svq1",
- AVMEDIA_TYPE_VIDEO,
- CODEC_ID_SVQ1,
- sizeof(MpegEncContext),
- svq1_decode_init,
- NULL,
- svq1_decode_end,
- svq1_decode_frame,
- CODEC_CAP_DR1,
- .flush= ff_mpeg_flush,
- .pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV410P, PIX_FMT_NONE},
- .long_name= NULL_IF_CONFIG_SMALL("Sorenson Vector Quantizer 1 / Sorenson Video 1 / SVQ1"),
+ .name = "svq1",
+ .type = AVMEDIA_TYPE_VIDEO,
+ .id = CODEC_ID_SVQ1,
+ .priv_data_size = sizeof(MpegEncContext),
+ .init = svq1_decode_init,
+ .close = svq1_decode_end,
+ .decode = svq1_decode_frame,
+ .capabilities = CODEC_CAP_DR1,
+ .flush = ff_mpeg_flush,
+ .pix_fmts = (const enum PixelFormat[]){ PIX_FMT_YUV410P, PIX_FMT_NONE },
+ .long_name = NULL_IF_CONFIG_SMALL("Sorenson Vector Quantizer 1 / Sorenson Video 1 / SVQ1"),
};