wmv2: K&R formatting cosmetics
Signed-off-by: Diego Biurrun <diego@biurrun.de>
This commit is contained in:
parent
7a1d6ddd2c
commit
eda7571ea1
@ -26,7 +26,8 @@
|
||||
#include "wmv2.h"
|
||||
|
||||
|
||||
av_cold void ff_wmv2_common_init(Wmv2Context * w){
|
||||
av_cold void ff_wmv2_common_init(Wmv2Context *w)
|
||||
{
|
||||
MpegEncContext *const s = &w->s;
|
||||
|
||||
ff_blockdsp_init(&s->bdsp, s->avctx);
|
||||
@ -51,7 +52,9 @@ av_cold void ff_wmv2_common_init(Wmv2Context * w){
|
||||
s->idsp.idct = NULL;
|
||||
}
|
||||
|
||||
static void wmv2_add_block(Wmv2Context *w, int16_t *block1, uint8_t *dst, int stride, int n){
|
||||
static void wmv2_add_block(Wmv2Context *w, int16_t *block1,
|
||||
uint8_t *dst, int stride, int n)
|
||||
{
|
||||
MpegEncContext *const s = &w->s;
|
||||
|
||||
if (s->block_last_index[n] >= 0) {
|
||||
@ -75,7 +78,9 @@ static void wmv2_add_block(Wmv2Context *w, int16_t *block1, uint8_t *dst, int st
|
||||
}
|
||||
}
|
||||
|
||||
void ff_wmv2_add_mb(MpegEncContext *s, int16_t block1[6][64], uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr){
|
||||
void ff_wmv2_add_mb(MpegEncContext *s, int16_t block1[6][64],
|
||||
uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr)
|
||||
{
|
||||
Wmv2Context *const w = (Wmv2Context *) s;
|
||||
|
||||
wmv2_add_block(w, block1[0], dest_y, s->linesize, 0);
|
||||
@ -83,14 +88,15 @@ void ff_wmv2_add_mb(MpegEncContext *s, int16_t block1[6][64], uint8_t *dest_y, u
|
||||
wmv2_add_block(w, block1[2], dest_y + 8 * s->linesize, s->linesize, 2);
|
||||
wmv2_add_block(w, block1[3], dest_y + 8 + 8 * s->linesize, s->linesize, 3);
|
||||
|
||||
if(s->flags&CODEC_FLAG_GRAY) return;
|
||||
if (s->flags & CODEC_FLAG_GRAY)
|
||||
return;
|
||||
|
||||
wmv2_add_block(w, block1[4], dest_cb, s->uvlinesize, 4);
|
||||
wmv2_add_block(w, block1[5], dest_cr, s->uvlinesize, 5);
|
||||
}
|
||||
|
||||
void ff_mspel_motion(MpegEncContext *s,
|
||||
uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr,
|
||||
void ff_mspel_motion(MpegEncContext *s, uint8_t *dest_y,
|
||||
uint8_t *dest_cb, uint8_t *dest_cr,
|
||||
uint8_t **ref_picture, op_pixels_func (*pix_op)[4],
|
||||
int motion_x, int motion_y, int h)
|
||||
{
|
||||
@ -119,12 +125,10 @@ void ff_mspel_motion(MpegEncContext *s,
|
||||
uvlinesize = s->uvlinesize;
|
||||
ptr = ref_picture[0] + (src_y * linesize) + src_x;
|
||||
|
||||
if(src_x<1 || src_y<1 || src_x + 17 >= s->h_edge_pos
|
||||
|| src_y + h+1 >= v_edge_pos){
|
||||
s->vdsp.emulated_edge_mc(s->edge_emu_buffer,
|
||||
ptr - 1 - s->linesize,
|
||||
s->linesize, s->linesize,
|
||||
19, 19,
|
||||
if (src_x < 1 || src_y < 1 || src_x + 17 >= s->h_edge_pos ||
|
||||
src_y + h + 1 >= v_edge_pos) {
|
||||
s->vdsp.emulated_edge_mc(s->edge_emu_buffer, ptr - 1 - s->linesize,
|
||||
s->linesize, s->linesize, 19, 19,
|
||||
src_x - 1, src_y - 1,
|
||||
s->h_edge_pos, s->v_edge_pos);
|
||||
ptr = s->edge_emu_buffer + 1 + s->linesize;
|
||||
@ -136,7 +140,8 @@ void ff_mspel_motion(MpegEncContext *s,
|
||||
w->wdsp.put_mspel_pixels_tab[dxy](dest_y + 8 * linesize, ptr + 8 * linesize, linesize);
|
||||
w->wdsp.put_mspel_pixels_tab[dxy](dest_y + 8 + 8 * linesize, ptr + 8 + 8 * linesize, linesize);
|
||||
|
||||
if(s->flags&CODEC_FLAG_GRAY) return;
|
||||
if (s->flags & CODEC_FLAG_GRAY)
|
||||
return;
|
||||
|
||||
if (s->out_format == FMT_H263) {
|
||||
dxy = 0;
|
||||
|
@ -22,8 +22,8 @@
|
||||
#define AVCODEC_WMV2_H
|
||||
|
||||
#include "avcodec.h"
|
||||
#include "mpegvideo.h"
|
||||
#include "intrax8.h"
|
||||
#include "mpegvideo.h"
|
||||
#include "wmv2dsp.h"
|
||||
|
||||
#define SKIP_TYPE_NONE 0
|
||||
|
@ -19,17 +19,18 @@
|
||||
*/
|
||||
|
||||
#include "avcodec.h"
|
||||
#include "h263.h"
|
||||
#include "intrax8.h"
|
||||
#include "mathops.h"
|
||||
#include "mpegutils.h"
|
||||
#include "mpegvideo.h"
|
||||
#include "h263.h"
|
||||
#include "mathops.h"
|
||||
#include "msmpeg4.h"
|
||||
#include "msmpeg4data.h"
|
||||
#include "intrax8.h"
|
||||
#include "wmv2.h"
|
||||
|
||||
|
||||
static void parse_mb_skip(Wmv2Context * w){
|
||||
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;
|
||||
@ -37,55 +38,55 @@ static void parse_mb_skip(Wmv2Context * w){
|
||||
w->skip_type = get_bits(&s->gb, 2);
|
||||
switch (w->skip_type) {
|
||||
case SKIP_TYPE_NONE:
|
||||
for(mb_y=0; mb_y<s->mb_height; mb_y++){
|
||||
for(mb_x=0; mb_x<s->mb_width; mb_x++){
|
||||
mb_type[mb_y*s->mb_stride + mb_x]= MB_TYPE_16x16 | MB_TYPE_L0;
|
||||
}
|
||||
}
|
||||
for (mb_y = 0; mb_y < s->mb_height; mb_y++)
|
||||
for (mb_x = 0; mb_x < s->mb_width; mb_x++)
|
||||
mb_type[mb_y * s->mb_stride + mb_x] =
|
||||
MB_TYPE_16x16 | MB_TYPE_L0;
|
||||
break;
|
||||
case SKIP_TYPE_MPEG:
|
||||
for(mb_y=0; mb_y<s->mb_height; mb_y++){
|
||||
for(mb_x=0; mb_x<s->mb_width; mb_x++){
|
||||
mb_type[mb_y*s->mb_stride + mb_x]= (get_bits1(&s->gb) ? MB_TYPE_SKIP : 0) | MB_TYPE_16x16 | MB_TYPE_L0;
|
||||
}
|
||||
}
|
||||
for (mb_y = 0; mb_y < s->mb_height; mb_y++)
|
||||
for (mb_x = 0; mb_x < s->mb_width; mb_x++)
|
||||
mb_type[mb_y * s->mb_stride + mb_x] =
|
||||
(get_bits1(&s->gb) ? MB_TYPE_SKIP : 0) | MB_TYPE_16x16 | MB_TYPE_L0;
|
||||
break;
|
||||
case SKIP_TYPE_ROW:
|
||||
for (mb_y = 0; mb_y < s->mb_height; mb_y++) {
|
||||
if (get_bits1(&s->gb)) {
|
||||
for(mb_x=0; mb_x<s->mb_width; mb_x++){
|
||||
mb_type[mb_y*s->mb_stride + mb_x]= MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_L0;
|
||||
}
|
||||
for (mb_x = 0; mb_x < s->mb_width; mb_x++)
|
||||
mb_type[mb_y * s->mb_stride + mb_x] =
|
||||
MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_L0;
|
||||
} else {
|
||||
for(mb_x=0; mb_x<s->mb_width; mb_x++){
|
||||
mb_type[mb_y*s->mb_stride + mb_x]= (get_bits1(&s->gb) ? MB_TYPE_SKIP : 0) | MB_TYPE_16x16 | MB_TYPE_L0;
|
||||
}
|
||||
for (mb_x = 0; mb_x < s->mb_width; mb_x++)
|
||||
mb_type[mb_y * s->mb_stride + mb_x] =
|
||||
(get_bits1(&s->gb) ? MB_TYPE_SKIP : 0) | MB_TYPE_16x16 | MB_TYPE_L0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SKIP_TYPE_COL:
|
||||
for (mb_x = 0; mb_x < s->mb_width; mb_x++) {
|
||||
if (get_bits1(&s->gb)) {
|
||||
for(mb_y=0; mb_y<s->mb_height; mb_y++){
|
||||
mb_type[mb_y*s->mb_stride + mb_x]= MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_L0;
|
||||
}
|
||||
for (mb_y = 0; mb_y < s->mb_height; mb_y++)
|
||||
mb_type[mb_y * s->mb_stride + mb_x] =
|
||||
MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_L0;
|
||||
} else {
|
||||
for(mb_y=0; mb_y<s->mb_height; mb_y++){
|
||||
mb_type[mb_y*s->mb_stride + mb_x]= (get_bits1(&s->gb) ? MB_TYPE_SKIP : 0) | MB_TYPE_16x16 | MB_TYPE_L0;
|
||||
}
|
||||
for (mb_y = 0; mb_y < s->mb_height; mb_y++)
|
||||
mb_type[mb_y * s->mb_stride + mb_x] =
|
||||
(get_bits1(&s->gb) ? MB_TYPE_SKIP : 0) | MB_TYPE_16x16 | MB_TYPE_L0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static int decode_ext_header(Wmv2Context *w){
|
||||
static int decode_ext_header(Wmv2Context *w)
|
||||
{
|
||||
MpegEncContext *const s = &w->s;
|
||||
GetBitContext gb;
|
||||
int fps;
|
||||
int code;
|
||||
|
||||
if(s->avctx->extradata_size<4) return -1;
|
||||
if (s->avctx->extradata_size < 4)
|
||||
return -1;
|
||||
|
||||
init_get_bits(&gb, s->avctx->extradata, 32);
|
||||
|
||||
@ -99,15 +100,19 @@ static int decode_ext_header(Wmv2Context *w){
|
||||
w->per_mb_rl_bit = get_bits1(&gb);
|
||||
code = get_bits(&gb, 3);
|
||||
|
||||
if(code==0) return -1;
|
||||
if (code == 0)
|
||||
return -1;
|
||||
|
||||
s->slice_height = s->mb_height / code;
|
||||
|
||||
if(s->avctx->debug&FF_DEBUG_PICT_INFO){
|
||||
av_log(s->avctx, AV_LOG_DEBUG, "fps:%d, br:%d, qpbit:%d, abt_flag:%d, j_type_bit:%d, tl_mv_flag:%d, mbrl_bit:%d, code:%d, loop_filter:%d, slices:%d\n",
|
||||
fps, s->bit_rate, w->mspel_bit, w->abt_flag, w->j_type_bit, w->top_left_mv_flag, w->per_mb_rl_bit, code, s->loop_filter,
|
||||
if (s->avctx->debug & FF_DEBUG_PICT_INFO)
|
||||
av_log(s->avctx, AV_LOG_DEBUG,
|
||||
"fps:%d, br:%d, qpbit:%d, abt_flag:%d, j_type_bit:%d, "
|
||||
"tl_mv_flag:%d, mbrl_bit:%d, code:%d, loop_filter:%d, "
|
||||
"slices:%d\n",
|
||||
fps, s->bit_rate, w->mspel_bit, w->abt_flag, w->j_type_bit,
|
||||
w->top_left_mv_flag, w->per_mb_rl_bit, code, s->loop_filter,
|
||||
code);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -136,12 +141,16 @@ int ff_wmv2_decode_secondary_picture_header(MpegEncContext * s)
|
||||
Wmv2Context *const w = (Wmv2Context *) s;
|
||||
|
||||
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
|
||||
if (w->j_type_bit)
|
||||
w->j_type = get_bits1(&s->gb);
|
||||
else
|
||||
w->j_type = 0; // FIXME check
|
||||
|
||||
if (!w->j_type) {
|
||||
if(w->per_mb_rl_bit) s->per_mb_rl_table= get_bits1(&s->gb);
|
||||
else s->per_mb_rl_table= 0;
|
||||
if (w->per_mb_rl_bit)
|
||||
s->per_mb_rl_table = get_bits1(&s->gb);
|
||||
else
|
||||
s->per_mb_rl_table = 0;
|
||||
|
||||
if (!s->per_mb_rl_table) {
|
||||
s->rl_chroma_table_index = decode012(&s->gb);
|
||||
@ -153,13 +162,10 @@ int ff_wmv2_decode_secondary_picture_header(MpegEncContext * s)
|
||||
s->inter_intra_pred = 0;
|
||||
s->no_rounding = 1;
|
||||
if (s->avctx->debug & FF_DEBUG_PICT_INFO) {
|
||||
av_log(s->avctx, AV_LOG_DEBUG, "qscale:%d rlc:%d rl:%d dc:%d mbrl:%d j_type:%d \n",
|
||||
s->qscale,
|
||||
s->rl_chroma_table_index,
|
||||
s->rl_table_index,
|
||||
s->dc_table_index,
|
||||
s->per_mb_rl_table,
|
||||
w->j_type);
|
||||
av_log(s->avctx, AV_LOG_DEBUG,
|
||||
"qscale:%d rlc:%d rl:%d dc:%d mbrl:%d j_type:%d \n",
|
||||
s->qscale, s->rl_chroma_table_index, s->rl_table_index,
|
||||
s->dc_table_index, s->per_mb_rl_table, w->j_type);
|
||||
}
|
||||
} else {
|
||||
int cbp_index;
|
||||
@ -178,18 +184,21 @@ int ff_wmv2_decode_secondary_picture_header(MpegEncContext * s)
|
||||
w->cbp_table_index = map[cbp_index];
|
||||
}
|
||||
|
||||
if(w->mspel_bit) s->mspel= get_bits1(&s->gb);
|
||||
else s->mspel= 0; //FIXME check
|
||||
if (w->mspel_bit)
|
||||
s->mspel = get_bits1(&s->gb);
|
||||
else
|
||||
s->mspel = 0; // FIXME check
|
||||
|
||||
if (w->abt_flag) {
|
||||
w->per_mb_abt = get_bits1(&s->gb) ^ 1;
|
||||
if(!w->per_mb_abt){
|
||||
if (!w->per_mb_abt)
|
||||
w->abt_type = decode012(&s->gb);
|
||||
}
|
||||
}
|
||||
|
||||
if(w->per_mb_rl_bit) s->per_mb_rl_table= get_bits1(&s->gb);
|
||||
else s->per_mb_rl_table= 0;
|
||||
if (w->per_mb_rl_bit)
|
||||
s->per_mb_rl_table = get_bits1(&s->gb);
|
||||
else
|
||||
s->per_mb_rl_table = 0;
|
||||
|
||||
if (!s->per_mb_rl_table) {
|
||||
s->rl_table_index = decode012(&s->gb);
|
||||
@ -203,26 +212,20 @@ int ff_wmv2_decode_secondary_picture_header(MpegEncContext * s)
|
||||
s->no_rounding ^= 1;
|
||||
|
||||
if (s->avctx->debug & FF_DEBUG_PICT_INFO) {
|
||||
av_log(s->avctx, AV_LOG_DEBUG, "rl:%d rlc:%d dc:%d mv:%d mbrl:%d qp:%d mspel:%d per_mb_abt:%d abt_type:%d cbp:%d ii:%d\n",
|
||||
s->rl_table_index,
|
||||
s->rl_chroma_table_index,
|
||||
s->dc_table_index,
|
||||
s->mv_table_index,
|
||||
s->per_mb_rl_table,
|
||||
s->qscale,
|
||||
s->mspel,
|
||||
w->per_mb_abt,
|
||||
w->abt_type,
|
||||
w->cbp_table_index,
|
||||
av_log(s->avctx, AV_LOG_DEBUG,
|
||||
"rl:%d rlc:%d dc:%d mv:%d mbrl:%d qp:%d mspel:%d "
|
||||
"per_mb_abt:%d abt_type:%d cbp:%d ii:%d\n",
|
||||
s->rl_table_index, s->rl_chroma_table_index,
|
||||
s->dc_table_index, s->mv_table_index,
|
||||
s->per_mb_rl_table, s->qscale, s->mspel,
|
||||
w->per_mb_abt, w->abt_type, w->cbp_table_index,
|
||||
s->inter_intra_pred);
|
||||
}
|
||||
}
|
||||
s->esc3_level_length = 0;
|
||||
s->esc3_run_length = 0;
|
||||
|
||||
s->picture_number++; // FIXME ?
|
||||
|
||||
|
||||
if (w->j_type) {
|
||||
ff_intrax8_decode_picture(&w->x8, 2 * s->qscale, (s->qscale - 1) | 1);
|
||||
return 1;
|
||||
@ -231,13 +234,15 @@ s->picture_number++; //FIXME ?
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int wmv2_decode_motion(Wmv2Context *w, int *mx_ptr, int *my_ptr){
|
||||
static inline int wmv2_decode_motion(Wmv2Context *w, int *mx_ptr, int *my_ptr)
|
||||
{
|
||||
MpegEncContext *const s = &w->s;
|
||||
int ret;
|
||||
|
||||
ret = ff_msmpeg4_decode_motion(s, mx_ptr, my_ptr);
|
||||
|
||||
if(ret<0) return -1;
|
||||
if (ret < 0)
|
||||
return -1;
|
||||
|
||||
if ((((*mx_ptr) | (*my_ptr)) & 1) && s->mspel)
|
||||
w->hshift = get_bits1(&s->gb);
|
||||
@ -247,7 +252,8 @@ static inline int wmv2_decode_motion(Wmv2Context *w, int *mx_ptr, int *my_ptr){
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int16_t *wmv2_pred_motion(Wmv2Context *w, int *px, int *py){
|
||||
static int16_t *wmv2_pred_motion(Wmv2Context *w, int *px, int *py)
|
||||
{
|
||||
MpegEncContext *const s = &w->s;
|
||||
int xy, wrap, diff, type;
|
||||
int16_t *A, *B, *C, *mot_val;
|
||||
@ -291,14 +297,15 @@ static int16_t *wmv2_pred_motion(Wmv2Context *w, int *px, int *py){
|
||||
return mot_val;
|
||||
}
|
||||
|
||||
static inline int wmv2_decode_inter_block(Wmv2Context *w, int16_t *block, int n, int cbp){
|
||||
static inline int wmv2_decode_inter_block(Wmv2Context *w, int16_t *block,
|
||||
int n, int cbp)
|
||||
{
|
||||
MpegEncContext *const s = &w->s;
|
||||
static const int sub_cbp_table[3] = { 2, 3, 1 };
|
||||
int sub_cbp;
|
||||
|
||||
if (!cbp) {
|
||||
s->block_last_index[n] = -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -313,31 +320,31 @@ static inline int wmv2_decode_inter_block(Wmv2Context *w, int16_t *block, int n,
|
||||
|
||||
sub_cbp = sub_cbp_table[decode012(&s->gb)];
|
||||
|
||||
if(sub_cbp&1){
|
||||
if (sub_cbp & 1)
|
||||
if (ff_msmpeg4_decode_block(s, block, n, 1, scantable) < 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(sub_cbp&2){
|
||||
if (sub_cbp & 2)
|
||||
if (ff_msmpeg4_decode_block(s, w->abt_block2[n], n, 1, scantable) < 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
s->block_last_index[n] = 63;
|
||||
|
||||
return 0;
|
||||
} else {
|
||||
return ff_msmpeg4_decode_block(s, block, n, 1, s->inter_scantable.permutated);
|
||||
return ff_msmpeg4_decode_block(s, block, n, 1,
|
||||
s->inter_scantable.permutated);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int ff_wmv2_decode_mb(MpegEncContext *s, int16_t block[6][64])
|
||||
{
|
||||
Wmv2Context *const w = (Wmv2Context *) s;
|
||||
int cbp, code, i;
|
||||
uint8_t *coded_val;
|
||||
|
||||
if(w->j_type) return 0;
|
||||
if (w->j_type)
|
||||
return 0;
|
||||
|
||||
if (s->pict_type == AV_PICTURE_TYPE_P) {
|
||||
if (IS_SKIP(s->current_picture.mb_type[s->mb_y * s->mb_stride + s->mb_x])) {
|
||||
@ -354,7 +361,8 @@ int ff_wmv2_decode_mb(MpegEncContext *s, int16_t block[6][64])
|
||||
return 0;
|
||||
}
|
||||
|
||||
code = get_vlc2(&s->gb, ff_mb_non_intra_vlc[w->cbp_table_index].table, MB_NON_INTRA_VLC_BITS, 3);
|
||||
code = get_vlc2(&s->gb, ff_mb_non_intra_vlc[w->cbp_table_index].table,
|
||||
MB_NON_INTRA_VLC_BITS, 3);
|
||||
if (code < 0)
|
||||
return -1;
|
||||
s->mb_intra = (~code & 0x40) >> 6;
|
||||
@ -364,7 +372,8 @@ int ff_wmv2_decode_mb(MpegEncContext *s, int16_t block[6][64])
|
||||
s->mb_intra = 1;
|
||||
code = get_vlc2(&s->gb, ff_msmp4_mb_i_vlc.table, MB_INTRA_VLC_BITS, 2);
|
||||
if (code < 0) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "II-cbp illegal at %d %d\n", s->mb_x, s->mb_y);
|
||||
av_log(s->avctx, AV_LOG_ERROR,
|
||||
"II-cbp illegal at %d %d\n", s->mb_x, s->mb_y);
|
||||
return -1;
|
||||
}
|
||||
/* predict coded block pattern */
|
||||
@ -408,9 +417,10 @@ int ff_wmv2_decode_mb(MpegEncContext *s, int16_t block[6][64])
|
||||
s->mv[0][0][1] = my;
|
||||
|
||||
for (i = 0; i < 6; i++) {
|
||||
if (wmv2_decode_inter_block(w, block[i], i, (cbp >> (5 - i)) & 1) < 0)
|
||||
{
|
||||
av_log(s->avctx, AV_LOG_ERROR, "\nerror while decoding inter block: %d x %d (%d)\n", s->mb_x, s->mb_y, i);
|
||||
if (wmv2_decode_inter_block(w, block[i], i, (cbp >> (5 - i)) & 1) < 0) {
|
||||
av_log(s->avctx, AV_LOG_ERROR,
|
||||
"\nerror while decoding inter block: %d x %d (%d)\n",
|
||||
s->mb_x, s->mb_y, i);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@ -422,7 +432,8 @@ int ff_wmv2_decode_mb(MpegEncContext *s, int16_t block[6][64])
|
||||
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);
|
||||
s->h263_aic_dir = get_vlc2(&s->gb, ff_inter_intra_vlc.table,
|
||||
INTER_INTRA_VLC_BITS, 1);
|
||||
av_dlog(s->avctx, "%d%d %d %d/",
|
||||
s->ac_pred, s->h263_aic_dir, s->mb_x, s->mb_y);
|
||||
}
|
||||
@ -433,9 +444,10 @@ int ff_wmv2_decode_mb(MpegEncContext *s, int16_t block[6][64])
|
||||
|
||||
s->bdsp.clear_blocks(s->block[0]);
|
||||
for (i = 0; i < 6; i++) {
|
||||
if (ff_msmpeg4_decode_block(s, block[i], i, (cbp >> (5 - i)) & 1, NULL) < 0)
|
||||
{
|
||||
av_log(s->avctx, AV_LOG_ERROR, "\nerror while decoding intra block: %d x %d (%d)\n", s->mb_x, s->mb_y, i);
|
||||
if (ff_msmpeg4_decode_block(s, block[i], i, (cbp >> (5 - i)) & 1, NULL) < 0) {
|
||||
av_log(s->avctx, AV_LOG_ERROR,
|
||||
"\nerror while decoding intra block: %d x %d (%d)\n",
|
||||
s->mb_x, s->mb_y, i);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@ -444,7 +456,8 @@ int ff_wmv2_decode_mb(MpegEncContext *s, int16_t block[6][64])
|
||||
return 0;
|
||||
}
|
||||
|
||||
static av_cold int wmv2_decode_init(AVCodecContext *avctx){
|
||||
static av_cold int wmv2_decode_init(AVCodecContext *avctx)
|
||||
{
|
||||
Wmv2Context *const w = avctx->priv_data;
|
||||
|
||||
if (ff_msmpeg4_decode_init(avctx) < 0)
|
||||
@ -475,8 +488,6 @@ AVCodec ff_wmv2_decoder = {
|
||||
.close = wmv2_decode_end,
|
||||
.decode = ff_h263_decode_frame,
|
||||
.capabilities = CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1,
|
||||
.pix_fmts = (const enum AVPixelFormat[]) {
|
||||
AV_PIX_FMT_YUV420P,
|
||||
AV_PIX_FMT_NONE
|
||||
},
|
||||
.pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P,
|
||||
AV_PIX_FMT_NONE },
|
||||
};
|
||||
|
@ -19,14 +19,15 @@
|
||||
*/
|
||||
|
||||
#include "avcodec.h"
|
||||
#include "h263.h"
|
||||
#include "mpegvideo.h"
|
||||
#include "msmpeg4.h"
|
||||
#include "msmpeg4data.h"
|
||||
#include "h263.h"
|
||||
#include "wmv2.h"
|
||||
|
||||
|
||||
static int encode_ext_header(Wmv2Context *w){
|
||||
static int encode_ext_header(Wmv2Context *w)
|
||||
{
|
||||
MpegEncContext *const s = &w->s;
|
||||
PutBitContext pb;
|
||||
int code;
|
||||
@ -51,7 +52,8 @@ static int encode_ext_header(Wmv2Context *w){
|
||||
return 0;
|
||||
}
|
||||
|
||||
static av_cold int wmv2_encode_init(AVCodecContext *avctx){
|
||||
static av_cold int wmv2_encode_init(AVCodecContext *avctx)
|
||||
{
|
||||
Wmv2Context *const w = avctx->priv_data;
|
||||
|
||||
if (ff_mpv_encode_init(avctx) < 0)
|
||||
@ -71,9 +73,8 @@ int ff_wmv2_encode_picture_header(MpegEncContext * s, int picture_number)
|
||||
Wmv2Context *const w = (Wmv2Context *) s;
|
||||
|
||||
put_bits(&s->pb, 1, s->pict_type - 1);
|
||||
if(s->pict_type == AV_PICTURE_TYPE_I){
|
||||
if (s->pict_type == AV_PICTURE_TYPE_I)
|
||||
put_bits(&s->pb, 7, 0);
|
||||
}
|
||||
put_bits(&s->pb, 5, s->qscale);
|
||||
|
||||
s->dc_table_index = 1;
|
||||
@ -88,9 +89,11 @@ int ff_wmv2_encode_picture_header(MpegEncContext * s, int picture_number)
|
||||
|
||||
if (s->pict_type == AV_PICTURE_TYPE_I) {
|
||||
assert(s->no_rounding == 1);
|
||||
if(w->j_type_bit) put_bits(&s->pb, 1, w->j_type);
|
||||
if (w->j_type_bit)
|
||||
put_bits(&s->pb, 1, w->j_type);
|
||||
|
||||
if(w->per_mb_rl_bit) put_bits(&s->pb, 1, s->per_mb_rl_table);
|
||||
if (w->per_mb_rl_bit)
|
||||
put_bits(&s->pb, 1, s->per_mb_rl_table);
|
||||
|
||||
if (!s->per_mb_rl_table) {
|
||||
ff_msmpeg4_code012(&s->pb, s->rl_chroma_table_index);
|
||||
@ -117,16 +120,17 @@ int ff_wmv2_encode_picture_header(MpegEncContext * s, int picture_number)
|
||||
w->cbp_table_index = map[cbp_index];
|
||||
}
|
||||
|
||||
if(w->mspel_bit) put_bits(&s->pb, 1, s->mspel);
|
||||
if (w->mspel_bit)
|
||||
put_bits(&s->pb, 1, s->mspel);
|
||||
|
||||
if (w->abt_flag) {
|
||||
put_bits(&s->pb, 1, w->per_mb_abt ^ 1);
|
||||
if(!w->per_mb_abt){
|
||||
if (!w->per_mb_abt)
|
||||
ff_msmpeg4_code012(&s->pb, w->abt_type);
|
||||
}
|
||||
}
|
||||
|
||||
if(w->per_mb_rl_bit) put_bits(&s->pb, 1, s->per_mb_rl_table);
|
||||
if (w->per_mb_rl_bit)
|
||||
put_bits(&s->pb, 1, s->per_mb_rl_table);
|
||||
|
||||
if (!s->per_mb_rl_table) {
|
||||
ff_msmpeg4_code012(&s->pb, s->rl_table_index);
|
||||
@ -146,8 +150,7 @@ int ff_wmv2_encode_picture_header(MpegEncContext * s, int picture_number)
|
||||
/* Nearly identical to wmv1 but that is just because we do not use the
|
||||
* useless M$ crap features. It is duplicated here in case someone wants
|
||||
* to add support for these crap features. */
|
||||
void ff_wmv2_encode_mb(MpegEncContext * s,
|
||||
int16_t block[6][64],
|
||||
void ff_wmv2_encode_mb(MpegEncContext *s, int16_t block[6][64],
|
||||
int motion_x, int motion_y)
|
||||
{
|
||||
Wmv2Context *const w = (Wmv2Context *) s;
|
||||
@ -160,10 +163,9 @@ void ff_wmv2_encode_mb(MpegEncContext * s,
|
||||
if (!s->mb_intra) {
|
||||
/* compute cbp */
|
||||
cbp = 0;
|
||||
for (i = 0; i < 6; i++) {
|
||||
for (i = 0; i < 6; i++)
|
||||
if (s->block_last_index[i] >= 0)
|
||||
cbp |= 1 << (5 - i);
|
||||
}
|
||||
|
||||
put_bits(&s->pb,
|
||||
ff_wmv2_inter_table[w->cbp_table_index][cbp + 64][1],
|
||||
@ -190,25 +192,26 @@ void ff_wmv2_encode_mb(MpegEncContext * s,
|
||||
coded_cbp |= val << (5 - i);
|
||||
}
|
||||
|
||||
if (s->pict_type == AV_PICTURE_TYPE_I) {
|
||||
if (s->pict_type == AV_PICTURE_TYPE_I)
|
||||
put_bits(&s->pb,
|
||||
ff_msmp4_mb_i_table[coded_cbp][1], ff_msmp4_mb_i_table[coded_cbp][0]);
|
||||
} else {
|
||||
ff_msmp4_mb_i_table[coded_cbp][1],
|
||||
ff_msmp4_mb_i_table[coded_cbp][0]);
|
||||
else
|
||||
put_bits(&s->pb,
|
||||
ff_wmv2_inter_table[w->cbp_table_index][cbp][1],
|
||||
ff_wmv2_inter_table[w->cbp_table_index][cbp][0]);
|
||||
}
|
||||
put_bits(&s->pb, 1, 0); /* no AC prediction yet */
|
||||
if (s->inter_intra_pred) {
|
||||
s->h263_aic_dir = 0;
|
||||
put_bits(&s->pb, ff_table_inter_intra[s->h263_aic_dir][1], ff_table_inter_intra[s->h263_aic_dir][0]);
|
||||
put_bits(&s->pb,
|
||||
ff_table_inter_intra[s->h263_aic_dir][1],
|
||||
ff_table_inter_intra[s->h263_aic_dir][0]);
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < 6; i++) {
|
||||
for (i = 0; i < 6; i++)
|
||||
ff_msmpeg4_encode_block(s, block[i], i);
|
||||
}
|
||||
}
|
||||
|
||||
AVCodec ff_wmv2_encoder = {
|
||||
.name = "wmv2",
|
||||
@ -219,5 +222,6 @@ AVCodec ff_wmv2_encoder = {
|
||||
.init = wmv2_encode_init,
|
||||
.encode2 = ff_mpv_encode_picture,
|
||||
.close = ff_mpv_encode_end,
|
||||
.pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE },
|
||||
.pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P,
|
||||
AV_PIX_FMT_NONE },
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user