/*
- * Copyright (c) 2002 The FFmpeg Project.
+ * Copyright (c) 2002 The Libav Project
*
- * This file is part of FFmpeg.
+ * This file is part of Libav.
*
- * FFmpeg is free software; you can redistribute it and/or
+ * Libav is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
- * FFmpeg is distributed in the hope that it will be useful,
+ * Libav is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
+ * License along with Libav; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "avcodec.h"
#include "dsputil.h"
#include "mpegvideo.h"
+#include "h263.h"
+#include "mathops.h"
#include "msmpeg4.h"
#include "msmpeg4data.h"
#include "intrax8.h"
static void parse_mb_skip(Wmv2Context * w){
int mb_x, mb_y;
MpegEncContext * const s= &w->s;
- uint32_t * const mb_type= s->current_picture_ptr->mb_type;
+ uint32_t * const mb_type = s->current_picture_ptr->f.mb_type;
w->skip_type= get_bits(&s->gb, 2);
switch(w->skip_type){
if(s->avctx->extradata_size<4) return -1;
- init_get_bits(&gb, s->avctx->extradata, s->avctx->extradata_size*8);
+ init_get_bits(&gb, s->avctx->extradata, 32);
fps = get_bits(&gb, 5);
s->bit_rate = get_bits(&gb, 11)*1024;
Wmv2Context * const w= (Wmv2Context*)s;
int code;
-#if 0
-{
-int i;
-for(i=0; i<s->gb.size*8; i++)
- printf("%d", get_bits1(&s->gb));
-// get_bits1(&s->gb);
-printf("END\n");
-return -1;
-}
-#endif
if(s->picture_number==0)
decode_ext_header(w);
s->pict_type = get_bits1(&s->gb) + 1;
- if(s->pict_type == I_TYPE){
+ if(s->pict_type == AV_PICTURE_TYPE_I){
code = get_bits(&s->gb, 7);
av_log(s->avctx, AV_LOG_DEBUG, "I7:%X/\n", code);
}
{
Wmv2Context * const w= (Wmv2Context*)s;
- if (s->pict_type == I_TYPE) {
+ if (s->pict_type == AV_PICTURE_TYPE_I) {
if(w->j_type_bit) w->j_type= get_bits1(&s->gb);
else w->j_type= 0; //FIXME check
else
w->hshift= 0;
-//printf("%d %d ", *mx_ptr, *my_ptr);
-
return 0;
}
wrap = s->b8_stride;
xy = s->block_index[0];
- mot_val = s->current_picture.motion_val[0][xy];
+ mot_val = s->current_picture.f.motion_val[0][xy];
- A = s->current_picture.motion_val[0][xy - 1];
- B = s->current_picture.motion_val[0][xy - wrap];
- C = s->current_picture.motion_val[0][xy + 2 - wrap];
+ A = s->current_picture.f.motion_val[0][xy - 1];
+ B = s->current_picture.f.motion_val[0][xy - wrap];
+ C = s->current_picture.f.motion_val[0][xy + 2 - wrap];
if(s->mb_x && !s->first_slice_line && !s->mspel && w->top_left_mv_flag)
diff= FFMAX(FFABS(A[0] - B[0]), FFABS(A[1] - B[1]));
if(w->per_block_abt)
w->abt_type= decode012(&s->gb);
-#if 0
- if(w->per_block_abt)
- printf("B%d", w->abt_type);
-#endif
w->abt_type_table[n]= w->abt_type;
if(w->abt_type){
// const uint8_t *scantable= w->abt_type-1 ? w->abt_scantable[1].permutated : w->abt_scantable[0].scantable;
sub_cbp= sub_cbp_table[ decode012(&s->gb) ];
-// printf("S%d", sub_cbp);
if(sub_cbp&1){
if (ff_msmpeg4_decode_block(s, block, n, 1, scantable) < 0)
if(w->j_type) return 0;
- if (s->pict_type == P_TYPE) {
- if(IS_SKIP(s->current_picture.mb_type[s->mb_y * s->mb_stride + s->mb_x])){
+ if (s->pict_type == AV_PICTURE_TYPE_P) {
+ if (IS_SKIP(s->current_picture.f.mb_type[s->mb_y * s->mb_stride + s->mb_x])) {
/* skip mb */
s->mb_intra = 0;
for(i=0;i<6;i++)
if (!s->mb_intra) {
int mx, my;
-//printf("P at %d %d\n", s->mb_x, s->mb_y);
wmv2_pred_motion(w, &mx, &my);
if(cbp){
}
}
} else {
-//if(s->pict_type==P_TYPE)
-// printf("%d%d ", s->inter_intra_pred, cbp);
-//printf("I at %d %d %d %06X\n", s->mb_x, s->mb_y, ((cbp&3)? 1 : 0) +((cbp&0x3C)? 2 : 0), show_bits(&s->gb, 24));
+ if (s->pict_type==AV_PICTURE_TYPE_P)
+ av_dlog(s->avctx, "%d%d ", s->inter_intra_pred, cbp);
+ av_dlog(s->avctx, "I at %d %d %d %06X\n", s->mb_x, s->mb_y,
+ ((cbp & 3) ? 1 : 0) +((cbp & 0x3C)? 2 : 0),
+ show_bits(&s->gb, 24));
s->ac_pred = get_bits1(&s->gb);
if(s->inter_intra_pred){
s->h263_aic_dir= get_vlc2(&s->gb, ff_inter_intra_vlc.table, INTER_INTRA_VLC_BITS, 1);
-// printf("%d%d %d %d/", s->ac_pred, s->h263_aic_dir, s->mb_x, s->mb_y);
+ av_dlog(s->avctx, "%d%d %d %d/",
+ s->ac_pred, s->h263_aic_dir, s->mb_x, s->mb_y);
}
if(s->per_mb_rl_table && cbp){
s->rl_table_index = decode012(&s->gb);
return 0;
}
-static int wmv2_decode_init(AVCodecContext *avctx){
+static av_cold int wmv2_decode_init(AVCodecContext *avctx){
Wmv2Context * const w= avctx->priv_data;
if(avctx->idct_algo==FF_IDCT_AUTO){
avctx->idct_algo=FF_IDCT_WMV2;
}
- if(ff_h263_decode_init(avctx) < 0)
+ if(ff_msmpeg4_decode_init(avctx) < 0)
return -1;
ff_wmv2_common_init(w);
return 0;
}
-static int wmv2_decode_end(AVCodecContext *avctx)
+static av_cold int wmv2_decode_end(AVCodecContext *avctx)
{
Wmv2Context *w = avctx->priv_data;
return ff_h263_decode_end(avctx);
}
-AVCodec wmv2_decoder = {
- "wmv2",
- CODEC_TYPE_VIDEO,
- CODEC_ID_WMV2,
- sizeof(Wmv2Context),
- wmv2_decode_init,
- NULL,
- wmv2_decode_end,
- ff_h263_decode_frame,
- CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1,
+AVCodec ff_wmv2_decoder = {
+ .name = "wmv2",
+ .type = AVMEDIA_TYPE_VIDEO,
+ .id = AV_CODEC_ID_WMV2,
+ .priv_data_size = sizeof(Wmv2Context),
+ .init = wmv2_decode_init,
+ .close = wmv2_decode_end,
+ .decode = ff_h263_decode_frame,
+ .capabilities = CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1,
+ .long_name = NULL_IF_CONFIG_SMALL("Windows Media Video 8"),
+ .pix_fmts = ff_pixfmt_list_420,
};