Merge remote-tracking branch 'qatar/release/0.8' into release/0.10
* qatar/release/0.8: (23 commits) snow: Check mallocs at init vorbis: Validate that the floor 1 X values contain no duplicates. vorbisenc: check all allocations for failure indeo3: validate new frame size before resetting decoder lavfi: avfilter_merge_formats: handle case where inputs are same rv34: error out on size changes with frame threading rv34: Handle only complete frames in frame-mt. rv34: use AVERROR return values in ff_rv34_decode_frame() vlc/rl: Add ff_ prefix to the nonstatic symbols h263: Add ff_ prefix to nonstatic symbols alsdec: check opt_order. golomb: check remaining bits during unary decoding in get_ur_golomb_jpegls() lavf: don't segfault when a NULL filename is passed to avformat_open_input() mpegvideo: Don't use ff_mspel_motion() for vc1 imgconvert: avoid undefined left shift in avcodec_find_best_pix_fmt eval: fix swapping of lt() and lte() nuv: check RTjpeg header for validity Revert "nuv: check per-frame header for validity." bmpdec: only initialize palette for pal8. sipr: fall back to setting mode based on bit_rate. ... Conflicts: avconv.c libavcodec/dnxhddec.c libavcodec/golomb.h libavcodec/h263.h libavcodec/imgconvert.c libavcodec/mpegvideo_common.h libavcodec/mpegvideo_enc.c libavcodec/nuv.c libavcodec/rv34.c libavcodec/sipr.c libavcodec/vorbisdec.c libavcodec/vorbisenc.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
commit
be2dd2559f
@ -915,7 +915,7 @@ static av_cold int decode_end(AVCodecContext *avctx){
|
||||
av_freep(&f->cfrm[i].data);
|
||||
f->cfrm[i].allocated_size= 0;
|
||||
}
|
||||
free_vlc(&f->pre_vlc);
|
||||
ff_free_vlc(&f->pre_vlc);
|
||||
if(f->current_picture.data[0])
|
||||
avctx->release_buffer(avctx, &f->current_picture);
|
||||
if(f->last_picture.data[0])
|
||||
|
@ -663,6 +663,11 @@ static int read_var_block_data(ALSDecContext *ctx, ALSBlockData *bd)
|
||||
int opt_order_length = av_ceil_log2(av_clip((bd->block_length >> 3) - 1,
|
||||
2, sconf->max_order + 1));
|
||||
*bd->opt_order = get_bits(gb, opt_order_length);
|
||||
if (*bd->opt_order > sconf->max_order) {
|
||||
*bd->opt_order = sconf->max_order;
|
||||
av_log(avctx, AV_LOG_ERROR, "Predictor order too large!\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
} else {
|
||||
*bd->opt_order = sconf->max_order;
|
||||
}
|
||||
|
@ -253,9 +253,9 @@ static int build_table(VLC *vlc, int table_nb_bits, int nb_codes,
|
||||
(byte/word/long) to store the 'bits', 'codes', and 'symbols' tables.
|
||||
|
||||
'use_static' should be set to 1 for tables, which should be freed
|
||||
with av_free_static(), 0 if free_vlc() will be used.
|
||||
with av_free_static(), 0 if ff_free_vlc() will be used.
|
||||
*/
|
||||
int init_vlc_sparse(VLC *vlc, int nb_bits, int nb_codes,
|
||||
int ff_init_vlc_sparse(VLC *vlc, int nb_bits, int nb_codes,
|
||||
const void *bits, int bits_wrap, int bits_size,
|
||||
const void *codes, int codes_wrap, int codes_size,
|
||||
const void *symbols, int symbols_wrap, int symbols_size,
|
||||
@ -318,7 +318,7 @@ int init_vlc_sparse(VLC *vlc, int nb_bits, int nb_codes,
|
||||
}
|
||||
|
||||
|
||||
void free_vlc(VLC *vlc)
|
||||
void ff_free_vlc(VLC *vlc)
|
||||
{
|
||||
av_freep(&vlc->table);
|
||||
}
|
||||
|
@ -231,9 +231,6 @@ static int bmp_decode_frame(AVCodecContext *avctx,
|
||||
if(comp == BMP_RLE4 || comp == BMP_RLE8)
|
||||
memset(p->data[0], 0, avctx->height * p->linesize[0]);
|
||||
|
||||
if(depth == 4 || depth == 8)
|
||||
memset(p->data[1], 0, 1024);
|
||||
|
||||
if(height > 0){
|
||||
ptr = p->data[0] + (avctx->height - 1) * p->linesize[0];
|
||||
linesize = -p->linesize[0];
|
||||
@ -244,6 +241,9 @@ static int bmp_decode_frame(AVCodecContext *avctx,
|
||||
|
||||
if(avctx->pix_fmt == PIX_FMT_PAL8){
|
||||
int colors = 1 << depth;
|
||||
|
||||
memset(p->data[1], 0, 1024);
|
||||
|
||||
if(ihsize >= 36){
|
||||
int t;
|
||||
buf = buf0 + 46;
|
||||
|
@ -321,11 +321,11 @@ static av_cold int cook_decode_close(AVCodecContext *avctx)
|
||||
|
||||
/* Free the VLC tables. */
|
||||
for (i = 0; i < 13; i++)
|
||||
free_vlc(&q->envelope_quant_index[i]);
|
||||
ff_free_vlc(&q->envelope_quant_index[i]);
|
||||
for (i = 0; i < 7; i++)
|
||||
free_vlc(&q->sqvh[i]);
|
||||
ff_free_vlc(&q->sqvh[i]);
|
||||
for (i = 0; i < q->num_subpackets; i++)
|
||||
free_vlc(&q->subpacket[i].ccpl);
|
||||
ff_free_vlc(&q->subpacket[i].ccpl);
|
||||
|
||||
av_log(avctx, AV_LOG_DEBUG, "Memory deallocated.\n");
|
||||
|
||||
|
@ -84,9 +84,9 @@ static int dnxhd_init_vlc(DNXHDContext *ctx, int cid)
|
||||
}
|
||||
ctx->cid_table = &ff_dnxhd_cid_table[index];
|
||||
|
||||
free_vlc(&ctx->ac_vlc);
|
||||
free_vlc(&ctx->dc_vlc);
|
||||
free_vlc(&ctx->run_vlc);
|
||||
ff_free_vlc(&ctx->ac_vlc);
|
||||
ff_free_vlc(&ctx->dc_vlc);
|
||||
ff_free_vlc(&ctx->run_vlc);
|
||||
|
||||
init_vlc(&ctx->ac_vlc, DNXHD_VLC_BITS, 257,
|
||||
ctx->cid_table->ac_bits, 1, 1,
|
||||
@ -416,9 +416,9 @@ static av_cold int dnxhd_decode_close(AVCodecContext *avctx)
|
||||
|
||||
if (ctx->picture.data[0])
|
||||
ff_thread_release_buffer(avctx, &ctx->picture);
|
||||
free_vlc(&ctx->ac_vlc);
|
||||
free_vlc(&ctx->dc_vlc);
|
||||
free_vlc(&ctx->run_vlc);
|
||||
ff_free_vlc(&ctx->ac_vlc);
|
||||
ff_free_vlc(&ctx->dc_vlc);
|
||||
ff_free_vlc(&ctx->run_vlc);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -312,7 +312,7 @@ static av_cold int dvvideo_init(AVCodecContext *avctx)
|
||||
dv_rl_vlc[i].level = level;
|
||||
dv_rl_vlc[i].run = run;
|
||||
}
|
||||
free_vlc(&dv_vlc);
|
||||
ff_free_vlc(&dv_vlc);
|
||||
|
||||
dv_vlc_map_tableinit();
|
||||
}
|
||||
|
@ -110,11 +110,11 @@ av_cold void ff_ccitt_unpack_init(void)
|
||||
ccitt_vlc[1].table = code_table2;
|
||||
ccitt_vlc[1].table_allocated = 648;
|
||||
for(i = 0; i < 2; i++){
|
||||
init_vlc_sparse(&ccitt_vlc[i], 9, CCITT_SYMS,
|
||||
ccitt_codes_lens[i], 1, 1,
|
||||
ccitt_codes_bits[i], 1, 1,
|
||||
ccitt_syms, 2, 2,
|
||||
INIT_VLC_USE_NEW_STATIC);
|
||||
ff_init_vlc_sparse(&ccitt_vlc[i], 9, CCITT_SYMS,
|
||||
ccitt_codes_lens[i], 1, 1,
|
||||
ccitt_codes_bits[i], 1, 1,
|
||||
ccitt_syms, 2, 2,
|
||||
INIT_VLC_USE_NEW_STATIC);
|
||||
}
|
||||
INIT_VLC_STATIC(&ccitt_group3_2d_vlc, 9, 11,
|
||||
ccitt_group3_2d_lens, 1, 1,
|
||||
|
@ -113,13 +113,13 @@ static int fraps2_decode_plane(FrapsContext *s, uint8_t *dst, int stride, int w,
|
||||
if(j) dst[i] += dst[i - stride];
|
||||
else if(Uoff) dst[i] += 0x80;
|
||||
if (get_bits_left(&gb) < 0) {
|
||||
free_vlc(&vlc);
|
||||
ff_free_vlc(&vlc);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
}
|
||||
dst += stride;
|
||||
}
|
||||
free_vlc(&vlc);
|
||||
ff_free_vlc(&vlc);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -373,19 +373,19 @@ static inline void align_get_bits(GetBitContext *s)
|
||||
bits, bits_wrap, bits_size, \
|
||||
codes, codes_wrap, codes_size, \
|
||||
flags) \
|
||||
init_vlc_sparse(vlc, nb_bits, nb_codes, \
|
||||
bits, bits_wrap, bits_size, \
|
||||
codes, codes_wrap, codes_size, \
|
||||
NULL, 0, 0, flags)
|
||||
ff_init_vlc_sparse(vlc, nb_bits, nb_codes, \
|
||||
bits, bits_wrap, bits_size, \
|
||||
codes, codes_wrap, codes_size, \
|
||||
NULL, 0, 0, flags)
|
||||
|
||||
int init_vlc_sparse(VLC *vlc, int nb_bits, int nb_codes,
|
||||
int ff_init_vlc_sparse(VLC *vlc, int nb_bits, int nb_codes,
|
||||
const void *bits, int bits_wrap, int bits_size,
|
||||
const void *codes, int codes_wrap, int codes_size,
|
||||
const void *symbols, int symbols_wrap, int symbols_size,
|
||||
int flags);
|
||||
#define INIT_VLC_LE 2
|
||||
#define INIT_VLC_USE_NEW_STATIC 4
|
||||
void free_vlc(VLC *vlc);
|
||||
void ff_free_vlc(VLC *vlc);
|
||||
|
||||
#define INIT_VLC_STATIC(vlc, bits, a,b,c,d,e,f,g, static_size) do { \
|
||||
static VLC_TYPE table[static_size][2]; \
|
||||
|
@ -66,7 +66,7 @@ static av_cold void h261_decode_init_vlc(H261Context *h){
|
||||
INIT_VLC_STATIC(&h261_cbp_vlc, H261_CBP_VLC_BITS, 63,
|
||||
&h261_cbp_tab[0][1], 2, 1,
|
||||
&h261_cbp_tab[0][0], 2, 1, 512);
|
||||
init_rl(&h261_rl_tcoeff, ff_h261_rl_table_store);
|
||||
ff_init_rl(&h261_rl_tcoeff, ff_h261_rl_table_store);
|
||||
INIT_VLC_RL(h261_rl_tcoeff, 552);
|
||||
}
|
||||
}
|
||||
|
@ -240,7 +240,7 @@ void ff_h261_encode_init(MpegEncContext *s){
|
||||
|
||||
if (!done) {
|
||||
done = 1;
|
||||
init_rl(&h261_rl_tcoeff, ff_h261_rl_table_store);
|
||||
ff_init_rl(&h261_rl_tcoeff, ff_h261_rl_table_store);
|
||||
}
|
||||
|
||||
s->min_qcoeff= -127;
|
||||
|
@ -98,7 +98,7 @@ void ff_h263_update_motion_val(MpegEncContext * s){
|
||||
}
|
||||
}
|
||||
|
||||
int h263_pred_dc(MpegEncContext * s, int n, int16_t **dc_val_ptr)
|
||||
int ff_h263_pred_dc(MpegEncContext * s, int n, int16_t **dc_val_ptr)
|
||||
{
|
||||
int x, y, wrap, a, c, pred_dc;
|
||||
int16_t *dc_val;
|
||||
@ -226,7 +226,7 @@ void ff_h263_loop_filter(MpegEncContext * s){
|
||||
}
|
||||
}
|
||||
|
||||
void h263_pred_acdc(MpegEncContext * s, DCTELEM *block, int n)
|
||||
void ff_h263_pred_acdc(MpegEncContext * s, DCTELEM *block, int n)
|
||||
{
|
||||
int x, y, wrap, a, c, pred_dc, scale, i;
|
||||
int16_t *dc_val, *ac_val, *ac_val1;
|
||||
@ -313,8 +313,8 @@ void h263_pred_acdc(MpegEncContext * s, DCTELEM *block, int n)
|
||||
ac_val1[8 + i] = block[s->dsp.idct_permutation[i ]];
|
||||
}
|
||||
|
||||
int16_t *h263_pred_motion(MpegEncContext * s, int block, int dir,
|
||||
int *px, int *py)
|
||||
int16_t *ff_h263_pred_motion(MpegEncContext * s, int block, int dir,
|
||||
int *px, int *py)
|
||||
{
|
||||
int wrap;
|
||||
int16_t *A, *B, *C, (*mot_val)[2];
|
||||
|
@ -38,16 +38,16 @@
|
||||
extern const AVRational ff_h263_pixel_aspect[16];
|
||||
extern const uint8_t ff_h263_cbpy_tab[16][2];
|
||||
|
||||
extern const uint8_t cbpc_b_tab[4][2];
|
||||
extern const uint8_t ff_cbpc_b_tab[4][2];
|
||||
|
||||
extern const uint8_t mvtab[33][2];
|
||||
extern const uint8_t ff_mvtab[33][2];
|
||||
|
||||
extern const uint8_t ff_h263_intra_MCBPC_code[9];
|
||||
extern const uint8_t ff_h263_intra_MCBPC_bits[9];
|
||||
|
||||
extern const uint8_t ff_h263_inter_MCBPC_code[28];
|
||||
extern const uint8_t ff_h263_inter_MCBPC_bits[28];
|
||||
extern const uint8_t h263_mbtype_b_tab[15][2];
|
||||
extern const uint8_t ff_h263_mbtype_b_tab[15][2];
|
||||
|
||||
extern VLC ff_h263_intra_MCBPC_vlc;
|
||||
extern VLC ff_h263_inter_MCBPC_vlc;
|
||||
@ -55,41 +55,41 @@ extern VLC ff_h263_cbpy_vlc;
|
||||
|
||||
extern RLTable ff_h263_rl_inter;
|
||||
|
||||
extern RLTable rl_intra_aic;
|
||||
extern RLTable ff_rl_intra_aic;
|
||||
|
||||
extern const uint16_t h263_format[8][2];
|
||||
extern const uint8_t modified_quant_tab[2][32];
|
||||
extern const uint16_t ff_h263_format[8][2];
|
||||
extern const uint8_t ff_modified_quant_tab[2][32];
|
||||
extern const uint16_t ff_mba_max[6];
|
||||
extern const uint8_t ff_mba_length[7];
|
||||
|
||||
extern uint8_t ff_h263_static_rl_table_store[2][2][2*MAX_RUN + MAX_LEVEL + 3];
|
||||
|
||||
|
||||
int h263_decode_motion(MpegEncContext * s, int pred, int f_code);
|
||||
int ff_h263_decode_motion(MpegEncContext * s, int pred, int f_code);
|
||||
av_const int ff_h263_aspect_to_info(AVRational aspect);
|
||||
int ff_h263_decode_init(AVCodecContext *avctx);
|
||||
int ff_h263_decode_frame(AVCodecContext *avctx,
|
||||
void *data, int *data_size,
|
||||
AVPacket *avpkt);
|
||||
int ff_h263_decode_end(AVCodecContext *avctx);
|
||||
void h263_encode_mb(MpegEncContext *s,
|
||||
DCTELEM block[6][64],
|
||||
int motion_x, int motion_y);
|
||||
void h263_encode_picture_header(MpegEncContext *s, int picture_number);
|
||||
void h263_encode_gob_header(MpegEncContext * s, int mb_line);
|
||||
int16_t *h263_pred_motion(MpegEncContext * s, int block, int dir,
|
||||
int *px, int *py);
|
||||
void h263_encode_init(MpegEncContext *s);
|
||||
void h263_decode_init_vlc(MpegEncContext *s);
|
||||
int h263_decode_picture_header(MpegEncContext *s);
|
||||
void ff_h263_encode_mb(MpegEncContext *s,
|
||||
DCTELEM block[6][64],
|
||||
int motion_x, int motion_y);
|
||||
void ff_h263_encode_picture_header(MpegEncContext *s, int picture_number);
|
||||
void ff_h263_encode_gob_header(MpegEncContext * s, int mb_line);
|
||||
int16_t *ff_h263_pred_motion(MpegEncContext * s, int block, int dir,
|
||||
int *px, int *py);
|
||||
void ff_h263_encode_init(MpegEncContext *s);
|
||||
void ff_h263_decode_init_vlc(MpegEncContext *s);
|
||||
int ff_h263_decode_picture_header(MpegEncContext *s);
|
||||
int ff_h263_decode_gob_header(MpegEncContext *s);
|
||||
void ff_h263_update_motion_val(MpegEncContext * s);
|
||||
void ff_h263_loop_filter(MpegEncContext * s);
|
||||
int ff_h263_decode_mba(MpegEncContext *s);
|
||||
void ff_h263_encode_mba(MpegEncContext *s);
|
||||
void ff_init_qscale_tab(MpegEncContext *s);
|
||||
int h263_pred_dc(MpegEncContext * s, int n, int16_t **dc_val_ptr);
|
||||
void h263_pred_acdc(MpegEncContext * s, DCTELEM *block, int n);
|
||||
int ff_h263_pred_dc(MpegEncContext * s, int n, int16_t **dc_val_ptr);
|
||||
void ff_h263_pred_acdc(MpegEncContext * s, DCTELEM *block, int n);
|
||||
|
||||
|
||||
/**
|
||||
@ -119,7 +119,7 @@ static inline int h263_get_motion_length(MpegEncContext * s, int val, int f_code
|
||||
int l, bit_size, code;
|
||||
|
||||
if (val == 0) {
|
||||
return mvtab[0][1];
|
||||
return ff_mvtab[0][1];
|
||||
} else {
|
||||
bit_size = f_code - 1;
|
||||
/* modulo encoding */
|
||||
@ -128,7 +128,7 @@ static inline int h263_get_motion_length(MpegEncContext * s, int val, int f_code
|
||||
val--;
|
||||
code = (val >> bit_size) + 1;
|
||||
|
||||
return mvtab[code][1] + 1 + bit_size;
|
||||
return ff_mvtab[code][1] + 1 + bit_size;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -57,7 +57,7 @@ const uint8_t ff_h263_inter_MCBPC_bits[28] = {
|
||||
11, 13, 13, 13,/* inter4Q*/
|
||||
};
|
||||
|
||||
const uint8_t h263_mbtype_b_tab[15][2] = {
|
||||
const uint8_t ff_h263_mbtype_b_tab[15][2] = {
|
||||
{1, 1},
|
||||
{3, 3},
|
||||
{1, 5},
|
||||
@ -75,7 +75,7 @@ const uint8_t h263_mbtype_b_tab[15][2] = {
|
||||
{1, 8},
|
||||
};
|
||||
|
||||
const uint8_t cbpc_b_tab[4][2] = {
|
||||
const uint8_t ff_cbpc_b_tab[4][2] = {
|
||||
{0, 1},
|
||||
{2, 2},
|
||||
{7, 3},
|
||||
@ -88,7 +88,7 @@ const uint8_t ff_h263_cbpy_tab[16][2] =
|
||||
{2,5}, {3,6}, {5,4}, {10,4}, {4,4}, {8,4}, {6,4}, {3,2}
|
||||
};
|
||||
|
||||
const uint8_t mvtab[33][2] =
|
||||
const uint8_t ff_mvtab[33][2] =
|
||||
{
|
||||
{1,1}, {1,2}, {1,3}, {1,4}, {3,6}, {5,7}, {4,7}, {3,7},
|
||||
{11,9}, {10,9}, {9,9}, {17,10}, {16,10}, {15,10}, {14,10}, {13,10},
|
||||
@ -98,7 +98,7 @@ const uint8_t mvtab[33][2] =
|
||||
};
|
||||
|
||||
/* third non intra table */
|
||||
const uint16_t inter_vlc[103][2] = {
|
||||
const uint16_t ff_inter_vlc[103][2] = {
|
||||
{ 0x2, 2 },{ 0xf, 4 },{ 0x15, 6 },{ 0x17, 7 },
|
||||
{ 0x1f, 8 },{ 0x25, 9 },{ 0x24, 9 },{ 0x21, 10 },
|
||||
{ 0x20, 10 },{ 0x7, 11 },{ 0x6, 11 },{ 0x20, 11 },
|
||||
@ -127,7 +127,7 @@ const uint16_t inter_vlc[103][2] = {
|
||||
{ 0x5e, 12 },{ 0x5f, 12 },{ 0x3, 7 },
|
||||
};
|
||||
|
||||
const int8_t inter_level[102] = {
|
||||
const int8_t ff_inter_level[102] = {
|
||||
1, 2, 3, 4, 5, 6, 7, 8,
|
||||
9, 10, 11, 12, 1, 2, 3, 4,
|
||||
5, 6, 1, 2, 3, 4, 1, 2,
|
||||
@ -143,7 +143,7 @@ const int8_t inter_level[102] = {
|
||||
1, 1, 1, 1, 1, 1,
|
||||
};
|
||||
|
||||
const int8_t inter_run[102] = {
|
||||
const int8_t ff_inter_run[102] = {
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 1, 1, 1, 1,
|
||||
1, 1, 2, 2, 2, 2, 3, 3,
|
||||
@ -162,9 +162,9 @@ const int8_t inter_run[102] = {
|
||||
RLTable ff_h263_rl_inter = {
|
||||
102,
|
||||
58,
|
||||
inter_vlc,
|
||||
inter_run,
|
||||
inter_level,
|
||||
ff_inter_vlc,
|
||||
ff_inter_run,
|
||||
ff_inter_level,
|
||||
};
|
||||
|
||||
static const uint16_t intra_vlc_aic[103][2] = {
|
||||
@ -228,7 +228,7 @@ static const int8_t intra_level_aic[102] = {
|
||||
1, 1, 1, 1, 1, 1,
|
||||
};
|
||||
|
||||
RLTable rl_intra_aic = {
|
||||
RLTable ff_rl_intra_aic = {
|
||||
102,
|
||||
58,
|
||||
intra_vlc_aic,
|
||||
@ -236,7 +236,7 @@ RLTable rl_intra_aic = {
|
||||
intra_level_aic,
|
||||
};
|
||||
|
||||
const uint16_t h263_format[8][2] = {
|
||||
const uint16_t ff_h263_format[8][2] = {
|
||||
{ 0, 0 },
|
||||
{ 128, 96 },
|
||||
{ 176, 144 },
|
||||
@ -250,7 +250,7 @@ const uint8_t ff_aic_dc_scale_table[32]={
|
||||
0, 2, 4, 6, 8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60,62
|
||||
};
|
||||
|
||||
const uint8_t modified_quant_tab[2][32]={
|
||||
const uint8_t ff_modified_quant_tab[2][32]={
|
||||
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
||||
{
|
||||
0, 3, 1, 2, 3, 4, 5, 6, 7, 8, 9, 9,10,11,12,13,14,15,16,17,18,18,19,20,21,22,23,24,25,26,27,28
|
||||
|
@ -115,7 +115,7 @@ av_cold int ff_h263_decode_init(AVCodecContext *avctx)
|
||||
if (MPV_common_init(s) < 0)
|
||||
return -1;
|
||||
|
||||
h263_decode_init_vlc(s);
|
||||
ff_h263_decode_init_vlc(s);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -435,7 +435,7 @@ retry:
|
||||
} else if (CONFIG_FLV_DECODER && s->h263_flv) {
|
||||
ret = ff_flv_decode_picture_header(s);
|
||||
} else {
|
||||
ret = h263_decode_picture_header(s);
|
||||
ret = ff_h263_decode_picture_header(s);
|
||||
}
|
||||
|
||||
if(ret==FRAME_SKIPPED) return get_consumed_bytes(s, buf_size);
|
||||
|
@ -61,7 +61,7 @@ static int build_huff_tree(VLC *vlc, Node *nodes, int head, int flags)
|
||||
int pos = 0;
|
||||
|
||||
get_tree_codes(bits, lens, xlat, nodes, head, 0, 0, &pos, no_zero_count);
|
||||
return init_vlc_sparse(vlc, 9, pos, lens, 2, 2, bits, 4, 4, xlat, 1, 1, 0);
|
||||
return ff_init_vlc_sparse(vlc, 9, pos, lens, 2, 2, bits, 4, 4, xlat, 1, 1, 0);
|
||||
}
|
||||
|
||||
|
||||
|
@ -324,8 +324,8 @@ static void generate_joint_tables(HYuvContext *s){
|
||||
i++;
|
||||
}
|
||||
}
|
||||
free_vlc(&s->vlc[3+p]);
|
||||
init_vlc_sparse(&s->vlc[3+p], VLC_BITS, i, len, 1, 1, bits, 2, 2, symbols, 2, 2, 0);
|
||||
ff_free_vlc(&s->vlc[3+p]);
|
||||
ff_init_vlc_sparse(&s->vlc[3+p], VLC_BITS, i, len, 1, 1, bits, 2, 2, symbols, 2, 2, 0);
|
||||
}
|
||||
}else{
|
||||
uint8_t (*map)[4] = (uint8_t(*)[4])s->pix_bgr_map;
|
||||
@ -365,7 +365,7 @@ static void generate_joint_tables(HYuvContext *s){
|
||||
}
|
||||
}
|
||||
}
|
||||
free_vlc(&s->vlc[3]);
|
||||
ff_free_vlc(&s->vlc[3]);
|
||||
init_vlc(&s->vlc[3], VLC_BITS, i, len, 1, 1, bits, 2, 2, 0);
|
||||
}
|
||||
}
|
||||
@ -382,7 +382,7 @@ static int read_huffman_tables(HYuvContext *s, const uint8_t *src, int length){
|
||||
if(generate_bits_table(s->bits[i], s->len[i])<0){
|
||||
return -1;
|
||||
}
|
||||
free_vlc(&s->vlc[i]);
|
||||
ff_free_vlc(&s->vlc[i]);
|
||||
init_vlc(&s->vlc[i], VLC_BITS, 256, s->len[i], 1, 1, s->bits[i], 4, 4, 0);
|
||||
}
|
||||
|
||||
@ -414,7 +414,7 @@ static int read_old_huffman_tables(HYuvContext *s){
|
||||
memcpy(s->len[2] , s->len [1], 256*sizeof(uint8_t));
|
||||
|
||||
for(i=0; i<3; i++){
|
||||
free_vlc(&s->vlc[i]);
|
||||
ff_free_vlc(&s->vlc[i]);
|
||||
init_vlc(&s->vlc[i], VLC_BITS, 256, s->len[i], 1, 1, s->bits[i], 4, 4, 0);
|
||||
}
|
||||
|
||||
@ -1255,7 +1255,7 @@ static av_cold int decode_end(AVCodecContext *avctx)
|
||||
av_freep(&s->bitstream_buffer);
|
||||
|
||||
for(i=0; i<6; i++){
|
||||
free_vlc(&s->vlc[i]);
|
||||
ff_free_vlc(&s->vlc[i]);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -898,6 +898,14 @@ static int decode_frame_headers(Indeo3DecodeContext *ctx, AVCodecContext *avctx,
|
||||
|
||||
av_dlog(avctx, "Frame dimensions changed!\n");
|
||||
|
||||
if (width < 16 || width > 640 ||
|
||||
height < 16 || height > 480 ||
|
||||
width & 3 || height & 3) {
|
||||
av_log(avctx, AV_LOG_ERROR,
|
||||
"Invalid picture dimensions: %d x %d!\n", width, height);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
ctx->width = width;
|
||||
ctx->height = height;
|
||||
|
||||
|
@ -820,7 +820,7 @@ static av_cold int decode_close(AVCodecContext *avctx)
|
||||
ff_ivi_free_buffers(&ctx->planes[0]);
|
||||
|
||||
if (ctx->mb_vlc.cust_tab.table)
|
||||
free_vlc(&ctx->mb_vlc.cust_tab);
|
||||
ff_free_vlc(&ctx->mb_vlc.cust_tab);
|
||||
|
||||
if (ctx->frame.data[0])
|
||||
avctx->release_buffer(avctx, &ctx->frame);
|
||||
|
@ -65,8 +65,8 @@ int ff_intel_h263_decode_picture_header(MpegEncContext *s)
|
||||
s->pb_frame = get_bits1(&s->gb);
|
||||
|
||||
if (format < 6) {
|
||||
s->width = h263_format[format][0];
|
||||
s->height = h263_format[format][1];
|
||||
s->width = ff_h263_format[format][0];
|
||||
s->height = ff_h263_format[format][1];
|
||||
s->avctx->sample_aspect_ratio.num = 12;
|
||||
s->avctx->sample_aspect_ratio.den = 11;
|
||||
} else {
|
||||
|
@ -103,7 +103,7 @@ static VLC cbpc_b_vlc;
|
||||
/* init vlcs */
|
||||
|
||||
/* XXX: find a better solution to handle static init */
|
||||
void h263_decode_init_vlc(MpegEncContext *s)
|
||||
void ff_h263_decode_init_vlc(MpegEncContext *s)
|
||||
{
|
||||
static int done = 0;
|
||||
|
||||
@ -120,18 +120,18 @@ void h263_decode_init_vlc(MpegEncContext *s)
|
||||
&ff_h263_cbpy_tab[0][1], 2, 1,
|
||||
&ff_h263_cbpy_tab[0][0], 2, 1, 64);
|
||||
INIT_VLC_STATIC(&mv_vlc, MV_VLC_BITS, 33,
|
||||
&mvtab[0][1], 2, 1,
|
||||
&mvtab[0][0], 2, 1, 538);
|
||||
init_rl(&ff_h263_rl_inter, ff_h263_static_rl_table_store[0]);
|
||||
init_rl(&rl_intra_aic, ff_h263_static_rl_table_store[1]);
|
||||
&ff_mvtab[0][1], 2, 1,
|
||||
&ff_mvtab[0][0], 2, 1, 538);
|
||||
ff_init_rl(&ff_h263_rl_inter, ff_h263_static_rl_table_store[0]);
|
||||
ff_init_rl(&ff_rl_intra_aic, ff_h263_static_rl_table_store[1]);
|
||||
INIT_VLC_RL(ff_h263_rl_inter, 554);
|
||||
INIT_VLC_RL(rl_intra_aic, 554);
|
||||
INIT_VLC_RL(ff_rl_intra_aic, 554);
|
||||
INIT_VLC_STATIC(&h263_mbtype_b_vlc, H263_MBTYPE_B_VLC_BITS, 15,
|
||||
&h263_mbtype_b_tab[0][1], 2, 1,
|
||||
&h263_mbtype_b_tab[0][0], 2, 1, 80);
|
||||
&ff_h263_mbtype_b_tab[0][1], 2, 1,
|
||||
&ff_h263_mbtype_b_tab[0][0], 2, 1, 80);
|
||||
INIT_VLC_STATIC(&cbpc_b_vlc, CBPC_B_VLC_BITS, 4,
|
||||
&cbpc_b_tab[0][1], 2, 1,
|
||||
&cbpc_b_tab[0][0], 2, 1, 8);
|
||||
&ff_cbpc_b_tab[0][1], 2, 1,
|
||||
&ff_cbpc_b_tab[0][0], 2, 1, 8);
|
||||
}
|
||||
}
|
||||
|
||||
@ -271,7 +271,7 @@ int ff_h263_resync(MpegEncContext *s){
|
||||
return -1;
|
||||
}
|
||||
|
||||
int h263_decode_motion(MpegEncContext * s, int pred, int f_code)
|
||||
int ff_h263_decode_motion(MpegEncContext * s, int pred, int f_code)
|
||||
{
|
||||
int code, val, sign, shift;
|
||||
code = get_vlc2(&s->gb, mv_vlc.table, MV_VLC_BITS, 2);
|
||||
@ -381,16 +381,16 @@ static void preview_obmc(MpegEncContext *s){
|
||||
if ((cbpc & 16) == 0) {
|
||||
s->current_picture.f.mb_type[xy] = MB_TYPE_16x16 | MB_TYPE_L0;
|
||||
/* 16x16 motion prediction */
|
||||
mot_val= h263_pred_motion(s, 0, 0, &pred_x, &pred_y);
|
||||
mot_val= ff_h263_pred_motion(s, 0, 0, &pred_x, &pred_y);
|
||||
if (s->umvplus)
|
||||
mx = h263p_decode_umotion(s, pred_x);
|
||||
else
|
||||
mx = h263_decode_motion(s, pred_x, 1);
|
||||
mx = ff_h263_decode_motion(s, pred_x, 1);
|
||||
|
||||
if (s->umvplus)
|
||||
my = h263p_decode_umotion(s, pred_y);
|
||||
else
|
||||
my = h263_decode_motion(s, pred_y, 1);
|
||||
my = ff_h263_decode_motion(s, pred_y, 1);
|
||||
|
||||
mot_val[0 ]= mot_val[2 ]=
|
||||
mot_val[0+stride]= mot_val[2+stride]= mx;
|
||||
@ -399,16 +399,16 @@ static void preview_obmc(MpegEncContext *s){
|
||||
} else {
|
||||
s->current_picture.f.mb_type[xy] = MB_TYPE_8x8 | MB_TYPE_L0;
|
||||
for(i=0;i<4;i++) {
|
||||
mot_val = h263_pred_motion(s, i, 0, &pred_x, &pred_y);
|
||||
mot_val = ff_h263_pred_motion(s, i, 0, &pred_x, &pred_y);
|
||||
if (s->umvplus)
|
||||
mx = h263p_decode_umotion(s, pred_x);
|
||||
else
|
||||
mx = h263_decode_motion(s, pred_x, 1);
|
||||
mx = ff_h263_decode_motion(s, pred_x, 1);
|
||||
|
||||
if (s->umvplus)
|
||||
my = h263p_decode_umotion(s, pred_y);
|
||||
else
|
||||
my = h263_decode_motion(s, pred_y, 1);
|
||||
my = ff_h263_decode_motion(s, pred_y, 1);
|
||||
if (s->umvplus && (mx - pred_x) == 1 && (my - pred_y) == 1)
|
||||
skip_bits1(&s->gb); /* Bit stuffing to prevent PSC */
|
||||
mot_val[0] = mx;
|
||||
@ -432,7 +432,7 @@ static void h263_decode_dquant(MpegEncContext *s){
|
||||
|
||||
if(s->modified_quant){
|
||||
if(get_bits1(&s->gb))
|
||||
s->qscale= modified_quant_tab[get_bits1(&s->gb)][ s->qscale ];
|
||||
s->qscale= ff_modified_quant_tab[get_bits1(&s->gb)][ s->qscale ];
|
||||
else
|
||||
s->qscale= get_bits(&s->gb, 5);
|
||||
}else
|
||||
@ -450,7 +450,7 @@ static int h263_decode_block(MpegEncContext * s, DCTELEM * block,
|
||||
|
||||
scan_table = s->intra_scantable.permutated;
|
||||
if (s->h263_aic && s->mb_intra) {
|
||||
rl = &rl_intra_aic;
|
||||
rl = &ff_rl_intra_aic;
|
||||
i = 0;
|
||||
if (s->ac_pred) {
|
||||
if (s->h263_aic_dir)
|
||||
@ -539,7 +539,7 @@ retry:
|
||||
if (i >= 64){
|
||||
if(s->alt_inter_vlc && rl == &ff_h263_rl_inter && !s->mb_intra){
|
||||
//Looks like a hack but no, it's the way it is supposed to work ...
|
||||
rl = &rl_intra_aic;
|
||||
rl = &ff_rl_intra_aic;
|
||||
i = 0;
|
||||
s->gb= gb;
|
||||
s->dsp.clear_block(block);
|
||||
@ -556,7 +556,7 @@ retry:
|
||||
}
|
||||
not_coded:
|
||||
if (s->mb_intra && s->h263_aic) {
|
||||
h263_pred_acdc(s, block, n);
|
||||
ff_h263_pred_acdc(s, block, n);
|
||||
i = 63;
|
||||
}
|
||||
s->block_last_index[n] = i;
|
||||
@ -655,11 +655,11 @@ int ff_h263_decode_mb(MpegEncContext *s,
|
||||
s->current_picture.f.mb_type[xy] = MB_TYPE_16x16 | MB_TYPE_L0;
|
||||
/* 16x16 motion prediction */
|
||||
s->mv_type = MV_TYPE_16X16;
|
||||
h263_pred_motion(s, 0, 0, &pred_x, &pred_y);
|
||||
ff_h263_pred_motion(s, 0, 0, &pred_x, &pred_y);
|
||||
if (s->umvplus)
|
||||
mx = h263p_decode_umotion(s, pred_x);
|
||||
else
|
||||
mx = h263_decode_motion(s, pred_x, 1);
|
||||
mx = ff_h263_decode_motion(s, pred_x, 1);
|
||||
|
||||
if (mx >= 0xffff)
|
||||
return -1;
|
||||
@ -667,7 +667,7 @@ int ff_h263_decode_mb(MpegEncContext *s,
|
||||
if (s->umvplus)
|
||||
my = h263p_decode_umotion(s, pred_y);
|
||||
else
|
||||
my = h263_decode_motion(s, pred_y, 1);
|
||||
my = ff_h263_decode_motion(s, pred_y, 1);
|
||||
|
||||
if (my >= 0xffff)
|
||||
return -1;
|
||||
@ -680,18 +680,18 @@ int ff_h263_decode_mb(MpegEncContext *s,
|
||||
s->current_picture.f.mb_type[xy] = MB_TYPE_8x8 | MB_TYPE_L0;
|
||||
s->mv_type = MV_TYPE_8X8;
|
||||
for(i=0;i<4;i++) {
|
||||
mot_val = h263_pred_motion(s, i, 0, &pred_x, &pred_y);
|
||||
mot_val = ff_h263_pred_motion(s, i, 0, &pred_x, &pred_y);
|
||||
if (s->umvplus)
|
||||
mx = h263p_decode_umotion(s, pred_x);
|
||||
else
|
||||
mx = h263_decode_motion(s, pred_x, 1);
|
||||
mx = ff_h263_decode_motion(s, pred_x, 1);
|
||||
if (mx >= 0xffff)
|
||||
return -1;
|
||||
|
||||
if (s->umvplus)
|
||||
my = h263p_decode_umotion(s, pred_y);
|
||||
else
|
||||
my = h263_decode_motion(s, pred_y, 1);
|
||||
my = ff_h263_decode_motion(s, pred_y, 1);
|
||||
if (my >= 0xffff)
|
||||
return -1;
|
||||
s->mv[0][i][0] = mx;
|
||||
@ -763,11 +763,11 @@ int ff_h263_decode_mb(MpegEncContext *s,
|
||||
//FIXME UMV
|
||||
|
||||
if(USES_LIST(mb_type, 0)){
|
||||
int16_t *mot_val= h263_pred_motion(s, 0, 0, &mx, &my);
|
||||
int16_t *mot_val= ff_h263_pred_motion(s, 0, 0, &mx, &my);
|
||||
s->mv_dir = MV_DIR_FORWARD;
|
||||
|
||||
mx = h263_decode_motion(s, mx, 1);
|
||||
my = h263_decode_motion(s, my, 1);
|
||||
mx = ff_h263_decode_motion(s, mx, 1);
|
||||
my = ff_h263_decode_motion(s, my, 1);
|
||||
|
||||
s->mv[0][0][0] = mx;
|
||||
s->mv[0][0][1] = my;
|
||||
@ -776,11 +776,11 @@ int ff_h263_decode_mb(MpegEncContext *s,
|
||||
}
|
||||
|
||||
if(USES_LIST(mb_type, 1)){
|
||||
int16_t *mot_val= h263_pred_motion(s, 0, 1, &mx, &my);
|
||||
int16_t *mot_val= ff_h263_pred_motion(s, 0, 1, &mx, &my);
|
||||
s->mv_dir |= MV_DIR_BACKWARD;
|
||||
|
||||
mx = h263_decode_motion(s, mx, 1);
|
||||
my = h263_decode_motion(s, my, 1);
|
||||
mx = ff_h263_decode_motion(s, mx, 1);
|
||||
my = ff_h263_decode_motion(s, my, 1);
|
||||
|
||||
s->mv[1][0][0] = mx;
|
||||
s->mv[1][0][1] = my;
|
||||
@ -831,8 +831,8 @@ intra:
|
||||
}
|
||||
|
||||
while(pb_mv_count--){
|
||||
h263_decode_motion(s, 0, 1);
|
||||
h263_decode_motion(s, 0, 1);
|
||||
ff_h263_decode_motion(s, 0, 1);
|
||||
ff_h263_decode_motion(s, 0, 1);
|
||||
}
|
||||
|
||||
/* decode each block */
|
||||
@ -866,7 +866,7 @@ end:
|
||||
}
|
||||
|
||||
/* most is hardcoded. should extend to handle all h263 streams */
|
||||
int h263_decode_picture_header(MpegEncContext *s)
|
||||
int ff_h263_decode_picture_header(MpegEncContext *s)
|
||||
{
|
||||
int format, width, height, i;
|
||||
uint32_t startcode;
|
||||
@ -918,8 +918,8 @@ int h263_decode_picture_header(MpegEncContext *s)
|
||||
if (format != 7 && format != 6) {
|
||||
s->h263_plus = 0;
|
||||
/* H.263v1 */
|
||||
width = h263_format[format][0];
|
||||
height = h263_format[format][1];
|
||||
width = ff_h263_format[format][0];
|
||||
height = ff_h263_format[format][1];
|
||||
if (!width)
|
||||
return -1;
|
||||
|
||||
@ -1028,8 +1028,8 @@ int h263_decode_picture_header(MpegEncContext *s)
|
||||
s->avctx->sample_aspect_ratio= ff_h263_pixel_aspect[s->aspect_ratio_info];
|
||||
}
|
||||
} else {
|
||||
width = h263_format[format][0];
|
||||
height = h263_format[format][1];
|
||||
width = ff_h263_format[format][0];
|
||||
height = ff_h263_format[format][1];
|
||||
s->avctx->sample_aspect_ratio= (AVRational){12,11};
|
||||
}
|
||||
if ((width == 0) || (height == 0))
|
||||
|
@ -102,7 +102,7 @@ av_const int ff_h263_aspect_to_info(AVRational aspect){
|
||||
return FF_ASPECT_EXTENDED;
|
||||
}
|
||||
|
||||
void h263_encode_picture_header(MpegEncContext * s, int picture_number)
|
||||
void ff_h263_encode_picture_header(MpegEncContext * s, int picture_number)
|
||||
{
|
||||
int format, coded_frame_rate, coded_frame_rate_base, i, temp_ref;
|
||||
int best_clock_code=1;
|
||||
@ -141,7 +141,7 @@ void h263_encode_picture_header(MpegEncContext * s, int picture_number)
|
||||
put_bits(&s->pb, 1, 0); /* camera off */
|
||||
put_bits(&s->pb, 1, 0); /* freeze picture release off */
|
||||
|
||||
format = ff_match_2uint16(h263_format, FF_ARRAY_ELEMS(h263_format), s->width, s->height);
|
||||
format = ff_match_2uint16(ff_h263_format, FF_ARRAY_ELEMS(ff_h263_format), s->width, s->height);
|
||||
if (!s->h263_plus) {
|
||||
/* H.263v1 */
|
||||
put_bits(&s->pb, 3, format);
|
||||
@ -247,7 +247,7 @@ void h263_encode_picture_header(MpegEncContext * s, int picture_number)
|
||||
/**
|
||||
* Encode a group of blocks header.
|
||||
*/
|
||||
void h263_encode_gob_header(MpegEncContext * s, int mb_line)
|
||||
void ff_h263_encode_gob_header(MpegEncContext * s, int mb_line)
|
||||
{
|
||||
put_bits(&s->pb, 17, 1); /* GBSC */
|
||||
|
||||
@ -333,7 +333,7 @@ static void h263_encode_block(MpegEncContext * s, DCTELEM * block, int n)
|
||||
} else {
|
||||
i = 0;
|
||||
if (s->h263_aic && s->mb_intra)
|
||||
rl = &rl_intra_aic;
|
||||
rl = &ff_rl_intra_aic;
|
||||
|
||||
if(s->alt_inter_vlc && !s->mb_intra){
|
||||
int aic_vlc_bits=0;
|
||||
@ -353,14 +353,14 @@ static void h263_encode_block(MpegEncContext * s, DCTELEM * block, int n)
|
||||
if(level<0) level= -level;
|
||||
|
||||
code = get_rl_index(rl, last, run, level);
|
||||
aic_code = get_rl_index(&rl_intra_aic, last, run, level);
|
||||
aic_code = get_rl_index(&ff_rl_intra_aic, last, run, level);
|
||||
inter_vlc_bits += rl->table_vlc[code][1]+1;
|
||||
aic_vlc_bits += rl_intra_aic.table_vlc[aic_code][1]+1;
|
||||
aic_vlc_bits += ff_rl_intra_aic.table_vlc[aic_code][1]+1;
|
||||
|
||||
if (code == rl->n) {
|
||||
inter_vlc_bits += 1+6+8-1;
|
||||
}
|
||||
if (aic_code == rl_intra_aic.n) {
|
||||
if (aic_code == ff_rl_intra_aic.n) {
|
||||
aic_vlc_bits += 1+6+8-1;
|
||||
wrong_pos += run + 1;
|
||||
}else
|
||||
@ -370,7 +370,7 @@ static void h263_encode_block(MpegEncContext * s, DCTELEM * block, int n)
|
||||
}
|
||||
i = 0;
|
||||
if(aic_vlc_bits < inter_vlc_bits && wrong_pos > 63)
|
||||
rl = &rl_intra_aic;
|
||||
rl = &ff_rl_intra_aic;
|
||||
}
|
||||
}
|
||||
|
||||
@ -454,9 +454,9 @@ static void h263p_encode_umotion(MpegEncContext * s, int val)
|
||||
}
|
||||
}
|
||||
|
||||
void h263_encode_mb(MpegEncContext * s,
|
||||
DCTELEM block[6][64],
|
||||
int motion_x, int motion_y)
|
||||
void ff_h263_encode_mb(MpegEncContext * s,
|
||||
DCTELEM block[6][64],
|
||||
int motion_x, int motion_y)
|
||||
{
|
||||
int cbpc, cbpy, i, cbp, pred_x, pred_y;
|
||||
int16_t pred_dc;
|
||||
@ -500,7 +500,7 @@ void h263_encode_mb(MpegEncContext * s,
|
||||
}
|
||||
|
||||
/* motion vectors: 16x16 mode */
|
||||
h263_pred_motion(s, 0, 0, &pred_x, &pred_y);
|
||||
ff_h263_pred_motion(s, 0, 0, &pred_x, &pred_y);
|
||||
|
||||
if (!s->umvplus) {
|
||||
ff_h263_encode_motion_vector(s, motion_x - pred_x,
|
||||
@ -527,7 +527,7 @@ void h263_encode_mb(MpegEncContext * s,
|
||||
|
||||
for(i=0; i<4; i++){
|
||||
/* motion vectors: 8x8 mode*/
|
||||
h263_pred_motion(s, i, 0, &pred_x, &pred_y);
|
||||
ff_h263_pred_motion(s, i, 0, &pred_x, &pred_y);
|
||||
|
||||
motion_x = s->current_picture.f.motion_val[0][s->block_index[i]][0];
|
||||
motion_y = s->current_picture.f.motion_val[0][s->block_index[i]][1];
|
||||
@ -561,7 +561,7 @@ void h263_encode_mb(MpegEncContext * s,
|
||||
if(i<4) scale= s->y_dc_scale;
|
||||
else scale= s->c_dc_scale;
|
||||
|
||||
pred_dc = h263_pred_dc(s, i, &dc_ptr[i]);
|
||||
pred_dc = ff_h263_pred_dc(s, i, &dc_ptr[i]);
|
||||
level -= pred_dc;
|
||||
/* Quant */
|
||||
if (level >= 0)
|
||||
@ -662,7 +662,7 @@ void ff_h263_encode_motion(MpegEncContext * s, int val, int f_code)
|
||||
if (val == 0) {
|
||||
/* zero vector */
|
||||
code = 0;
|
||||
put_bits(&s->pb, mvtab[code][1], mvtab[code][0]);
|
||||
put_bits(&s->pb, ff_mvtab[code][1], ff_mvtab[code][0]);
|
||||
} else {
|
||||
bit_size = f_code - 1;
|
||||
range = 1 << bit_size;
|
||||
@ -676,7 +676,7 @@ void ff_h263_encode_motion(MpegEncContext * s, int val, int f_code)
|
||||
code = (val >> bit_size) + 1;
|
||||
bits = val & (range - 1);
|
||||
|
||||
put_bits(&s->pb, mvtab[code][1] + 1, (mvtab[code][0] << 1) | sign);
|
||||
put_bits(&s->pb, ff_mvtab[code][1] + 1, (ff_mvtab[code][0] << 1) | sign);
|
||||
if (bit_size > 0) {
|
||||
put_bits(&s->pb, bit_size, bits);
|
||||
}
|
||||
@ -692,7 +692,7 @@ static void init_mv_penalty_and_fcode(MpegEncContext *s)
|
||||
for(mv=-MAX_MV; mv<=MAX_MV; mv++){
|
||||
int len;
|
||||
|
||||
if(mv==0) len= mvtab[0][1];
|
||||
if(mv==0) len= ff_mvtab[0][1];
|
||||
else{
|
||||
int val, bit_size, code;
|
||||
|
||||
@ -704,9 +704,9 @@ static void init_mv_penalty_and_fcode(MpegEncContext *s)
|
||||
val--;
|
||||
code = (val >> bit_size) + 1;
|
||||
if(code<33){
|
||||
len= mvtab[code][1] + 1 + bit_size;
|
||||
len= ff_mvtab[code][1] + 1 + bit_size;
|
||||
}else{
|
||||
len= mvtab[32][1] + av_log2(code>>5) + 2 + bit_size;
|
||||
len= ff_mvtab[32][1] + av_log2(code>>5) + 2 + bit_size;
|
||||
}
|
||||
}
|
||||
|
||||
@ -768,17 +768,17 @@ static void init_uni_h263_rl_tab(RLTable *rl, uint32_t *bits_tab, uint8_t *len_t
|
||||
}
|
||||
}
|
||||
|
||||
void h263_encode_init(MpegEncContext *s)
|
||||
void ff_h263_encode_init(MpegEncContext *s)
|
||||
{
|
||||
static int done = 0;
|
||||
|
||||
if (!done) {
|
||||
done = 1;
|
||||
|
||||
init_rl(&ff_h263_rl_inter, ff_h263_static_rl_table_store[0]);
|
||||
init_rl(&rl_intra_aic, ff_h263_static_rl_table_store[1]);
|
||||
ff_init_rl(&ff_h263_rl_inter, ff_h263_static_rl_table_store[0]);
|
||||
ff_init_rl(&ff_rl_intra_aic, ff_h263_static_rl_table_store[1]);
|
||||
|
||||
init_uni_h263_rl_tab(&rl_intra_aic, NULL, uni_h263_intra_aic_rl_len);
|
||||
init_uni_h263_rl_tab(&ff_rl_intra_aic, NULL, uni_h263_intra_aic_rl_len);
|
||||
init_uni_h263_rl_tab(&ff_h263_rl_inter , NULL, uni_h263_inter_rl_len);
|
||||
|
||||
init_mv_penalty_and_fcode(s);
|
||||
|
@ -132,7 +132,7 @@ int ff_ivi_dec_huff_desc(GetBitContext *gb, int desc_coded, int which_tab,
|
||||
ff_ivi_huff_desc_copy(&huff_tab->cust_desc, &new_huff);
|
||||
|
||||
if (huff_tab->cust_tab.table)
|
||||
free_vlc(&huff_tab->cust_tab);
|
||||
ff_free_vlc(&huff_tab->cust_tab);
|
||||
result = ff_ivi_create_huff_from_desc(&huff_tab->cust_desc,
|
||||
&huff_tab->cust_tab, 0);
|
||||
if (result) {
|
||||
@ -237,7 +237,7 @@ void av_cold ff_ivi_free_buffers(IVIPlaneDesc *planes)
|
||||
av_freep(&planes[p].bands[b].bufs[2]);
|
||||
|
||||
if (planes[p].bands[b].blk_vlc.cust_tab.table)
|
||||
free_vlc(&planes[p].bands[b].blk_vlc.cust_tab);
|
||||
ff_free_vlc(&planes[p].bands[b].blk_vlc.cust_tab);
|
||||
for (t = 0; t < planes[p].bands[b].num_tiles; t++)
|
||||
av_freep(&planes[p].bands[b].tiles[t].mbs);
|
||||
av_freep(&planes[p].bands[b].tiles);
|
||||
|
@ -412,7 +412,7 @@ static av_cold int mimic_decode_end(AVCodecContext *avctx)
|
||||
for(i = 0; i < 16; i++)
|
||||
if(ctx->buf_ptrs[i].data[0])
|
||||
ff_thread_release_buffer(avctx, &ctx->buf_ptrs[i]);
|
||||
free_vlc(&ctx->vlc);
|
||||
ff_free_vlc(&ctx->vlc);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -63,8 +63,8 @@ static int build_vlc(VLC *vlc, const uint8_t *bits_table,
|
||||
if (is_ac)
|
||||
huff_sym[0] = 16 * 256;
|
||||
|
||||
return init_vlc_sparse(vlc, 9, nb_codes, huff_size, 1, 1,
|
||||
huff_code, 2, 2, huff_sym, 2, 2, use_static);
|
||||
return ff_init_vlc_sparse(vlc, 9, nb_codes, huff_size, 1, 1,
|
||||
huff_code, 2, 2, huff_sym, 2, 2, use_static);
|
||||
}
|
||||
|
||||
static void build_basic_mjpeg_vlc(MJpegDecodeContext *s)
|
||||
@ -197,7 +197,7 @@ int ff_mjpeg_decode_dht(MJpegDecodeContext *s)
|
||||
len -= n;
|
||||
|
||||
/* build VLC and flush previous vlc if present */
|
||||
free_vlc(&s->vlcs[class][index]);
|
||||
ff_free_vlc(&s->vlcs[class][index]);
|
||||
av_log(s->avctx, AV_LOG_DEBUG, "class=%d index=%d nb_codes=%d\n",
|
||||
class, index, code_max + 1);
|
||||
if (build_vlc(&s->vlcs[class][index], bits_table, val_table,
|
||||
@ -205,7 +205,7 @@ int ff_mjpeg_decode_dht(MJpegDecodeContext *s)
|
||||
return -1;
|
||||
|
||||
if (class > 0) {
|
||||
free_vlc(&s->vlcs[2][index]);
|
||||
ff_free_vlc(&s->vlcs[2][index]);
|
||||
if (build_vlc(&s->vlcs[2][index], bits_table, val_table,
|
||||
code_max + 1, 0, 0) < 0)
|
||||
return -1;
|
||||
@ -1773,7 +1773,7 @@ av_cold int ff_mjpeg_decode_end(AVCodecContext *avctx)
|
||||
|
||||
for (i = 0; i < 3; i++) {
|
||||
for (j = 0; j < 4; j++)
|
||||
free_vlc(&s->vlcs[i][j]);
|
||||
ff_free_vlc(&s->vlcs[i][j]);
|
||||
}
|
||||
for (i = 0; i < MAX_COMPONENTS; i++) {
|
||||
av_freep(&s->blocks[i]);
|
||||
|
@ -298,7 +298,7 @@ static int mp_decode_frame(AVCodecContext *avctx,
|
||||
if (init_vlc(&mp->vlc, mp->max_codes_bits, mp->codes_count, &mp->codes[0].size, sizeof(HuffCode), 1, &mp->codes[0].code, sizeof(HuffCode), 4, 0))
|
||||
goto end;
|
||||
mp_decode_frame_helper(mp, &gb);
|
||||
free_vlc(&mp->vlc);
|
||||
ff_free_vlc(&mp->vlc);
|
||||
|
||||
end:
|
||||
*data_size = sizeof(AVFrame);
|
||||
|
@ -185,13 +185,13 @@ static av_cold int mpc8_decode_init(AVCodecContext * avctx)
|
||||
|
||||
q3_vlc[0].table = q3_0_table;
|
||||
q3_vlc[0].table_allocated = 512;
|
||||
init_vlc_sparse(&q3_vlc[0], MPC8_Q3_BITS, MPC8_Q3_SIZE,
|
||||
ff_init_vlc_sparse(&q3_vlc[0], MPC8_Q3_BITS, MPC8_Q3_SIZE,
|
||||
mpc8_q3_bits, 1, 1,
|
||||
mpc8_q3_codes, 1, 1,
|
||||
mpc8_q3_syms, 1, 1, INIT_VLC_USE_NEW_STATIC);
|
||||
q3_vlc[1].table = q3_1_table;
|
||||
q3_vlc[1].table_allocated = 516;
|
||||
init_vlc_sparse(&q3_vlc[1], MPC8_Q4_BITS, MPC8_Q4_SIZE,
|
||||
ff_init_vlc_sparse(&q3_vlc[1], MPC8_Q4_BITS, MPC8_Q4_SIZE,
|
||||
mpc8_q4_bits, 1, 1,
|
||||
mpc8_q4_codes, 1, 1,
|
||||
mpc8_q4_syms, 1, 1, INIT_VLC_USE_NEW_STATIC);
|
||||
|
@ -696,8 +696,8 @@ av_cold void ff_mpeg12_init_vlcs(void)
|
||||
INIT_VLC_STATIC(&mb_btype_vlc, MB_BTYPE_VLC_BITS, 11,
|
||||
&table_mb_btype[0][1], 2, 1,
|
||||
&table_mb_btype[0][0], 2, 1, 64);
|
||||
init_rl(&ff_rl_mpeg1, ff_mpeg12_static_rl_table_store[0]);
|
||||
init_rl(&ff_rl_mpeg2, ff_mpeg12_static_rl_table_store[1]);
|
||||
ff_init_rl(&ff_rl_mpeg1, ff_mpeg12_static_rl_table_store[0]);
|
||||
ff_init_rl(&ff_rl_mpeg2, ff_mpeg12_static_rl_table_store[1]);
|
||||
|
||||
INIT_2D_VLC_RL(ff_rl_mpeg1, 680);
|
||||
INIT_2D_VLC_RL(ff_rl_mpeg2, 674);
|
||||
|
@ -729,8 +729,8 @@ void ff_mpeg1_encode_init(MpegEncContext *s)
|
||||
int i;
|
||||
|
||||
done=1;
|
||||
init_rl(&ff_rl_mpeg1, ff_mpeg12_static_rl_table_store[0]);
|
||||
init_rl(&ff_rl_mpeg2, ff_mpeg12_static_rl_table_store[1]);
|
||||
ff_init_rl(&ff_rl_mpeg1, ff_mpeg12_static_rl_table_store[0]);
|
||||
ff_init_rl(&ff_rl_mpeg2, ff_mpeg12_static_rl_table_store[1]);
|
||||
|
||||
for(i=0; i<64; i++)
|
||||
{
|
||||
|
@ -654,13 +654,13 @@ try_again:
|
||||
if ((cbpc & 16) == 0) {
|
||||
/* 16x16 motion prediction */
|
||||
|
||||
h263_pred_motion(s, 0, 0, &pred_x, &pred_y);
|
||||
ff_h263_pred_motion(s, 0, 0, &pred_x, &pred_y);
|
||||
if(!s->mcsel){
|
||||
mx = h263_decode_motion(s, pred_x, s->f_code);
|
||||
mx = ff_h263_decode_motion(s, pred_x, s->f_code);
|
||||
if (mx >= 0xffff)
|
||||
return -1;
|
||||
|
||||
my = h263_decode_motion(s, pred_y, s->f_code);
|
||||
my = ff_h263_decode_motion(s, pred_y, s->f_code);
|
||||
if (my >= 0xffff)
|
||||
return -1;
|
||||
s->current_picture.f.mb_type[xy] = MB_TYPE_16x16 | MB_TYPE_L0;
|
||||
@ -678,12 +678,12 @@ try_again:
|
||||
int i;
|
||||
s->current_picture.f.mb_type[xy] = MB_TYPE_8x8 | MB_TYPE_L0;
|
||||
for(i=0;i<4;i++) {
|
||||
int16_t *mot_val= h263_pred_motion(s, i, 0, &pred_x, &pred_y);
|
||||
mx = h263_decode_motion(s, pred_x, s->f_code);
|
||||
int16_t *mot_val= ff_h263_pred_motion(s, i, 0, &pred_x, &pred_y);
|
||||
mx = ff_h263_decode_motion(s, pred_x, s->f_code);
|
||||
if (mx >= 0xffff)
|
||||
return -1;
|
||||
|
||||
my = h263_decode_motion(s, pred_y, s->f_code);
|
||||
my = ff_h263_decode_motion(s, pred_y, s->f_code);
|
||||
if (my >= 0xffff)
|
||||
return -1;
|
||||
mot_val[0] = mx;
|
||||
@ -1248,14 +1248,14 @@ static int mpeg4_decode_mb(MpegEncContext *s,
|
||||
s->field_select[0][0]= get_bits1(&s->gb);
|
||||
s->field_select[0][1]= get_bits1(&s->gb);
|
||||
|
||||
h263_pred_motion(s, 0, 0, &pred_x, &pred_y);
|
||||
ff_h263_pred_motion(s, 0, 0, &pred_x, &pred_y);
|
||||
|
||||
for(i=0; i<2; i++){
|
||||
mx = h263_decode_motion(s, pred_x, s->f_code);
|
||||
mx = ff_h263_decode_motion(s, pred_x, s->f_code);
|
||||
if (mx >= 0xffff)
|
||||
return -1;
|
||||
|
||||
my = h263_decode_motion(s, pred_y/2, s->f_code);
|
||||
my = ff_h263_decode_motion(s, pred_y/2, s->f_code);
|
||||
if (my >= 0xffff)
|
||||
return -1;
|
||||
|
||||
@ -1266,13 +1266,13 @@ static int mpeg4_decode_mb(MpegEncContext *s,
|
||||
s->current_picture.f.mb_type[xy] = MB_TYPE_16x16 | MB_TYPE_L0;
|
||||
/* 16x16 motion prediction */
|
||||
s->mv_type = MV_TYPE_16X16;
|
||||
h263_pred_motion(s, 0, 0, &pred_x, &pred_y);
|
||||
mx = h263_decode_motion(s, pred_x, s->f_code);
|
||||
ff_h263_pred_motion(s, 0, 0, &pred_x, &pred_y);
|
||||
mx = ff_h263_decode_motion(s, pred_x, s->f_code);
|
||||
|
||||
if (mx >= 0xffff)
|
||||
return -1;
|
||||
|
||||
my = h263_decode_motion(s, pred_y, s->f_code);
|
||||
my = ff_h263_decode_motion(s, pred_y, s->f_code);
|
||||
|
||||
if (my >= 0xffff)
|
||||
return -1;
|
||||
@ -1283,12 +1283,12 @@ static int mpeg4_decode_mb(MpegEncContext *s,
|
||||
s->current_picture.f.mb_type[xy] = MB_TYPE_8x8 | MB_TYPE_L0;
|
||||
s->mv_type = MV_TYPE_8X8;
|
||||
for(i=0;i<4;i++) {
|
||||
mot_val = h263_pred_motion(s, i, 0, &pred_x, &pred_y);
|
||||
mx = h263_decode_motion(s, pred_x, s->f_code);
|
||||
mot_val = ff_h263_pred_motion(s, i, 0, &pred_x, &pred_y);
|
||||
mx = ff_h263_decode_motion(s, pred_x, s->f_code);
|
||||
if (mx >= 0xffff)
|
||||
return -1;
|
||||
|
||||
my = h263_decode_motion(s, pred_y, s->f_code);
|
||||
my = ff_h263_decode_motion(s, pred_y, s->f_code);
|
||||
if (my >= 0xffff)
|
||||
return -1;
|
||||
s->mv[0][i][0] = mx;
|
||||
@ -1384,8 +1384,8 @@ static int mpeg4_decode_mb(MpegEncContext *s,
|
||||
if(USES_LIST(mb_type, 0)){
|
||||
s->mv_dir = MV_DIR_FORWARD;
|
||||
|
||||
mx = h263_decode_motion(s, s->last_mv[0][0][0], s->f_code);
|
||||
my = h263_decode_motion(s, s->last_mv[0][0][1], s->f_code);
|
||||
mx = ff_h263_decode_motion(s, s->last_mv[0][0][0], s->f_code);
|
||||
my = ff_h263_decode_motion(s, s->last_mv[0][0][1], s->f_code);
|
||||
s->last_mv[0][1][0]= s->last_mv[0][0][0]= s->mv[0][0][0] = mx;
|
||||
s->last_mv[0][1][1]= s->last_mv[0][0][1]= s->mv[0][0][1] = my;
|
||||
}
|
||||
@ -1393,8 +1393,8 @@ static int mpeg4_decode_mb(MpegEncContext *s,
|
||||
if(USES_LIST(mb_type, 1)){
|
||||
s->mv_dir |= MV_DIR_BACKWARD;
|
||||
|
||||
mx = h263_decode_motion(s, s->last_mv[1][0][0], s->b_code);
|
||||
my = h263_decode_motion(s, s->last_mv[1][0][1], s->b_code);
|
||||
mx = ff_h263_decode_motion(s, s->last_mv[1][0][0], s->b_code);
|
||||
my = ff_h263_decode_motion(s, s->last_mv[1][0][1], s->b_code);
|
||||
s->last_mv[1][1][0]= s->last_mv[1][0][0]= s->mv[1][0][0] = mx;
|
||||
s->last_mv[1][1][1]= s->last_mv[1][0][1]= s->mv[1][0][1] = my;
|
||||
}
|
||||
@ -1405,8 +1405,8 @@ static int mpeg4_decode_mb(MpegEncContext *s,
|
||||
s->mv_dir = MV_DIR_FORWARD;
|
||||
|
||||
for(i=0; i<2; i++){
|
||||
mx = h263_decode_motion(s, s->last_mv[0][i][0] , s->f_code);
|
||||
my = h263_decode_motion(s, s->last_mv[0][i][1]/2, s->f_code);
|
||||
mx = ff_h263_decode_motion(s, s->last_mv[0][i][0] , s->f_code);
|
||||
my = ff_h263_decode_motion(s, s->last_mv[0][i][1]/2, s->f_code);
|
||||
s->last_mv[0][i][0]= s->mv[0][i][0] = mx;
|
||||
s->last_mv[0][i][1]= (s->mv[0][i][1] = my)*2;
|
||||
}
|
||||
@ -1416,8 +1416,8 @@ static int mpeg4_decode_mb(MpegEncContext *s,
|
||||
s->mv_dir |= MV_DIR_BACKWARD;
|
||||
|
||||
for(i=0; i<2; i++){
|
||||
mx = h263_decode_motion(s, s->last_mv[1][i][0] , s->b_code);
|
||||
my = h263_decode_motion(s, s->last_mv[1][i][1]/2, s->b_code);
|
||||
mx = ff_h263_decode_motion(s, s->last_mv[1][i][0] , s->b_code);
|
||||
my = ff_h263_decode_motion(s, s->last_mv[1][i][1]/2, s->b_code);
|
||||
s->last_mv[1][i][0]= s->mv[1][i][0] = mx;
|
||||
s->last_mv[1][i][1]= (s->mv[1][i][1] = my)*2;
|
||||
}
|
||||
@ -1429,8 +1429,8 @@ static int mpeg4_decode_mb(MpegEncContext *s,
|
||||
if(IS_SKIP(mb_type))
|
||||
mx=my=0;
|
||||
else{
|
||||
mx = h263_decode_motion(s, 0, 1);
|
||||
my = h263_decode_motion(s, 0, 1);
|
||||
mx = ff_h263_decode_motion(s, 0, 1);
|
||||
my = ff_h263_decode_motion(s, 0, 1);
|
||||
}
|
||||
|
||||
s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD | MV_DIRECT;
|
||||
@ -2237,9 +2237,9 @@ static av_cold int decode_init(AVCodecContext *avctx)
|
||||
if (!done) {
|
||||
done = 1;
|
||||
|
||||
init_rl(&ff_mpeg4_rl_intra, ff_mpeg4_static_rl_table_store[0]);
|
||||
init_rl(&rvlc_rl_inter, ff_mpeg4_static_rl_table_store[1]);
|
||||
init_rl(&rvlc_rl_intra, ff_mpeg4_static_rl_table_store[2]);
|
||||
ff_init_rl(&ff_mpeg4_rl_intra, ff_mpeg4_static_rl_table_store[0]);
|
||||
ff_init_rl(&rvlc_rl_inter, ff_mpeg4_static_rl_table_store[1]);
|
||||
ff_init_rl(&rvlc_rl_intra, ff_mpeg4_static_rl_table_store[2]);
|
||||
INIT_VLC_RL(ff_mpeg4_rl_intra, 554);
|
||||
INIT_VLC_RL(rvlc_rl_inter, 1072);
|
||||
INIT_VLC_RL(rvlc_rl_intra, 1072);
|
||||
|
@ -705,7 +705,7 @@ void mpeg4_encode_mb(MpegEncContext * s,
|
||||
}
|
||||
|
||||
/* motion vectors: 16x16 mode */
|
||||
h263_pred_motion(s, 0, 0, &pred_x, &pred_y);
|
||||
ff_h263_pred_motion(s, 0, 0, &pred_x, &pred_y);
|
||||
|
||||
ff_h263_encode_motion_vector(s, motion_x - pred_x,
|
||||
motion_y - pred_y, s->f_code);
|
||||
@ -729,7 +729,7 @@ void mpeg4_encode_mb(MpegEncContext * s,
|
||||
}
|
||||
|
||||
/* motion vectors: 16x8 interlaced mode */
|
||||
h263_pred_motion(s, 0, 0, &pred_x, &pred_y);
|
||||
ff_h263_pred_motion(s, 0, 0, &pred_x, &pred_y);
|
||||
pred_y /=2;
|
||||
|
||||
put_bits(&s->pb, 1, s->field_select[0][0]);
|
||||
@ -757,7 +757,7 @@ void mpeg4_encode_mb(MpegEncContext * s,
|
||||
|
||||
for(i=0; i<4; i++){
|
||||
/* motion vectors: 8x8 mode*/
|
||||
h263_pred_motion(s, i, 0, &pred_x, &pred_y);
|
||||
ff_h263_pred_motion(s, i, 0, &pred_x, &pred_y);
|
||||
|
||||
ff_h263_encode_motion_vector(s, s->current_picture.f.motion_val[0][ s->block_index[i] ][0] - pred_x,
|
||||
s->current_picture.f.motion_val[0][ s->block_index[i] ][1] - pred_y, s->f_code);
|
||||
@ -1240,7 +1240,7 @@ static av_cold int encode_init(AVCodecContext *avctx)
|
||||
|
||||
init_uni_dc_tab();
|
||||
|
||||
init_rl(&ff_mpeg4_rl_intra, ff_mpeg4_static_rl_table_store[0]);
|
||||
ff_init_rl(&ff_mpeg4_rl_intra, ff_mpeg4_static_rl_table_store[0]);
|
||||
|
||||
init_uni_mpeg4_rl_tab(&ff_mpeg4_rl_intra, uni_mpeg4_intra_rl_bits, uni_mpeg4_intra_rl_len);
|
||||
init_uni_mpeg4_rl_tab(&ff_h263_rl_inter, uni_mpeg4_inter_rl_bits, uni_mpeg4_inter_rl_len);
|
||||
|
@ -956,8 +956,8 @@ void MPV_common_end(MpegEncContext *s)
|
||||
avcodec_default_free_buffers(s->avctx);
|
||||
}
|
||||
|
||||
void init_rl(RLTable *rl,
|
||||
uint8_t static_store[2][2 * MAX_RUN + MAX_LEVEL + 3])
|
||||
void ff_init_rl(RLTable *rl,
|
||||
uint8_t static_store[2][2 * MAX_RUN + MAX_LEVEL + 3])
|
||||
{
|
||||
int8_t max_level[MAX_RUN + 1], max_run[MAX_LEVEL + 1];
|
||||
uint8_t index_run[MAX_RUN + 1];
|
||||
@ -1008,7 +1008,7 @@ void init_rl(RLTable *rl,
|
||||
}
|
||||
}
|
||||
|
||||
void init_vlc_rl(RLTable *rl)
|
||||
void ff_init_vlc_rl(RLTable *rl)
|
||||
{
|
||||
int i, q;
|
||||
|
||||
|
@ -725,7 +725,8 @@ static av_always_inline void MPV_motion_internal(MpegEncContext *s,
|
||||
0, 0, 0,
|
||||
ref_picture, pix_op, qpix_op,
|
||||
s->mv[dir][0][0], s->mv[dir][0][1], 16);
|
||||
}else if(!is_mpeg12 && (CONFIG_WMV2_DECODER || CONFIG_WMV2_ENCODER) && s->mspel && s->codec_id == CODEC_ID_WMV2){
|
||||
} else if (!is_mpeg12 && (CONFIG_WMV2_DECODER || CONFIG_WMV2_ENCODER) &&
|
||||
s->mspel && s->codec_id == CODEC_ID_WMV2) {
|
||||
ff_mspel_motion(s, dest_y, dest_cb, dest_cr,
|
||||
ref_picture, pix_op,
|
||||
s->mv[dir][0][0], s->mv[dir][0][1], 16);
|
||||
|
@ -712,7 +712,7 @@ av_cold int MPV_encode_init(AVCodecContext *avctx)
|
||||
case CODEC_ID_H263:
|
||||
if (!CONFIG_H263_ENCODER)
|
||||
return -1;
|
||||
if (ff_match_2uint16(h263_format, FF_ARRAY_ELEMS(h263_format),
|
||||
if (ff_match_2uint16(ff_h263_format, FF_ARRAY_ELEMS(ff_h263_format),
|
||||
s->width, s->height) == 8) {
|
||||
av_log(avctx, AV_LOG_ERROR,
|
||||
"The specified picture size of %dx%d is not valid for "
|
||||
@ -848,7 +848,7 @@ av_cold int MPV_encode_init(AVCodecContext *avctx)
|
||||
if (CONFIG_H261_ENCODER && s->out_format == FMT_H261)
|
||||
ff_h261_encode_init(s);
|
||||
if (CONFIG_H263_ENCODER && s->out_format == FMT_H263)
|
||||
h263_encode_init(s);
|
||||
ff_h263_encode_init(s);
|
||||
if (CONFIG_MSMPEG4_ENCODER && s->msmpeg4_version)
|
||||
ff_msmpeg4_encode_init(s);
|
||||
if ((CONFIG_MPEG1VIDEO_ENCODER || CONFIG_MPEG2VIDEO_ENCODER)
|
||||
@ -2086,7 +2086,7 @@ static av_always_inline void encode_mb_internal(MpegEncContext *s,
|
||||
case CODEC_ID_RV10:
|
||||
case CODEC_ID_RV20:
|
||||
if (CONFIG_H263_ENCODER)
|
||||
h263_encode_mb(s, s->block, motion_x, motion_y);
|
||||
ff_h263_encode_mb(s, s->block, motion_x, motion_y);
|
||||
break;
|
||||
case CODEC_ID_MJPEG:
|
||||
case CODEC_ID_AMV:
|
||||
@ -2522,7 +2522,7 @@ static int encode_thread(AVCodecContext *c, void *arg){
|
||||
case CODEC_ID_H263:
|
||||
case CODEC_ID_H263P:
|
||||
if (CONFIG_H263_ENCODER)
|
||||
h263_encode_gob_header(s, mb_y);
|
||||
ff_h263_encode_gob_header(s, mb_y);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -3298,7 +3298,7 @@ static int encode_picture(MpegEncContext *s, int picture_number)
|
||||
else if (CONFIG_FLV_ENCODER && s->codec_id == CODEC_ID_FLV1)
|
||||
ff_flv_encode_picture_header(s, picture_number);
|
||||
else if (CONFIG_H263_ENCODER)
|
||||
h263_encode_picture_header(s, picture_number);
|
||||
ff_h263_encode_picture_header(s, picture_number);
|
||||
break;
|
||||
case FMT_MPEG1:
|
||||
if (CONFIG_MPEG1VIDEO_ENCODER || CONFIG_MPEG2VIDEO_ENCODER)
|
||||
|
@ -262,7 +262,7 @@ av_cold void ff_msmpeg4_encode_init(MpegEncContext *s)
|
||||
init_mv_table(&mv_tables[0]);
|
||||
init_mv_table(&mv_tables[1]);
|
||||
for(i=0;i<NB_RL_TABLES;i++)
|
||||
init_rl(&rl_table[i], static_rl_table_store[i]);
|
||||
ff_init_rl(&rl_table[i], static_rl_table_store[i]);
|
||||
|
||||
for(i=0; i<NB_RL_TABLES; i++){
|
||||
int level;
|
||||
@ -507,7 +507,7 @@ static void msmpeg4v2_encode_motion(MpegEncContext * s, int val)
|
||||
if (val == 0) {
|
||||
/* zero vector */
|
||||
code = 0;
|
||||
put_bits(&s->pb, mvtab[code][1], mvtab[code][0]);
|
||||
put_bits(&s->pb, ff_mvtab[code][1], ff_mvtab[code][0]);
|
||||
} else {
|
||||
bit_size = s->f_code - 1;
|
||||
range = 1 << bit_size;
|
||||
@ -526,7 +526,7 @@ static void msmpeg4v2_encode_motion(MpegEncContext * s, int val)
|
||||
code = (val >> bit_size) + 1;
|
||||
bits = val & (range - 1);
|
||||
|
||||
put_bits(&s->pb, mvtab[code][1] + 1, (mvtab[code][0] << 1) | sign);
|
||||
put_bits(&s->pb, ff_mvtab[code][1] + 1, (ff_mvtab[code][0] << 1) | sign);
|
||||
if (bit_size > 0) {
|
||||
put_bits(&s->pb, bit_size, bits);
|
||||
}
|
||||
@ -575,7 +575,7 @@ void msmpeg4_encode_mb(MpegEncContext * s,
|
||||
|
||||
s->misc_bits += get_bits_diff(s);
|
||||
|
||||
h263_pred_motion(s, 0, 0, &pred_x, &pred_y);
|
||||
ff_h263_pred_motion(s, 0, 0, &pred_x, &pred_y);
|
||||
msmpeg4v2_encode_motion(s, motion_x - pred_x);
|
||||
msmpeg4v2_encode_motion(s, motion_y - pred_y);
|
||||
}else{
|
||||
@ -586,7 +586,7 @@ void msmpeg4_encode_mb(MpegEncContext * s,
|
||||
s->misc_bits += get_bits_diff(s);
|
||||
|
||||
/* motion vector */
|
||||
h263_pred_motion(s, 0, 0, &pred_x, &pred_y);
|
||||
ff_h263_pred_motion(s, 0, 0, &pred_x, &pred_y);
|
||||
ff_msmpeg4_encode_motion(s, motion_x - pred_x,
|
||||
motion_y - pred_y);
|
||||
}
|
||||
@ -1134,7 +1134,7 @@ static int msmpeg4v12_decode_mb(MpegEncContext *s, DCTELEM block[6][64])
|
||||
cbp|= cbpy<<2;
|
||||
if(s->msmpeg4_version==1 || (cbp&3) != 3) cbp^= 0x3C;
|
||||
|
||||
h263_pred_motion(s, 0, 0, &mx, &my);
|
||||
ff_h263_pred_motion(s, 0, 0, &mx, &my);
|
||||
mx= msmpeg4v2_decode_motion(s, mx, 1);
|
||||
my= msmpeg4v2_decode_motion(s, my, 1);
|
||||
|
||||
@ -1220,7 +1220,7 @@ static int msmpeg4v34_decode_mb(MpegEncContext *s, DCTELEM block[6][64])
|
||||
s->rl_table_index = decode012(&s->gb);
|
||||
s->rl_chroma_table_index = s->rl_table_index;
|
||||
}
|
||||
h263_pred_motion(s, 0, 0, &mx, &my);
|
||||
ff_h263_pred_motion(s, 0, 0, &mx, &my);
|
||||
if (ff_msmpeg4_decode_motion(s, &mx, &my) < 0)
|
||||
return -1;
|
||||
s->mv_dir = MV_DIR_FORWARD;
|
||||
@ -1271,7 +1271,7 @@ av_cold int ff_msmpeg4_decode_init(AVCodecContext *avctx)
|
||||
done = 1;
|
||||
|
||||
for(i=0;i<NB_RL_TABLES;i++) {
|
||||
init_rl(&rl_table[i], static_rl_table_store[i]);
|
||||
ff_init_rl(&rl_table[i], static_rl_table_store[i]);
|
||||
}
|
||||
INIT_VLC_RL(rl_table[0], 642);
|
||||
INIT_VLC_RL(rl_table[1], 1104);
|
||||
@ -1316,8 +1316,8 @@ av_cold int ff_msmpeg4_decode_init(AVCodecContext *avctx)
|
||||
&v2_mb_type[0][1], 2, 1,
|
||||
&v2_mb_type[0][0], 2, 1, 128);
|
||||
INIT_VLC_STATIC(&v2_mv_vlc, V2_MV_VLC_BITS, 33,
|
||||
&mvtab[0][1], 2, 1,
|
||||
&mvtab[0][0], 2, 1, 538);
|
||||
&ff_mvtab[0][1], 2, 1,
|
||||
&ff_mvtab[0][0], 2, 1, 538);
|
||||
|
||||
INIT_VLC_STATIC(&ff_mb_non_intra_vlc[0], MB_NON_INTRA_VLC_BITS, 128,
|
||||
&wmv2_inter_table[0][0][1], 8, 4,
|
||||
|
@ -592,9 +592,9 @@ static const int8_t table4_run[168] = {
|
||||
29, 30, 31, 32, 33, 34, 35, 36,
|
||||
};
|
||||
|
||||
extern const uint16_t inter_vlc[103][2];
|
||||
extern const int8_t inter_level[102];
|
||||
extern const int8_t inter_run[102];
|
||||
extern const uint16_t ff_inter_vlc[103][2];
|
||||
extern const int8_t ff_inter_level[102];
|
||||
extern const int8_t ff_inter_run[102];
|
||||
|
||||
extern const uint16_t ff_mpeg4_intra_vlc[103][2];
|
||||
extern const int8_t ff_mpeg4_intra_level[102];
|
||||
@ -647,9 +647,9 @@ RLTable rl_table[NB_RL_TABLES] = {
|
||||
{
|
||||
102,
|
||||
58,
|
||||
inter_vlc,
|
||||
inter_run,
|
||||
inter_level,
|
||||
ff_inter_vlc,
|
||||
ff_inter_run,
|
||||
ff_inter_level,
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -191,13 +191,15 @@ retry:
|
||||
}
|
||||
if (c->codec_frameheader) {
|
||||
int w, h, q, res;
|
||||
if (buf[0] != 'V' || buf_size < 12) {
|
||||
av_log(avctx, AV_LOG_ERROR, "invalid nuv video frame (wrong codec_tag?)\n");
|
||||
if (buf_size < RTJPEG_HEADER_SIZE || buf[4] != RTJPEG_HEADER_SIZE ||
|
||||
buf[5] != RTJPEG_FILE_VERSION) {
|
||||
av_log(avctx, AV_LOG_ERROR, "invalid nuv video frame\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
w = AV_RL16(&buf[6]);
|
||||
h = AV_RL16(&buf[8]);
|
||||
q = buf[10];
|
||||
|
||||
res = codec_reinit(avctx, w, h, q);
|
||||
if (res < 0)
|
||||
return res;
|
||||
@ -207,8 +209,8 @@ retry:
|
||||
size_change = 1;
|
||||
goto retry;
|
||||
}
|
||||
buf = &buf[12];
|
||||
buf_size -= 12;
|
||||
buf = &buf[RTJPEG_HEADER_SIZE];
|
||||
buf_size -= RTJPEG_HEADER_SIZE;
|
||||
}
|
||||
|
||||
if ((size_change || keyframe) && c->pic.data[0])
|
||||
|
@ -53,8 +53,8 @@ typedef struct RLTable {
|
||||
* @param static_store static uint8_t array[2][2*MAX_RUN + MAX_LEVEL + 3] which will hold
|
||||
* the level and run tables, if this is NULL av_malloc() will be used
|
||||
*/
|
||||
void init_rl(RLTable *rl, uint8_t static_store[2][2*MAX_RUN + MAX_LEVEL + 3]);
|
||||
void init_vlc_rl(RLTable *rl);
|
||||
void ff_init_rl(RLTable *rl, uint8_t static_store[2][2*MAX_RUN + MAX_LEVEL + 3]);
|
||||
void ff_init_vlc_rl(RLTable *rl);
|
||||
|
||||
#define INIT_VLC_RL(rl, static_size)\
|
||||
{\
|
||||
@ -68,7 +68,7 @@ void init_vlc_rl(RLTable *rl);
|
||||
for(q=0; q<32; q++)\
|
||||
rl.rl_vlc[q]= rl_vlc_table[q];\
|
||||
\
|
||||
init_vlc_rl(&rl);\
|
||||
ff_init_vlc_rl(&rl);\
|
||||
}\
|
||||
}
|
||||
|
||||
|
@ -25,6 +25,9 @@
|
||||
#include <stdint.h>
|
||||
#include "dsputil.h"
|
||||
|
||||
#define RTJPEG_FILE_VERSION 0
|
||||
#define RTJPEG_HEADER_SIZE 12
|
||||
|
||||
typedef struct {
|
||||
int w, h;
|
||||
DSPContext *dsp;
|
||||
|
@ -487,7 +487,7 @@ static av_cold int rv10_decode_init(AVCodecContext *avctx)
|
||||
if (MPV_common_init(s) < 0)
|
||||
return -1;
|
||||
|
||||
h263_decode_init_vlc(s);
|
||||
ff_h263_decode_init_vlc(s);
|
||||
|
||||
/* init rv vlc */
|
||||
if (!done) {
|
||||
|
@ -131,10 +131,10 @@ static void rv34_gen_vlc(const uint8_t *bits, int size, VLC *vlc, const uint8_t
|
||||
|
||||
vlc->table = &table_data[table_offs[num]];
|
||||
vlc->table_allocated = table_offs[num + 1] - table_offs[num];
|
||||
init_vlc_sparse(vlc, FFMIN(maxbits, 9), realsize,
|
||||
bits2, 1, 1,
|
||||
cw, 2, 2,
|
||||
syms, 2, 2, INIT_VLC_USE_NEW_STATIC);
|
||||
ff_init_vlc_sparse(vlc, FFMIN(maxbits, 9), realsize,
|
||||
bits2, 1, 1,
|
||||
cw, 2, 2,
|
||||
syms, 2, 2, INIT_VLC_USE_NEW_STATIC);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1411,7 +1411,7 @@ static int rv34_decode_slice(RV34DecContext *r, int end, const uint8_t* buf, int
|
||||
{
|
||||
MpegEncContext *s = &r->s;
|
||||
GetBitContext *gb = &s->gb;
|
||||
int mb_pos;
|
||||
int mb_pos, slice_type;
|
||||
int res;
|
||||
|
||||
init_get_bits(&r->s.gb, buf, buf_size*8);
|
||||
@ -1421,64 +1421,14 @@ static int rv34_decode_slice(RV34DecContext *r, int end, const uint8_t* buf, int
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((s->mb_x == 0 && s->mb_y == 0) || s->current_picture_ptr==NULL) {
|
||||
if (s->width != r->si.width || s->height != r->si.height) {
|
||||
int err;
|
||||
|
||||
av_log(s->avctx, AV_LOG_WARNING, "Changing dimensions to %dx%d\n",
|
||||
r->si.width, r->si.height);
|
||||
MPV_common_end(s);
|
||||
s->width = r->si.width;
|
||||
s->height = r->si.height;
|
||||
avcodec_set_dimensions(s->avctx, s->width, s->height);
|
||||
if ((err = MPV_common_init(s)) < 0)
|
||||
return err;
|
||||
if ((err = rv34_decoder_realloc(r)) < 0)
|
||||
return err;
|
||||
}
|
||||
s->pict_type = r->si.type ? r->si.type : AV_PICTURE_TYPE_I;
|
||||
if(MPV_frame_start(s, s->avctx) < 0)
|
||||
return -1;
|
||||
ff_er_frame_start(s);
|
||||
if (!r->tmp_b_block_base) {
|
||||
int i;
|
||||
|
||||
r->tmp_b_block_base = av_malloc(s->linesize * 48);
|
||||
for (i = 0; i < 2; i++)
|
||||
r->tmp_b_block_y[i] = r->tmp_b_block_base + i * 16 * s->linesize;
|
||||
for (i = 0; i < 4; i++)
|
||||
r->tmp_b_block_uv[i] = r->tmp_b_block_base + 32 * s->linesize
|
||||
+ (i >> 1) * 8 * s->uvlinesize + (i & 1) * 16;
|
||||
}
|
||||
r->cur_pts = r->si.pts;
|
||||
if(s->pict_type != AV_PICTURE_TYPE_B){
|
||||
r->last_pts = r->next_pts;
|
||||
r->next_pts = r->cur_pts;
|
||||
}else{
|
||||
int refdist = GET_PTS_DIFF(r->next_pts, r->last_pts);
|
||||
int dist0 = GET_PTS_DIFF(r->cur_pts, r->last_pts);
|
||||
int dist1 = GET_PTS_DIFF(r->next_pts, r->cur_pts);
|
||||
|
||||
if(!refdist){
|
||||
r->weight1 = r->weight2 = 8192;
|
||||
}else{
|
||||
r->weight1 = (dist0 << 14) / refdist;
|
||||
r->weight2 = (dist1 << 14) / refdist;
|
||||
}
|
||||
}
|
||||
s->mb_x = s->mb_y = 0;
|
||||
ff_thread_finish_setup(s->avctx);
|
||||
} else {
|
||||
int slice_type = r->si.type ? r->si.type : AV_PICTURE_TYPE_I;
|
||||
|
||||
if (slice_type != s->pict_type) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "Slice type mismatch\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
if (s->width != r->si.width || s->height != r->si.height) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "Size mismatch\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
slice_type = r->si.type ? r->si.type : AV_PICTURE_TYPE_I;
|
||||
if (slice_type != s->pict_type) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "Slice type mismatch\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
if (s->width != r->si.width || s->height != r->si.height) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "Size mismatch\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
r->si.end = end;
|
||||
@ -1628,10 +1578,6 @@ int ff_rv34_decode_update_thread_context(AVCodecContext *dst, const AVCodecConte
|
||||
|
||||
memset(&r->si, 0, sizeof(r->si));
|
||||
|
||||
/* necessary since it is it the condition checked for in decode_slice
|
||||
* to call MPV_frame_start. cmp. comment at the end of decode_frame */
|
||||
s->current_picture_ptr = NULL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1641,8 +1587,33 @@ static int get_slice_offset(AVCodecContext *avctx, const uint8_t *buf, int n)
|
||||
else return AV_RL32(buf + n*8 - 4) == 1 ? AV_RL32(buf + n*8) : AV_RB32(buf + n*8);
|
||||
}
|
||||
|
||||
static int finish_frame(AVCodecContext *avctx, AVFrame *pict)
|
||||
{
|
||||
RV34DecContext *r = avctx->priv_data;
|
||||
MpegEncContext *s = &r->s;
|
||||
int got_picture = 0;
|
||||
|
||||
ff_er_frame_end(s);
|
||||
MPV_frame_end(s);
|
||||
|
||||
if (HAVE_THREADS && (s->avctx->active_thread_type & FF_THREAD_FRAME))
|
||||
ff_thread_report_progress(&s->current_picture_ptr->f, INT_MAX, 0);
|
||||
|
||||
if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) {
|
||||
*pict = s->current_picture_ptr->f;
|
||||
got_picture = 1;
|
||||
} else if (s->last_picture_ptr != NULL) {
|
||||
*pict = s->last_picture_ptr->f;
|
||||
got_picture = 1;
|
||||
}
|
||||
if (got_picture)
|
||||
ff_print_debug_info(s, pict);
|
||||
|
||||
return got_picture;
|
||||
}
|
||||
|
||||
int ff_rv34_decode_frame(AVCodecContext *avctx,
|
||||
void *data, int *data_size,
|
||||
void *data, int *got_picture_ptr,
|
||||
AVPacket *avpkt)
|
||||
{
|
||||
const uint8_t *buf = avpkt->data;
|
||||
@ -1660,10 +1631,10 @@ int ff_rv34_decode_frame(AVCodecContext *avctx,
|
||||
if (buf_size == 0) {
|
||||
/* special case for last picture */
|
||||
if (s->low_delay==0 && s->next_picture_ptr) {
|
||||
*pict = *(AVFrame*)s->next_picture_ptr;
|
||||
*pict = s->next_picture_ptr->f;
|
||||
s->next_picture_ptr = NULL;
|
||||
|
||||
*data_size = sizeof(AVFrame);
|
||||
*got_picture_ptr = 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -1680,20 +1651,95 @@ int ff_rv34_decode_frame(AVCodecContext *avctx,
|
||||
if(get_slice_offset(avctx, slices_hdr, 0) < 0 ||
|
||||
get_slice_offset(avctx, slices_hdr, 0) > buf_size){
|
||||
av_log(avctx, AV_LOG_ERROR, "Slice offset is invalid\n");
|
||||
return -1;
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
init_get_bits(&s->gb, buf+get_slice_offset(avctx, slices_hdr, 0), (buf_size-get_slice_offset(avctx, slices_hdr, 0))*8);
|
||||
if(r->parse_slice_header(r, &r->s.gb, &si) < 0 || si.start){
|
||||
av_log(avctx, AV_LOG_ERROR, "First slice header is incorrect\n");
|
||||
return -1;
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
if ((!s->last_picture_ptr || !s->last_picture_ptr->f.data[0]) &&
|
||||
si.type == AV_PICTURE_TYPE_B) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Invalid decoder state: B-frame without "
|
||||
"reference data.\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
if ((!s->last_picture_ptr || !s->last_picture_ptr->f.data[0]) && si.type == AV_PICTURE_TYPE_B)
|
||||
return -1;
|
||||
if( (avctx->skip_frame >= AVDISCARD_NONREF && si.type==AV_PICTURE_TYPE_B)
|
||||
|| (avctx->skip_frame >= AVDISCARD_NONKEY && si.type!=AV_PICTURE_TYPE_I)
|
||||
|| avctx->skip_frame >= AVDISCARD_ALL)
|
||||
return avpkt->size;
|
||||
|
||||
/* first slice */
|
||||
if (si.start == 0) {
|
||||
if (s->mb_num_left > 0) {
|
||||
av_log(avctx, AV_LOG_ERROR, "New frame but still %d MB left.",
|
||||
s->mb_num_left);
|
||||
ff_er_frame_end(s);
|
||||
MPV_frame_end(s);
|
||||
}
|
||||
|
||||
if (s->width != si.width || s->height != si.height) {
|
||||
int err;
|
||||
|
||||
if (HAVE_THREADS &&
|
||||
(s->avctx->active_thread_type & FF_THREAD_FRAME)) {
|
||||
av_log_missing_feature(s->avctx, "Width/height changing with "
|
||||
"frame threading is", 0);
|
||||
return AVERROR_PATCHWELCOME;
|
||||
}
|
||||
|
||||
av_log(s->avctx, AV_LOG_WARNING, "Changing dimensions to %dx%d\n",
|
||||
si.width, si.height);
|
||||
MPV_common_end(s);
|
||||
s->width = si.width;
|
||||
s->height = si.height;
|
||||
avcodec_set_dimensions(s->avctx, s->width, s->height);
|
||||
if ((err = MPV_common_init(s)) < 0)
|
||||
return err;
|
||||
if ((err = rv34_decoder_realloc(r)) < 0)
|
||||
return err;
|
||||
}
|
||||
s->pict_type = si.type ? si.type : AV_PICTURE_TYPE_I;
|
||||
if (MPV_frame_start(s, s->avctx) < 0)
|
||||
return -1;
|
||||
ff_er_frame_start(s);
|
||||
if (!r->tmp_b_block_base) {
|
||||
int i;
|
||||
|
||||
r->tmp_b_block_base = av_malloc(s->linesize * 48);
|
||||
for (i = 0; i < 2; i++)
|
||||
r->tmp_b_block_y[i] = r->tmp_b_block_base
|
||||
+ i * 16 * s->linesize;
|
||||
for (i = 0; i < 4; i++)
|
||||
r->tmp_b_block_uv[i] = r->tmp_b_block_base + 32 * s->linesize
|
||||
+ (i >> 1) * 8 * s->uvlinesize
|
||||
+ (i & 1) * 16;
|
||||
}
|
||||
r->cur_pts = si.pts;
|
||||
if (s->pict_type != AV_PICTURE_TYPE_B) {
|
||||
r->last_pts = r->next_pts;
|
||||
r->next_pts = r->cur_pts;
|
||||
} else {
|
||||
int refdist = GET_PTS_DIFF(r->next_pts, r->last_pts);
|
||||
int dist0 = GET_PTS_DIFF(r->cur_pts, r->last_pts);
|
||||
int dist1 = GET_PTS_DIFF(r->next_pts, r->cur_pts);
|
||||
|
||||
if (!refdist) {
|
||||
r->weight1 = r->weight2 = 8192;
|
||||
} else {
|
||||
r->weight1 = (dist0 << 14) / refdist;
|
||||
r->weight2 = (dist1 << 14) / refdist;
|
||||
}
|
||||
}
|
||||
s->mb_x = s->mb_y = 0;
|
||||
ff_thread_finish_setup(s->avctx);
|
||||
} else if (HAVE_THREADS &&
|
||||
(s->avctx->active_thread_type & FF_THREAD_FRAME)) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "Decoder needs full frames in frame "
|
||||
"multithreading mode (start MB is %d).\n", si.start);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
for(i = 0; i < slice_count; i++){
|
||||
int offset = get_slice_offset(avctx, slices_hdr, i);
|
||||
int size;
|
||||
@ -1708,6 +1754,8 @@ int ff_rv34_decode_frame(AVCodecContext *avctx,
|
||||
}
|
||||
|
||||
r->si.end = s->mb_width * s->mb_height;
|
||||
s->mb_num_left = r->s.mb_x + r->s.mb_y*r->s.mb_width - r->si.start;
|
||||
|
||||
if(i+1 < slice_count){
|
||||
if (get_slice_offset(avctx, slices_hdr, i+1) < 0 ||
|
||||
get_slice_offset(avctx, slices_hdr, i+1) > buf_size) {
|
||||
@ -1728,32 +1776,28 @@ int ff_rv34_decode_frame(AVCodecContext *avctx,
|
||||
break;
|
||||
}
|
||||
last = rv34_decode_slice(r, r->si.end, buf + offset, size);
|
||||
s->mb_num_left = r->s.mb_x + r->s.mb_y*r->s.mb_width - r->si.start;
|
||||
if(last)
|
||||
break;
|
||||
}
|
||||
|
||||
if(last && s->current_picture_ptr){
|
||||
if(r->loop_filter)
|
||||
r->loop_filter(r, s->mb_height - 1);
|
||||
ff_er_frame_end(s);
|
||||
MPV_frame_end(s);
|
||||
if (s->current_picture_ptr) {
|
||||
if (last) {
|
||||
if(r->loop_filter)
|
||||
r->loop_filter(r, s->mb_height - 1);
|
||||
|
||||
if (HAVE_THREADS && (s->avctx->active_thread_type & FF_THREAD_FRAME))
|
||||
*got_picture_ptr = finish_frame(avctx, pict);
|
||||
} else if (HAVE_THREADS &&
|
||||
(s->avctx->active_thread_type & FF_THREAD_FRAME)) {
|
||||
av_log(avctx, AV_LOG_INFO, "marking unfished frame as finished\n");
|
||||
/* always mark the current frame as finished, frame-mt supports
|
||||
* only complete frames */
|
||||
ff_er_frame_end(s);
|
||||
MPV_frame_end(s);
|
||||
ff_thread_report_progress(&s->current_picture_ptr->f, INT_MAX, 0);
|
||||
|
||||
if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) {
|
||||
*pict = *(AVFrame*)s->current_picture_ptr;
|
||||
} else if (s->last_picture_ptr != NULL) {
|
||||
*pict = *(AVFrame*)s->last_picture_ptr;
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
if(s->last_picture_ptr || s->low_delay){
|
||||
*data_size = sizeof(AVFrame);
|
||||
ff_print_debug_info(s, pict);
|
||||
}
|
||||
s->current_picture_ptr = NULL; //so we can detect if frame_end wasnt called (find some nicer solution...)
|
||||
}
|
||||
|
||||
return avpkt->size;
|
||||
}
|
||||
|
||||
|
@ -101,7 +101,7 @@ static const uint8_t rv34_quant_to_vlc_set[2][31] = {
|
||||
|
||||
/**
|
||||
* table for obtaining the quantizer difference
|
||||
* @todo Use with modified_quant_tab from h263data.h.
|
||||
* @todo Use with ff_modified_quant_tab from h263data.h.
|
||||
*/
|
||||
static const uint8_t rv34_dquant_tab[2][32]={
|
||||
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
||||
|
@ -80,18 +80,18 @@ static av_cold void rv40_init_tables(void)
|
||||
for(i = 0; i < NUM_PTYPE_VLCS; i++){
|
||||
ptype_vlc[i].table = &ptype_table[i << PTYPE_VLC_BITS];
|
||||
ptype_vlc[i].table_allocated = 1 << PTYPE_VLC_BITS;
|
||||
init_vlc_sparse(&ptype_vlc[i], PTYPE_VLC_BITS, PTYPE_VLC_SIZE,
|
||||
ptype_vlc_bits[i], 1, 1,
|
||||
ptype_vlc_codes[i], 1, 1,
|
||||
ptype_vlc_syms, 1, 1, INIT_VLC_USE_NEW_STATIC);
|
||||
ff_init_vlc_sparse(&ptype_vlc[i], PTYPE_VLC_BITS, PTYPE_VLC_SIZE,
|
||||
ptype_vlc_bits[i], 1, 1,
|
||||
ptype_vlc_codes[i], 1, 1,
|
||||
ptype_vlc_syms, 1, 1, INIT_VLC_USE_NEW_STATIC);
|
||||
}
|
||||
for(i = 0; i < NUM_BTYPE_VLCS; i++){
|
||||
btype_vlc[i].table = &btype_table[i << BTYPE_VLC_BITS];
|
||||
btype_vlc[i].table_allocated = 1 << BTYPE_VLC_BITS;
|
||||
init_vlc_sparse(&btype_vlc[i], BTYPE_VLC_BITS, BTYPE_VLC_SIZE,
|
||||
btype_vlc_bits[i], 1, 1,
|
||||
btype_vlc_codes[i], 1, 1,
|
||||
btype_vlc_syms, 1, 1, INIT_VLC_USE_NEW_STATIC);
|
||||
ff_init_vlc_sparse(&btype_vlc[i], BTYPE_VLC_BITS, BTYPE_VLC_SIZE,
|
||||
btype_vlc_bits[i], 1, 1,
|
||||
btype_vlc_codes[i], 1, 1,
|
||||
btype_vlc_syms, 1, 1, INIT_VLC_USE_NEW_STATIC);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -486,11 +486,13 @@ static av_cold int sipr_decoder_init(AVCodecContext * avctx)
|
||||
case 29: ctx->mode = MODE_6k5; break;
|
||||
case 37: ctx->mode = MODE_5k0; break;
|
||||
default:
|
||||
av_log(avctx, AV_LOG_ERROR, "Invalid block_align: %d\n", avctx->block_align);
|
||||
if (avctx->bit_rate > 12200) ctx->mode = MODE_16k;
|
||||
else if (avctx->bit_rate > 7500 ) ctx->mode = MODE_8k5;
|
||||
else if (avctx->bit_rate > 5750 ) ctx->mode = MODE_6k5;
|
||||
else ctx->mode = MODE_5k0;
|
||||
av_log(avctx, AV_LOG_WARNING,
|
||||
"Invalid block_align: %d. Mode %s guessed based on bitrate: %d\n",
|
||||
avctx->block_align, modes[ctx->mode].mode_name, avctx->bit_rate);
|
||||
}
|
||||
|
||||
av_log(avctx, AV_LOG_DEBUG, "Mode: %s\n", modes[ctx->mode].mode_name);
|
||||
|
@ -272,9 +272,9 @@ static int smacker_decode_header_tree(SmackVContext *smk, GetBitContext *gb, int
|
||||
*recodes = huff.values;
|
||||
|
||||
if(vlc[0].table)
|
||||
free_vlc(&vlc[0]);
|
||||
ff_free_vlc(&vlc[0]);
|
||||
if(vlc[1].table)
|
||||
free_vlc(&vlc[1]);
|
||||
ff_free_vlc(&vlc[1]);
|
||||
av_free(tmp1.bits);
|
||||
av_free(tmp1.lengths);
|
||||
av_free(tmp1.values);
|
||||
@ -730,7 +730,7 @@ static int smka_decode_frame(AVCodecContext *avctx, void *data,
|
||||
|
||||
for(i = 0; i < 4; i++) {
|
||||
if(vlc[i].table)
|
||||
free_vlc(&vlc[i]);
|
||||
ff_free_vlc(&vlc[i]);
|
||||
av_free(h[i].bits);
|
||||
av_free(h[i].lengths);
|
||||
av_free(h[i].values);
|
||||
|
@ -385,7 +385,7 @@ mca( 8, 8,8)
|
||||
av_cold int ff_snow_common_init(AVCodecContext *avctx){
|
||||
SnowContext *s = avctx->priv_data;
|
||||
int width, height;
|
||||
int i, j;
|
||||
int i, j, ret;
|
||||
|
||||
s->avctx= avctx;
|
||||
s->max_ref_frames=1; //just make sure its not an invalid value in case of no initial keyframe
|
||||
@ -438,17 +438,22 @@ av_cold int ff_snow_common_init(AVCodecContext *avctx){
|
||||
width= s->avctx->width;
|
||||
height= s->avctx->height;
|
||||
|
||||
s->spatial_idwt_buffer= av_mallocz(width*height*sizeof(IDWTELEM));
|
||||
s->spatial_dwt_buffer= av_mallocz(width*height*sizeof(DWTELEM)); //FIXME this does not belong here
|
||||
FF_ALLOCZ_OR_GOTO(avctx, s->spatial_idwt_buffer, width * height * sizeof(IDWTELEM), fail);
|
||||
FF_ALLOCZ_OR_GOTO(avctx, s->spatial_dwt_buffer, width * height * sizeof(DWTELEM), fail); //FIXME this does not belong here
|
||||
|
||||
for(i=0; i<MAX_REF_FRAMES; i++)
|
||||
for(j=0; j<MAX_REF_FRAMES; j++)
|
||||
scale_mv_ref[i][j] = 256*(i+1)/(j+1);
|
||||
|
||||
s->avctx->get_buffer(s->avctx, &s->mconly_picture);
|
||||
s->scratchbuf = av_malloc(s->mconly_picture.linesize[0]*7*MB_SIZE);
|
||||
if ((ret = s->avctx->get_buffer(s->avctx, &s->mconly_picture)) < 0) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed\n");
|
||||
return ret;
|
||||
}
|
||||
FF_ALLOC_OR_GOTO(avctx, s->scratchbuf, s->mconly_picture.linesize[0]*7*MB_SIZE, fail);
|
||||
|
||||
return 0;
|
||||
fail:
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
|
||||
int ff_snow_common_init_after_header(AVCodecContext *avctx) {
|
||||
|
@ -354,9 +354,14 @@ static int decode_header(SnowContext *s){
|
||||
|
||||
static av_cold int decode_init(AVCodecContext *avctx)
|
||||
{
|
||||
int ret;
|
||||
|
||||
avctx->pix_fmt= PIX_FMT_YUV420P;
|
||||
|
||||
ff_snow_common_init(avctx);
|
||||
if ((ret = ff_snow_common_init(avctx)) < 0) {
|
||||
ff_snow_common_end(avctx->priv_data);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -156,7 +156,7 @@ static void dwt_quantize(SnowContext *s, Plane *p, DWTELEM *buffer, int width, i
|
||||
static av_cold int encode_init(AVCodecContext *avctx)
|
||||
{
|
||||
SnowContext *s = avctx->priv_data;
|
||||
int plane_index;
|
||||
int plane_index, ret;
|
||||
|
||||
if(avctx->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL){
|
||||
av_log(avctx, AV_LOG_ERROR, "This codec is under development, files encoded with it may not be decodable with future versions!!!\n"
|
||||
@ -185,7 +185,10 @@ static av_cold int encode_init(AVCodecContext *avctx)
|
||||
s->plane[plane_index].fast_mc= 1;
|
||||
}
|
||||
|
||||
ff_snow_common_init(avctx);
|
||||
if ((ret = ff_snow_common_init(avctx)) < 0) {
|
||||
ff_snow_common_end(avctx->priv_data);
|
||||
return ret;
|
||||
}
|
||||
ff_snow_alloc_blocks(s);
|
||||
|
||||
s->version=0;
|
||||
@ -199,7 +202,7 @@ static av_cold int encode_init(AVCodecContext *avctx)
|
||||
s->m.me.map = av_mallocz(ME_MAP_SIZE*sizeof(uint32_t));
|
||||
s->m.me.score_map = av_mallocz(ME_MAP_SIZE*sizeof(uint32_t));
|
||||
s->m.obmc_scratchpad= av_mallocz(MB_SIZE*MB_SIZE*12*sizeof(uint32_t));
|
||||
h263_encode_init(&s->m); //mv_penalty
|
||||
ff_h263_encode_init(&s->m); //mv_penalty
|
||||
|
||||
s->max_ref_frames = FFMAX(FFMIN(avctx->refs, MAX_REF_FRAMES), 1);
|
||||
|
||||
|
@ -43,7 +43,7 @@
|
||||
#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;
|
||||
@ -769,8 +769,8 @@ static av_cold int svq1_decode_init(AVCodecContext *avctx)
|
||||
&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}};
|
||||
|
@ -402,7 +402,7 @@ static int svq1_encode_plane(SVQ1Context *s, int plane, unsigned char *src_plane
|
||||
int mx, my, pred_x, pred_y, dxy;
|
||||
int16_t *motion_ptr;
|
||||
|
||||
motion_ptr= h263_pred_motion(&s->m, 0, 0, &pred_x, &pred_y);
|
||||
motion_ptr= ff_h263_pred_motion(&s->m, 0, 0, &pred_x, &pred_y);
|
||||
if(s->m.mb_type[x + y*s->m.mb_stride]&CANDIDATE_MB_TYPE_INTER){
|
||||
for(i=0; i<6; i++)
|
||||
init_put_bits(&s->reorder_pb[i], reorder_buffer[1][i], 7*32);
|
||||
@ -492,7 +492,7 @@ static av_cold int svq1_encode_init(AVCodecContext *avctx)
|
||||
s->m.me.score_map = av_mallocz(ME_MAP_SIZE*sizeof(uint32_t));
|
||||
s->mb_type = av_mallocz((s->y_block_width+1)*s->y_block_height*sizeof(int16_t));
|
||||
s->dummy = av_mallocz((s->y_block_width+1)*s->y_block_height*sizeof(int32_t));
|
||||
h263_encode_init(&s->m); //mv_penalty
|
||||
ff_h263_encode_init(&s->m); //mv_penalty
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -193,7 +193,7 @@ static void tm2_free_codes(TM2Codes *code)
|
||||
{
|
||||
av_free(code->recode);
|
||||
if(code->vlc.table)
|
||||
free_vlc(&code->vlc);
|
||||
ff_free_vlc(&code->vlc);
|
||||
}
|
||||
|
||||
static inline int tm2_get_token(GetBitContext *gb, TM2Codes *code)
|
||||
|
@ -103,10 +103,10 @@ static int build_huff(const uint8_t *src, VLC *vlc, int *fsym)
|
||||
code += 0x80000000u >> (he[i].len - 1);
|
||||
}
|
||||
|
||||
return init_vlc_sparse(vlc, FFMIN(he[last].len, 9), last + 1,
|
||||
bits, sizeof(*bits), sizeof(*bits),
|
||||
codes, sizeof(*codes), sizeof(*codes),
|
||||
syms, sizeof(*syms), sizeof(*syms), 0);
|
||||
return ff_init_vlc_sparse(vlc, FFMIN(he[last].len, 9), last + 1,
|
||||
bits, sizeof(*bits), sizeof(*bits),
|
||||
codes, sizeof(*codes), sizeof(*codes),
|
||||
syms, sizeof(*syms), sizeof(*syms), 0);
|
||||
}
|
||||
|
||||
static int decode_plane(UtvideoContext *c, int plane_no,
|
||||
@ -207,11 +207,11 @@ static int decode_plane(UtvideoContext *c, int plane_no,
|
||||
get_bits_left(&gb));
|
||||
}
|
||||
|
||||
free_vlc(&vlc);
|
||||
ff_free_vlc(&vlc);
|
||||
|
||||
return 0;
|
||||
fail:
|
||||
free_vlc(&vlc);
|
||||
ff_free_vlc(&vlc);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
|
@ -5817,6 +5817,7 @@ AVCodec ff_vc1_decoder = {
|
||||
.init = vc1_decode_init,
|
||||
.close = vc1_decode_end,
|
||||
.decode = vc1_decode_frame,
|
||||
.flush = ff_mpeg_flush,
|
||||
.capabilities = CODEC_CAP_DR1 | CODEC_CAP_DELAY,
|
||||
.long_name = NULL_IF_CONFIG_SMALL("SMPTE VC-1"),
|
||||
.pix_fmts = ff_hwaccel_pixfmt_list_420,
|
||||
@ -5832,6 +5833,7 @@ AVCodec ff_wmv3_decoder = {
|
||||
.init = vc1_decode_init,
|
||||
.close = vc1_decode_end,
|
||||
.decode = vc1_decode_frame,
|
||||
.flush = ff_mpeg_flush,
|
||||
.capabilities = CODEC_CAP_DR1 | CODEC_CAP_DELAY,
|
||||
.long_name = NULL_IF_CONFIG_SMALL("Windows Media Video 9"),
|
||||
.pix_fmts = ff_hwaccel_pixfmt_list_420,
|
||||
|
@ -123,7 +123,8 @@ int ff_vorbis_len2vlc(uint8_t *bits, uint32_t *codes, unsigned num)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ff_vorbis_ready_floor1_list(vorbis_floor1_entry * list, int values)
|
||||
int ff_vorbis_ready_floor1_list(AVCodecContext *avccontext,
|
||||
vorbis_floor1_entry *list, int values)
|
||||
{
|
||||
int i;
|
||||
list[0].sort = 0;
|
||||
@ -147,6 +148,11 @@ void ff_vorbis_ready_floor1_list(vorbis_floor1_entry * list, int values)
|
||||
for (i = 0; i < values - 1; i++) {
|
||||
int j;
|
||||
for (j = i + 1; j < values; j++) {
|
||||
if (list[i].x == list[j].x) {
|
||||
av_log(avccontext, AV_LOG_ERROR,
|
||||
"Duplicate value found in floor 1 X coordinates\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
if (list[list[i].sort].x > list[list[j].sort].x) {
|
||||
int tmp = list[i].sort;
|
||||
list[i].sort = list[j].sort;
|
||||
@ -154,6 +160,7 @@ void ff_vorbis_ready_floor1_list(vorbis_floor1_entry * list, int values)
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline void render_line_unrolled(intptr_t x, int y, int x1,
|
||||
|
@ -36,7 +36,8 @@ typedef struct {
|
||||
uint16_t high;
|
||||
} vorbis_floor1_entry;
|
||||
|
||||
void ff_vorbis_ready_floor1_list(vorbis_floor1_entry * list, int values);
|
||||
int ff_vorbis_ready_floor1_list(AVCodecContext *avccontext,
|
||||
vorbis_floor1_entry *list, int values);
|
||||
unsigned int ff_vorbis_nth_root(unsigned int x, unsigned int n); // x^(1/n)
|
||||
int ff_vorbis_len2vlc(uint8_t *bits, uint32_t *codes, unsigned num);
|
||||
void ff_vorbis_floor1_render_list(vorbis_floor1_entry * list, int values,
|
||||
|
@ -207,7 +207,7 @@ static void vorbis_free(vorbis_context *vc)
|
||||
|
||||
for (i = 0; i < vc->codebook_count; ++i) {
|
||||
av_free(vc->codebooks[i].codevectors);
|
||||
free_vlc(&vc->codebooks[i].vlc);
|
||||
ff_free_vlc(&vc->codebooks[i].vlc);
|
||||
}
|
||||
av_freep(&vc->codebooks);
|
||||
|
||||
@ -578,7 +578,11 @@ static int vorbis_parse_setup_hdr_floors(vorbis_context *vc)
|
||||
}
|
||||
|
||||
// Precalculate order of x coordinates - needed for decode
|
||||
ff_vorbis_ready_floor1_list(floor_setup->data.t1.list, floor_setup->data.t1.x_list_dim);
|
||||
if (ff_vorbis_ready_floor1_list(vc->avccontext,
|
||||
floor_setup->data.t1.list,
|
||||
floor_setup->data.t1.x_list_dim)) {
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
for (j=1; j<floor_setup->data.t1.x_list_dim; j++) {
|
||||
if ( floor_setup->data.t1.list[ floor_setup->data.t1.list[j-1].sort ].x
|
||||
|
@ -155,7 +155,7 @@ static int cb_lookup_vals(int lookup, int dimentions, int entries)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void ready_codebook(vorbis_enc_codebook *cb)
|
||||
static int ready_codebook(vorbis_enc_codebook *cb)
|
||||
{
|
||||
int i;
|
||||
|
||||
@ -167,6 +167,8 @@ static void ready_codebook(vorbis_enc_codebook *cb)
|
||||
int vals = cb_lookup_vals(cb->lookup, cb->ndimentions, cb->nentries);
|
||||
cb->dimentions = av_malloc(sizeof(float) * cb->nentries * cb->ndimentions);
|
||||
cb->pow2 = av_mallocz(sizeof(float) * cb->nentries);
|
||||
if (!cb->dimentions || !cb->pow2)
|
||||
return AVERROR(ENOMEM);
|
||||
for (i = 0; i < cb->nentries; i++) {
|
||||
float last = 0;
|
||||
int j;
|
||||
@ -187,13 +189,16 @@ static void ready_codebook(vorbis_enc_codebook *cb)
|
||||
cb->pow2[i] /= 2.;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void ready_residue(vorbis_enc_residue *rc, vorbis_enc_context *venc)
|
||||
static int ready_residue(vorbis_enc_residue *rc, vorbis_enc_context *venc)
|
||||
{
|
||||
int i;
|
||||
assert(rc->type == 2);
|
||||
rc->maxes = av_mallocz(sizeof(float[2]) * rc->classifications);
|
||||
if (!rc->maxes)
|
||||
return AVERROR(ENOMEM);
|
||||
for (i = 0; i < rc->classifications; i++) {
|
||||
int j;
|
||||
vorbis_enc_codebook * cb;
|
||||
@ -223,15 +228,16 @@ static void ready_residue(vorbis_enc_residue *rc, vorbis_enc_context *venc)
|
||||
rc->maxes[i][0] += 0.8;
|
||||
rc->maxes[i][1] += 0.8;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void create_vorbis_context(vorbis_enc_context *venc,
|
||||
AVCodecContext *avccontext)
|
||||
static int create_vorbis_context(vorbis_enc_context *venc,
|
||||
AVCodecContext *avccontext)
|
||||
{
|
||||
vorbis_enc_floor *fc;
|
||||
vorbis_enc_residue *rc;
|
||||
vorbis_enc_mapping *mc;
|
||||
int i, book;
|
||||
int i, book, ret;
|
||||
|
||||
venc->channels = avccontext->channels;
|
||||
venc->sample_rate = avccontext->sample_rate;
|
||||
@ -239,6 +245,8 @@ static void create_vorbis_context(vorbis_enc_context *venc,
|
||||
|
||||
venc->ncodebooks = FF_ARRAY_ELEMS(cvectors);
|
||||
venc->codebooks = av_malloc(sizeof(vorbis_enc_codebook) * venc->ncodebooks);
|
||||
if (!venc->codebooks)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
// codebook 0..14 - floor1 book, values 0..255
|
||||
// codebook 15 residue masterbook
|
||||
@ -255,27 +263,36 @@ static void create_vorbis_context(vorbis_enc_context *venc,
|
||||
|
||||
cb->lens = av_malloc(sizeof(uint8_t) * cb->nentries);
|
||||
cb->codewords = av_malloc(sizeof(uint32_t) * cb->nentries);
|
||||
if (!cb->lens || !cb->codewords)
|
||||
return AVERROR(ENOMEM);
|
||||
memcpy(cb->lens, cvectors[book].clens, cvectors[book].len);
|
||||
memset(cb->lens + cvectors[book].len, 0, cb->nentries - cvectors[book].len);
|
||||
|
||||
if (cb->lookup) {
|
||||
vals = cb_lookup_vals(cb->lookup, cb->ndimentions, cb->nentries);
|
||||
cb->quantlist = av_malloc(sizeof(int) * vals);
|
||||
if (!cb->quantlist)
|
||||
return AVERROR(ENOMEM);
|
||||
for (i = 0; i < vals; i++)
|
||||
cb->quantlist[i] = cvectors[book].quant[i];
|
||||
} else {
|
||||
cb->quantlist = NULL;
|
||||
}
|
||||
ready_codebook(cb);
|
||||
if ((ret = ready_codebook(cb)) < 0)
|
||||
return ret;
|
||||
}
|
||||
|
||||
venc->nfloors = 1;
|
||||
venc->floors = av_malloc(sizeof(vorbis_enc_floor) * venc->nfloors);
|
||||
if (!venc->floors)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
// just 1 floor
|
||||
fc = &venc->floors[0];
|
||||
fc->partitions = NUM_FLOOR_PARTITIONS;
|
||||
fc->partition_to_class = av_malloc(sizeof(int) * fc->partitions);
|
||||
if (!fc->partition_to_class)
|
||||
return AVERROR(ENOMEM);
|
||||
fc->nclasses = 0;
|
||||
for (i = 0; i < fc->partitions; i++) {
|
||||
static const int a[] = {0, 1, 2, 2, 3, 3, 4, 4};
|
||||
@ -284,6 +301,8 @@ static void create_vorbis_context(vorbis_enc_context *venc,
|
||||
}
|
||||
fc->nclasses++;
|
||||
fc->classes = av_malloc(sizeof(vorbis_enc_floor_class) * fc->nclasses);
|
||||
if (!fc->classes)
|
||||
return AVERROR(ENOMEM);
|
||||
for (i = 0; i < fc->nclasses; i++) {
|
||||
vorbis_enc_floor_class * c = &fc->classes[i];
|
||||
int j, books;
|
||||
@ -292,6 +311,8 @@ static void create_vorbis_context(vorbis_enc_context *venc,
|
||||
c->masterbook = floor_classes[i].masterbook;
|
||||
books = (1 << c->subclass);
|
||||
c->books = av_malloc(sizeof(int) * books);
|
||||
if (!c->books)
|
||||
return AVERROR(ENOMEM);
|
||||
for (j = 0; j < books; j++)
|
||||
c->books[j] = floor_classes[i].nbooks[j];
|
||||
}
|
||||
@ -303,6 +324,8 @@ static void create_vorbis_context(vorbis_enc_context *venc,
|
||||
fc->values += fc->classes[fc->partition_to_class[i]].dim;
|
||||
|
||||
fc->list = av_malloc(sizeof(vorbis_floor1_entry) * fc->values);
|
||||
if (!fc->list)
|
||||
return AVERROR(ENOMEM);
|
||||
fc->list[0].x = 0;
|
||||
fc->list[1].x = 1 << fc->rangebits;
|
||||
for (i = 2; i < fc->values; i++) {
|
||||
@ -313,10 +336,13 @@ static void create_vorbis_context(vorbis_enc_context *venc,
|
||||
};
|
||||
fc->list[i].x = a[i - 2];
|
||||
}
|
||||
ff_vorbis_ready_floor1_list(fc->list, fc->values);
|
||||
if (ff_vorbis_ready_floor1_list(avccontext, fc->list, fc->values))
|
||||
return AVERROR_BUG;
|
||||
|
||||
venc->nresidues = 1;
|
||||
venc->residues = av_malloc(sizeof(vorbis_enc_residue) * venc->nresidues);
|
||||
if (!venc->residues)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
// single residue
|
||||
rc = &venc->residues[0];
|
||||
@ -327,6 +353,8 @@ static void create_vorbis_context(vorbis_enc_context *venc,
|
||||
rc->classifications = 10;
|
||||
rc->classbook = 15;
|
||||
rc->books = av_malloc(sizeof(*rc->books) * rc->classifications);
|
||||
if (!rc->books)
|
||||
return AVERROR(ENOMEM);
|
||||
{
|
||||
static const int8_t a[10][8] = {
|
||||
{ -1, -1, -1, -1, -1, -1, -1, -1, },
|
||||
@ -342,19 +370,26 @@ static void create_vorbis_context(vorbis_enc_context *venc,
|
||||
};
|
||||
memcpy(rc->books, a, sizeof a);
|
||||
}
|
||||
ready_residue(rc, venc);
|
||||
if ((ret = ready_residue(rc, venc)) < 0)
|
||||
return ret;
|
||||
|
||||
venc->nmappings = 1;
|
||||
venc->mappings = av_malloc(sizeof(vorbis_enc_mapping) * venc->nmappings);
|
||||
if (!venc->mappings)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
// single mapping
|
||||
mc = &venc->mappings[0];
|
||||
mc->submaps = 1;
|
||||
mc->mux = av_malloc(sizeof(int) * venc->channels);
|
||||
if (!mc->mux)
|
||||
return AVERROR(ENOMEM);
|
||||
for (i = 0; i < venc->channels; i++)
|
||||
mc->mux[i] = 0;
|
||||
mc->floor = av_malloc(sizeof(int) * mc->submaps);
|
||||
mc->residue = av_malloc(sizeof(int) * mc->submaps);
|
||||
if (!mc->floor || !mc->residue)
|
||||
return AVERROR(ENOMEM);
|
||||
for (i = 0; i < mc->submaps; i++) {
|
||||
mc->floor[i] = 0;
|
||||
mc->residue[i] = 0;
|
||||
@ -362,6 +397,8 @@ static void create_vorbis_context(vorbis_enc_context *venc,
|
||||
mc->coupling_steps = venc->channels == 2 ? 1 : 0;
|
||||
mc->magnitude = av_malloc(sizeof(int) * mc->coupling_steps);
|
||||
mc->angle = av_malloc(sizeof(int) * mc->coupling_steps);
|
||||
if (!mc->magnitude || !mc->angle)
|
||||
return AVERROR(ENOMEM);
|
||||
if (mc->coupling_steps) {
|
||||
mc->magnitude[0] = 0;
|
||||
mc->angle[0] = 1;
|
||||
@ -369,6 +406,8 @@ static void create_vorbis_context(vorbis_enc_context *venc,
|
||||
|
||||
venc->nmodes = 1;
|
||||
venc->modes = av_malloc(sizeof(vorbis_enc_mode) * venc->nmodes);
|
||||
if (!venc->modes)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
// single mode
|
||||
venc->modes[0].blockflag = 0;
|
||||
@ -379,12 +418,18 @@ static void create_vorbis_context(vorbis_enc_context *venc,
|
||||
venc->samples = av_malloc(sizeof(float) * venc->channels * (1 << venc->log2_blocksize[1]));
|
||||
venc->floor = av_malloc(sizeof(float) * venc->channels * (1 << venc->log2_blocksize[1]) / 2);
|
||||
venc->coeffs = av_malloc(sizeof(float) * venc->channels * (1 << venc->log2_blocksize[1]) / 2);
|
||||
if (!venc->saved || !venc->samples || !venc->floor || !venc->coeffs)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
venc->win[0] = ff_vorbis_vwin[venc->log2_blocksize[0] - 6];
|
||||
venc->win[1] = ff_vorbis_vwin[venc->log2_blocksize[1] - 6];
|
||||
|
||||
ff_mdct_init(&venc->mdct[0], venc->log2_blocksize[0], 0, 1.0);
|
||||
ff_mdct_init(&venc->mdct[1], venc->log2_blocksize[1], 0, 1.0);
|
||||
if ((ret = ff_mdct_init(&venc->mdct[0], venc->log2_blocksize[0], 0, 1.0)) < 0)
|
||||
return ret;
|
||||
if ((ret = ff_mdct_init(&venc->mdct[1], venc->log2_blocksize[1], 0, 1.0)) < 0)
|
||||
return ret;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void put_float(PutBitContext *pb, float f)
|
||||
@ -647,6 +692,8 @@ static int put_main_header(vorbis_enc_context *venc, uint8_t **out)
|
||||
|
||||
len = hlens[0] + hlens[1] + hlens[2];
|
||||
p = *out = av_mallocz(64 + len + len/255);
|
||||
if (!p)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
*p++ = 2;
|
||||
p += av_xiphlacing(p, hlens[0]);
|
||||
@ -952,33 +999,6 @@ static int apply_window_and_mdct(vorbis_enc_context *venc, const signed short *a
|
||||
return 1;
|
||||
}
|
||||
|
||||
static av_cold int vorbis_encode_init(AVCodecContext *avccontext)
|
||||
{
|
||||
vorbis_enc_context *venc = avccontext->priv_data;
|
||||
|
||||
if (avccontext->channels != 2) {
|
||||
av_log(avccontext, AV_LOG_ERROR, "Current FFmpeg Vorbis encoder only supports 2 channels.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
create_vorbis_context(venc, avccontext);
|
||||
|
||||
if (avccontext->flags & CODEC_FLAG_QSCALE)
|
||||
venc->quality = avccontext->global_quality / (float)FF_QP2LAMBDA / 10.;
|
||||
else
|
||||
venc->quality = 0.03;
|
||||
venc->quality *= venc->quality;
|
||||
|
||||
avccontext->extradata_size = put_main_header(venc, (uint8_t**)&avccontext->extradata);
|
||||
|
||||
avccontext->frame_size = 1 << (venc->log2_blocksize[0] - 1);
|
||||
|
||||
avccontext->coded_frame = avcodec_alloc_frame();
|
||||
avccontext->coded_frame->key_frame = 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int vorbis_encode_frame(AVCodecContext *avccontext,
|
||||
unsigned char *packets,
|
||||
int buf_size, void *data)
|
||||
@ -1102,6 +1122,43 @@ static av_cold int vorbis_encode_close(AVCodecContext *avccontext)
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
static av_cold int vorbis_encode_init(AVCodecContext *avccontext)
|
||||
{
|
||||
vorbis_enc_context *venc = avccontext->priv_data;
|
||||
int ret;
|
||||
|
||||
if (avccontext->channels != 2) {
|
||||
av_log(avccontext, AV_LOG_ERROR, "Current FFmpeg Vorbis encoder only supports 2 channels.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((ret = create_vorbis_context(venc, avccontext)) < 0)
|
||||
goto error;
|
||||
|
||||
if (avccontext->flags & CODEC_FLAG_QSCALE)
|
||||
venc->quality = avccontext->global_quality / (float)FF_QP2LAMBDA / 10.;
|
||||
else
|
||||
venc->quality = 0.03;
|
||||
venc->quality *= venc->quality;
|
||||
|
||||
if ((ret = put_main_header(venc, (uint8_t**)&avccontext->extradata)) < 0)
|
||||
goto error;
|
||||
avccontext->extradata_size = ret;
|
||||
|
||||
avccontext->frame_size = 1 << (venc->log2_blocksize[0] - 1);
|
||||
|
||||
avccontext->coded_frame = avcodec_alloc_frame();
|
||||
if (!avccontext->coded_frame) {
|
||||
ret = AVERROR(ENOMEM);
|
||||
goto error;
|
||||
}
|
||||
|
||||
return 0;
|
||||
error:
|
||||
vorbis_encode_close(avccontext);
|
||||
return ret;
|
||||
}
|
||||
|
||||
AVCodec ff_vorbis_encoder = {
|
||||
.name = "vorbis",
|
||||
.type = AVMEDIA_TYPE_AUDIO,
|
||||
|
@ -292,17 +292,17 @@ static av_cold int vp3_decode_end(AVCodecContext *avctx)
|
||||
return 0;
|
||||
|
||||
for (i = 0; i < 16; i++) {
|
||||
free_vlc(&s->dc_vlc[i]);
|
||||
free_vlc(&s->ac_vlc_1[i]);
|
||||
free_vlc(&s->ac_vlc_2[i]);
|
||||
free_vlc(&s->ac_vlc_3[i]);
|
||||
free_vlc(&s->ac_vlc_4[i]);
|
||||
ff_free_vlc(&s->dc_vlc[i]);
|
||||
ff_free_vlc(&s->ac_vlc_1[i]);
|
||||
ff_free_vlc(&s->ac_vlc_2[i]);
|
||||
ff_free_vlc(&s->ac_vlc_3[i]);
|
||||
ff_free_vlc(&s->ac_vlc_4[i]);
|
||||
}
|
||||
|
||||
free_vlc(&s->superblock_run_length_vlc);
|
||||
free_vlc(&s->fragment_run_length_vlc);
|
||||
free_vlc(&s->mode_code_vlc);
|
||||
free_vlc(&s->motion_vector_vlc);
|
||||
ff_free_vlc(&s->superblock_run_length_vlc);
|
||||
ff_free_vlc(&s->fragment_run_length_vlc);
|
||||
ff_free_vlc(&s->mode_code_vlc);
|
||||
ff_free_vlc(&s->motion_vector_vlc);
|
||||
|
||||
/* release all frames */
|
||||
vp3_decode_flush(avctx);
|
||||
|
@ -237,7 +237,7 @@ static int vp6_build_huff_tree(VP56Context *s, uint8_t coeff_model[],
|
||||
nodes[map[2*i+1]].count = b + !b;
|
||||
}
|
||||
|
||||
free_vlc(vlc);
|
||||
ff_free_vlc(vlc);
|
||||
/* then build the huffman tree according to probabilities */
|
||||
return ff_huff_build_tree(s->avctx, vlc, size, nodes, vp6_huff_cmp,
|
||||
FF_HUFFMAN_FLAG_HNODE_FIRST);
|
||||
@ -615,11 +615,11 @@ static av_cold int vp6_decode_free(AVCodecContext *avctx)
|
||||
ff_vp56_free(avctx);
|
||||
|
||||
for (pt=0; pt<2; pt++) {
|
||||
free_vlc(&s->dccv_vlc[pt]);
|
||||
free_vlc(&s->runv_vlc[pt]);
|
||||
ff_free_vlc(&s->dccv_vlc[pt]);
|
||||
ff_free_vlc(&s->runv_vlc[pt]);
|
||||
for (ct=0; ct<3; ct++)
|
||||
for (cg=0; cg<6; cg++)
|
||||
free_vlc(&s->ract_vlc[pt][ct][cg]);
|
||||
ff_free_vlc(&s->ract_vlc[pt][ct][cg]);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -417,13 +417,13 @@ int ff_wma_end(AVCodecContext *avctx)
|
||||
ff_mdct_end(&s->mdct_ctx[i]);
|
||||
|
||||
if (s->use_exp_vlc) {
|
||||
free_vlc(&s->exp_vlc);
|
||||
ff_free_vlc(&s->exp_vlc);
|
||||
}
|
||||
if (s->use_noise_coding) {
|
||||
free_vlc(&s->hgain_vlc);
|
||||
ff_free_vlc(&s->hgain_vlc);
|
||||
}
|
||||
for (i = 0; i < 2; i++) {
|
||||
free_vlc(&s->coef_vlc[i]);
|
||||
ff_free_vlc(&s->coef_vlc[i]);
|
||||
av_free(s->run_table[i]);
|
||||
av_free(s->level_table[i]);
|
||||
av_free(s->int_table[i]);
|
||||
|
@ -171,7 +171,7 @@ void ff_wmv2_encode_mb(MpegEncContext * s,
|
||||
wmv2_inter_table[w->cbp_table_index][cbp + 64][0]);
|
||||
|
||||
/* motion vector */
|
||||
h263_pred_motion(s, 0, 0, &pred_x, &pred_y);
|
||||
ff_h263_pred_motion(s, 0, 0, &pred_x, &pred_y);
|
||||
ff_msmpeg4_encode_motion(s, motion_x - pred_x,
|
||||
motion_y - pred_y);
|
||||
} else {
|
||||
|
@ -49,6 +49,9 @@ AVFilterFormats *avfilter_merge_formats(AVFilterFormats *a, AVFilterFormats *b)
|
||||
|
||||
if (a == b) return a;
|
||||
|
||||
if (a == b)
|
||||
return a;
|
||||
|
||||
ret = av_mallocz(sizeof(AVFilterFormats));
|
||||
|
||||
/* merge list of formats */
|
||||
|
@ -687,7 +687,7 @@ int avformat_open_input(AVFormatContext **ps, const char *filename, AVInputForma
|
||||
}
|
||||
|
||||
s->duration = s->start_time = AV_NOPTS_VALUE;
|
||||
av_strlcpy(s->filename, filename, sizeof(s->filename));
|
||||
av_strlcpy(s->filename, filename ? filename : "", sizeof(s->filename));
|
||||
|
||||
/* allocate private data */
|
||||
if (s->iformat->priv_data_size > 0) {
|
||||
|
@ -312,8 +312,8 @@ static int parse_primary(AVExpr **e, Parser *p)
|
||||
else if (strmatch(next, "eq" )) d->type = e_eq;
|
||||
else if (strmatch(next, "gte" )) d->type = e_gte;
|
||||
else if (strmatch(next, "gt" )) d->type = e_gt;
|
||||
else if (strmatch(next, "lte" )) { AVExpr *tmp = d->param[1]; d->param[1] = d->param[0]; d->param[0] = tmp; d->type = e_gt; }
|
||||
else if (strmatch(next, "lt" )) { AVExpr *tmp = d->param[1]; d->param[1] = d->param[0]; d->param[0] = tmp; d->type = e_gte; }
|
||||
else if (strmatch(next, "lte" )) { AVExpr *tmp = d->param[1]; d->param[1] = d->param[0]; d->param[0] = tmp; d->type = e_gte; }
|
||||
else if (strmatch(next, "lt" )) { AVExpr *tmp = d->param[1]; d->param[1] = d->param[0]; d->param[0] = tmp; d->type = e_gt; }
|
||||
else if (strmatch(next, "ld" )) d->type = e_ld;
|
||||
else if (strmatch(next, "isnan" )) d->type = e_isnan;
|
||||
else if (strmatch(next, "st" )) d->type = e_st;
|
||||
|
@ -95,16 +95,16 @@ Evaluating 'st(1, 123); ld(1)'
|
||||
'st(1, 123); ld(1)' -> 123.000000
|
||||
|
||||
Evaluating 'st(0, 1); while(lte(ld(0), 100), st(1, ld(1)+ld(0));st(0, ld(0)+1)); ld(1)'
|
||||
'st(0, 1); while(lte(ld(0), 100), st(1, ld(1)+ld(0));st(0, ld(0)+1)); ld(1)' -> 4950.000000
|
||||
'st(0, 1); while(lte(ld(0), 100), st(1, ld(1)+ld(0));st(0, ld(0)+1)); ld(1)' -> 5050.000000
|
||||
|
||||
Evaluating 'st(1, 1); st(2, 2); st(0, 1); while(lte(ld(0),10), st(3, ld(1)+ld(2)); st(1, ld(2)); st(2, ld(3)); st(0, ld(0)+1)); ld(3)'
|
||||
'st(1, 1); st(2, 2); st(0, 1); while(lte(ld(0),10), st(3, ld(1)+ld(2)); st(1, ld(2)); st(2, ld(3)); st(0, ld(0)+1)); ld(3)' -> 144.000000
|
||||
'st(1, 1); st(2, 2); st(0, 1); while(lte(ld(0),10), st(3, ld(1)+ld(2)); st(1, ld(2)); st(2, ld(3)); st(0, ld(0)+1)); ld(3)' -> 233.000000
|
||||
|
||||
Evaluating 'while(0, 10)'
|
||||
'while(0, 10)' -> nan
|
||||
|
||||
Evaluating 'st(0, 1); while(lte(ld(0),100), st(1, ld(1)+ld(0)); st(0, ld(0)+1))'
|
||||
'st(0, 1); while(lte(ld(0),100), st(1, ld(1)+ld(0)); st(0, ld(0)+1))' -> 100.000000
|
||||
'st(0, 1); while(lte(ld(0),100), st(1, ld(1)+ld(0)); st(0, ld(0)+1))' -> 101.000000
|
||||
|
||||
Evaluating 'isnan(1)'
|
||||
'isnan(1)' -> 0.000000
|
||||
|
Loading…
x
Reference in New Issue
Block a user