1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

Merge remote-tracking branch 'qatar/master'

* qatar/master: (29 commits)
  amrwb: remove duplicate arguments from extrapolate_isf().
  amrwb: error out early if mode is invalid.
  h264: change underread for 10bit QPEL to overread.
  matroska: check buffer size for RM-style byte reordering.
  vp8: disable mmx functions with sse/sse2 counterparts on x86-64.
  vp8: change int stride to ptrdiff_t stride.
  wma: fix invalid buffer size assumptions causing random overreads.
  Windows Media Audio Lossless decoder
  rv10/20: Fix slice overflow with checked bitstream reader.
  h263dec: Disallow width/height changing with frame threads.
  rv10/20: Fix a buffer overread caused by losing track of the remaining buffer size.
  rmdec: Honor .RMF tag size rather than assuming 18.
  g722: Fix the QMF scaling
  r3d: don't set codec timebase.
  electronicarts: set timebase for tgv video.
  electronicarts: parse the framerate for cmv video.
  ogg: don't set codec timebase
  electronicarts: don't set codec timebase
  avs: don't set codec timebase
  wavpack: Fix an integer overflow
  ...

Conflicts:
	libavcodec/arm/vp8dsp_init_arm.c
	libavcodec/fraps.c
	libavcodec/h264.c
	libavcodec/mpeg4videodec.c
	libavcodec/mpegvideo.c
	libavcodec/msmpeg4.c
	libavcodec/pnmdec.c
	libavcodec/qpeg.c
	libavcodec/rawenc.c
	libavcodec/ulti.c
	libavcodec/vcr1.c
	libavcodec/version.h
	libavcodec/wmalosslessdec.c
	libavformat/electronicarts.c
	libswscale/ppc/yuv2rgb_altivec.c
	tests/ref/acodec/g722
	tests/ref/fate/ea-cmv

Merged-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Michael Niedermayer 2012-03-03 00:09:47 +01:00
commit 268098d8b2
80 changed files with 2353 additions and 2460 deletions

View File

@ -9,6 +9,7 @@ version next:
- ffprobe -count_packets and -count_frames options - ffprobe -count_packets and -count_frames options
- Sun Rasterfile Encoder - Sun Rasterfile Encoder
- ID3v2 attached pictures reading and writing - ID3v2 attached pictures reading and writing
- WMA Lossless decoder
version 0.10: version 0.10:

View File

@ -811,6 +811,7 @@ following image formats are supported:
@item Westwood Audio (SND1) @tab @tab X @item Westwood Audio (SND1) @tab @tab X
@item Windows Media Audio 1 @tab X @tab X @item Windows Media Audio 1 @tab X @tab X
@item Windows Media Audio 2 @tab X @tab X @item Windows Media Audio 2 @tab X @tab X
@item Windows Media Audio Lossless @tab @tab X
@item Windows Media Audio Pro @tab @tab X @item Windows Media Audio Pro @tab @tab X
@item Windows Media Audio Voice @tab @tab X @item Windows Media Audio Voice @tab @tab X
@end multitable @end multitable

View File

@ -299,12 +299,14 @@ OBJS-$(CONFIG_MPEG4_VAAPI_HWACCEL) += vaapi_mpeg4.o
OBJS-$(CONFIG_MSMPEG4V1_DECODER) += msmpeg4.o msmpeg4data.o OBJS-$(CONFIG_MSMPEG4V1_DECODER) += msmpeg4.o msmpeg4data.o
OBJS-$(CONFIG_MSMPEG4V2_DECODER) += msmpeg4.o msmpeg4data.o h263dec.o \ OBJS-$(CONFIG_MSMPEG4V2_DECODER) += msmpeg4.o msmpeg4data.o h263dec.o \
h263.o ituh263dec.o mpeg4videodec.o h263.o ituh263dec.o mpeg4videodec.o
OBJS-$(CONFIG_MSMPEG4V2_ENCODER) += msmpeg4.o msmpeg4data.o h263dec.o \ OBJS-$(CONFIG_MSMPEG4V2_ENCODER) += msmpeg4.o msmpeg4enc.o msmpeg4data.o \
h263.o ituh263dec.o mpeg4videodec.o h263dec.o h263.o ituh263dec.o \
mpeg4videodec.o
OBJS-$(CONFIG_MSMPEG4V3_DECODER) += msmpeg4.o msmpeg4data.o h263dec.o \ OBJS-$(CONFIG_MSMPEG4V3_DECODER) += msmpeg4.o msmpeg4data.o h263dec.o \
h263.o ituh263dec.o mpeg4videodec.o h263.o ituh263dec.o mpeg4videodec.o
OBJS-$(CONFIG_MSMPEG4V3_ENCODER) += msmpeg4.o msmpeg4data.o h263dec.o \ OBJS-$(CONFIG_MSMPEG4V3_ENCODER) += msmpeg4.o msmpeg4enc.o msmpeg4data.o \
h263.o ituh263dec.o mpeg4videodec.o h263dec.o h263.o ituh263dec.o \
mpeg4videodec.o
OBJS-$(CONFIG_MSRLE_DECODER) += msrle.o msrledec.o OBJS-$(CONFIG_MSRLE_DECODER) += msrle.o msrledec.o
OBJS-$(CONFIG_MSVIDEO1_DECODER) += msvideo1.o OBJS-$(CONFIG_MSVIDEO1_DECODER) += msvideo1.o
OBJS-$(CONFIG_MSVIDEO1_ENCODER) += msvideo1enc.o elbg.o OBJS-$(CONFIG_MSVIDEO1_ENCODER) += msvideo1enc.o elbg.o
@ -471,7 +473,7 @@ OBJS-$(CONFIG_WMV2_DECODER) += wmv2dec.o wmv2.o \
msmpeg4.o msmpeg4data.o \ msmpeg4.o msmpeg4data.o \
intrax8.o intrax8dsp.o intrax8.o intrax8dsp.o
OBJS-$(CONFIG_WMV2_ENCODER) += wmv2enc.o wmv2.o \ OBJS-$(CONFIG_WMV2_ENCODER) += wmv2enc.o wmv2.o \
msmpeg4.o msmpeg4data.o \ msmpeg4.o msmpeg4enc.o msmpeg4data.o \
mpeg4videodec.o ituh263dec.o h263dec.o mpeg4videodec.o ituh263dec.o h263dec.o
OBJS-$(CONFIG_WNV1_DECODER) += wnv1.o OBJS-$(CONFIG_WNV1_DECODER) += wnv1.o
OBJS-$(CONFIG_WS_SND1_DECODER) += ws-snd1.o OBJS-$(CONFIG_WS_SND1_DECODER) += ws-snd1.o

View File

@ -246,7 +246,7 @@ static int a64multi_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
const AVFrame *pict, int *got_packet) const AVFrame *pict, int *got_packet)
{ {
A64Context *c = avctx->priv_data; A64Context *c = avctx->priv_data;
AVFrame *const p = (AVFrame *) & c->picture; AVFrame *const p = &c->picture;
int frame; int frame;
int x, y; int x, y;

View File

@ -898,10 +898,10 @@ static float auto_correlation(float *diff_isf, float mean, int lag)
* Extrapolate a ISF vector to the 16kHz range (20th order LP) * Extrapolate a ISF vector to the 16kHz range (20th order LP)
* used at mode 6k60 LP filter for the high frequency band. * used at mode 6k60 LP filter for the high frequency band.
* *
* @param[out] out Buffer for extrapolated isf * @param[out] isf Buffer for extrapolated isf; contains LP_ORDER
* @param[in] isf Input isf vector * values on input
*/ */
static void extrapolate_isf(float out[LP_ORDER_16k], float isf[LP_ORDER]) static void extrapolate_isf(float isf[LP_ORDER_16k])
{ {
float diff_isf[LP_ORDER - 2], diff_mean; float diff_isf[LP_ORDER - 2], diff_mean;
float *diff_hi = diff_isf - LP_ORDER + 1; // diff array for extrapolated indexes float *diff_hi = diff_isf - LP_ORDER + 1; // diff array for extrapolated indexes
@ -909,8 +909,7 @@ static void extrapolate_isf(float out[LP_ORDER_16k], float isf[LP_ORDER])
float est, scale; float est, scale;
int i, i_max_corr; int i, i_max_corr;
memcpy(out, isf, (LP_ORDER - 1) * sizeof(float)); isf[LP_ORDER_16k - 1] = isf[LP_ORDER - 1];
out[LP_ORDER_16k - 1] = isf[LP_ORDER - 1];
/* Calculate the difference vector */ /* Calculate the difference vector */
for (i = 0; i < LP_ORDER - 2; i++) for (i = 0; i < LP_ORDER - 2; i++)
@ -931,16 +930,16 @@ static void extrapolate_isf(float out[LP_ORDER_16k], float isf[LP_ORDER])
i_max_corr++; i_max_corr++;
for (i = LP_ORDER - 1; i < LP_ORDER_16k - 1; i++) for (i = LP_ORDER - 1; i < LP_ORDER_16k - 1; i++)
out[i] = isf[i - 1] + isf[i - 1 - i_max_corr] isf[i] = isf[i - 1] + isf[i - 1 - i_max_corr]
- isf[i - 2 - i_max_corr]; - isf[i - 2 - i_max_corr];
/* Calculate an estimate for ISF(18) and scale ISF based on the error */ /* Calculate an estimate for ISF(18) and scale ISF based on the error */
est = 7965 + (out[2] - out[3] - out[4]) / 6.0; est = 7965 + (isf[2] - isf[3] - isf[4]) / 6.0;
scale = 0.5 * (FFMIN(est, 7600) - out[LP_ORDER - 2]) / scale = 0.5 * (FFMIN(est, 7600) - isf[LP_ORDER - 2]) /
(out[LP_ORDER_16k - 2] - out[LP_ORDER - 2]); (isf[LP_ORDER_16k - 2] - isf[LP_ORDER - 2]);
for (i = LP_ORDER - 1; i < LP_ORDER_16k - 1; i++) for (i = LP_ORDER - 1; i < LP_ORDER_16k - 1; i++)
diff_hi[i] = scale * (out[i] - out[i - 1]); diff_hi[i] = scale * (isf[i] - isf[i - 1]);
/* Stability insurance */ /* Stability insurance */
for (i = LP_ORDER; i < LP_ORDER_16k - 1; i++) for (i = LP_ORDER; i < LP_ORDER_16k - 1; i++)
@ -952,11 +951,11 @@ static void extrapolate_isf(float out[LP_ORDER_16k], float isf[LP_ORDER])
} }
for (i = LP_ORDER - 1; i < LP_ORDER_16k - 1; i++) for (i = LP_ORDER - 1; i < LP_ORDER_16k - 1; i++)
out[i] = out[i - 1] + diff_hi[i] * (1.0f / (1 << 15)); isf[i] = isf[i - 1] + diff_hi[i] * (1.0f / (1 << 15));
/* Scale the ISF vector for 16000 Hz */ /* Scale the ISF vector for 16000 Hz */
for (i = 0; i < LP_ORDER_16k - 1; i++) for (i = 0; i < LP_ORDER_16k - 1; i++)
out[i] *= 0.8; isf[i] *= 0.8;
} }
/** /**
@ -1003,7 +1002,7 @@ static void hb_synthesis(AMRWBContext *ctx, int subframe, float *samples,
ff_weighted_vector_sumf(e_isf, isf_past, isf, isfp_inter[subframe], ff_weighted_vector_sumf(e_isf, isf_past, isf, isfp_inter[subframe],
1.0 - isfp_inter[subframe], LP_ORDER); 1.0 - isfp_inter[subframe], LP_ORDER);
extrapolate_isf(e_isf, e_isf); extrapolate_isf(e_isf);
e_isf[LP_ORDER_16k - 1] *= 2.0; e_isf[LP_ORDER_16k - 1] *= 2.0;
ff_acelp_lsf2lspd(e_isp, e_isf, LP_ORDER_16k); ff_acelp_lsf2lspd(e_isp, e_isf, LP_ORDER_16k);
@ -1095,23 +1094,27 @@ static int amrwb_decode_frame(AVCodecContext *avctx, void *data,
buf_out = (float *)ctx->avframe.data[0]; buf_out = (float *)ctx->avframe.data[0];
header_size = decode_mime_header(ctx, buf); header_size = decode_mime_header(ctx, buf);
if (ctx->fr_cur_mode > MODE_SID) {
av_log(avctx, AV_LOG_ERROR,
"Invalid mode %d\n", ctx->fr_cur_mode);
return AVERROR_INVALIDDATA;
}
expected_fr_size = ((cf_sizes_wb[ctx->fr_cur_mode] + 7) >> 3) + 1; expected_fr_size = ((cf_sizes_wb[ctx->fr_cur_mode] + 7) >> 3) + 1;
if (buf_size < expected_fr_size) { if (buf_size < expected_fr_size) {
av_log(avctx, AV_LOG_ERROR, av_log(avctx, AV_LOG_ERROR,
"Frame too small (%d bytes). Truncated file?\n", buf_size); "Frame too small (%d bytes). Truncated file?\n", buf_size);
*got_frame_ptr = 0; *got_frame_ptr = 0;
return buf_size; return AVERROR_INVALIDDATA;
} }
if (!ctx->fr_quality || ctx->fr_cur_mode > MODE_SID) if (!ctx->fr_quality || ctx->fr_cur_mode > MODE_SID)
av_log(avctx, AV_LOG_ERROR, "Encountered a bad or corrupted frame\n"); av_log(avctx, AV_LOG_ERROR, "Encountered a bad or corrupted frame\n");
if (ctx->fr_cur_mode == MODE_SID) /* Comfort noise frame */ if (ctx->fr_cur_mode == MODE_SID) { /* Comfort noise frame */
av_log_missing_feature(avctx, "SID mode", 1); av_log_missing_feature(avctx, "SID mode", 1);
if (ctx->fr_cur_mode >= MODE_SID)
return -1; return -1;
}
ff_amr_bit_reorder((uint16_t *) &ctx->frame, sizeof(AMRWBFrame), ff_amr_bit_reorder((uint16_t *) &ctx->frame, sizeof(AMRWBFrame),
buf + header_size, amr_bit_orderings_by_mode[ctx->fr_cur_mode]); buf + header_size, amr_bit_orderings_by_mode[ctx->fr_cur_mode]);

View File

@ -23,87 +23,87 @@ void ff_vp8_luma_dc_wht_dc_armv6(DCTELEM block[4][4][16], DCTELEM dc[16]);
#define idct_funcs(opt) \ #define idct_funcs(opt) \
void ff_vp8_luma_dc_wht_ ## opt(DCTELEM block[4][4][16], DCTELEM dc[16]); \ void ff_vp8_luma_dc_wht_ ## opt(DCTELEM block[4][4][16], DCTELEM dc[16]); \
void ff_vp8_idct_add_ ## opt(uint8_t *dst, DCTELEM block[16], int stride); \ void ff_vp8_idct_add_ ## opt(uint8_t *dst, DCTELEM block[16], ptrdiff_t stride); \
void ff_vp8_idct_dc_add_ ## opt(uint8_t *dst, DCTELEM block[16], int stride); \ void ff_vp8_idct_dc_add_ ## opt(uint8_t *dst, DCTELEM block[16], ptrdiff_t stride); \
void ff_vp8_idct_dc_add4y_ ## opt(uint8_t *dst, DCTELEM block[4][16], int stride); \ void ff_vp8_idct_dc_add4y_ ## opt(uint8_t *dst, DCTELEM block[4][16], ptrdiff_t stride); \
void ff_vp8_idct_dc_add4uv_ ## opt(uint8_t *dst, DCTELEM block[4][16], int stride) void ff_vp8_idct_dc_add4uv_ ## opt(uint8_t *dst, DCTELEM block[4][16], ptrdiff_t stride)
idct_funcs(neon); idct_funcs(neon);
idct_funcs(armv6); idct_funcs(armv6);
void ff_vp8_v_loop_filter16_neon(uint8_t *dst, int stride, void ff_vp8_v_loop_filter16_neon(uint8_t *dst, ptrdiff_t stride,
int flim_E, int flim_I, int hev_thresh); int flim_E, int flim_I, int hev_thresh);
void ff_vp8_h_loop_filter16_neon(uint8_t *dst, int stride, void ff_vp8_h_loop_filter16_neon(uint8_t *dst, ptrdiff_t stride,
int flim_E, int flim_I, int hev_thresh); int flim_E, int flim_I, int hev_thresh);
void ff_vp8_v_loop_filter8uv_neon(uint8_t *dstU, uint8_t *dstV, int stride, void ff_vp8_v_loop_filter8uv_neon(uint8_t *dstU, uint8_t *dstV, ptrdiff_t stride,
int flim_E, int flim_I, int hev_thresh); int flim_E, int flim_I, int hev_thresh);
void ff_vp8_h_loop_filter8uv_neon(uint8_t *dstU, uint8_t *dstV, int stride, void ff_vp8_h_loop_filter8uv_neon(uint8_t *dstU, uint8_t *dstV, ptrdiff_t stride,
int flim_E, int flim_I, int hev_thresh); int flim_E, int flim_I, int hev_thresh);
void ff_vp8_v_loop_filter16_inner_neon(uint8_t *dst, int stride, void ff_vp8_v_loop_filter16_inner_neon(uint8_t *dst, ptrdiff_t stride,
int flim_E, int flim_I, int hev_thresh); int flim_E, int flim_I, int hev_thresh);
void ff_vp8_h_loop_filter16_inner_neon(uint8_t *dst, int stride, void ff_vp8_h_loop_filter16_inner_neon(uint8_t *dst, ptrdiff_t stride,
int flim_E, int flim_I, int hev_thresh); int flim_E, int flim_I, int hev_thresh);
void ff_vp8_v_loop_filter8uv_inner_neon(uint8_t *dstU, uint8_t *dstV, void ff_vp8_v_loop_filter8uv_inner_neon(uint8_t *dstU, uint8_t *dstV,
int stride, int flim_E, int flim_I, ptrdiff_t stride, int flim_E, int flim_I,
int hev_thresh); int hev_thresh);
void ff_vp8_h_loop_filter8uv_inner_neon(uint8_t *dstU, uint8_t *dstV, void ff_vp8_h_loop_filter8uv_inner_neon(uint8_t *dstU, uint8_t *dstV,
int stride, int flim_E, int flim_I, ptrdiff_t stride, int flim_E, int flim_I,
int hev_thresh); int hev_thresh);
void ff_vp8_v_loop_filter_inner_armv6(uint8_t *dst, int stride, void ff_vp8_v_loop_filter_inner_armv6(uint8_t *dst, ptrdiff_t stride,
int flim_E, int flim_I, int flim_E, int flim_I,
int hev_thresh, int count); int hev_thresh, int count);
void ff_vp8_h_loop_filter_inner_armv6(uint8_t *dst, int stride, void ff_vp8_h_loop_filter_inner_armv6(uint8_t *dst, ptrdiff_t stride,
int flim_E, int flim_I, int flim_E, int flim_I,
int hev_thresh, int count); int hev_thresh, int count);
void ff_vp8_v_loop_filter_armv6(uint8_t *dst, int stride, void ff_vp8_v_loop_filter_armv6(uint8_t *dst, ptrdiff_t stride,
int flim_E, int flim_I, int flim_E, int flim_I,
int hev_thresh, int count); int hev_thresh, int count);
void ff_vp8_h_loop_filter_armv6(uint8_t *dst, int stride, void ff_vp8_h_loop_filter_armv6(uint8_t *dst, ptrdiff_t stride,
int flim_E, int flim_I, int flim_E, int flim_I,
int hev_thresh, int count); int hev_thresh, int count);
static void ff_vp8_v_loop_filter16_armv6(uint8_t *dst, int stride, static void ff_vp8_v_loop_filter16_armv6(uint8_t *dst, ptrdiff_t stride,
int flim_E, int flim_I, int hev_thresh) int flim_E, int flim_I, int hev_thresh)
{ {
ff_vp8_v_loop_filter_armv6(dst, stride, flim_E, flim_I, hev_thresh, 4); ff_vp8_v_loop_filter_armv6(dst, stride, flim_E, flim_I, hev_thresh, 4);
} }
static void ff_vp8_h_loop_filter16_armv6(uint8_t *dst, int stride, static void ff_vp8_h_loop_filter16_armv6(uint8_t *dst, ptrdiff_t stride,
int flim_E, int flim_I, int hev_thresh) int flim_E, int flim_I, int hev_thresh)
{ {
ff_vp8_h_loop_filter_armv6(dst, stride, flim_E, flim_I, hev_thresh, 4); ff_vp8_h_loop_filter_armv6(dst, stride, flim_E, flim_I, hev_thresh, 4);
} }
static void ff_vp8_v_loop_filter8uv_armv6(uint8_t *dstU, uint8_t *dstV, int stride, static void ff_vp8_v_loop_filter8uv_armv6(uint8_t *dstU, uint8_t *dstV, ptrdiff_t stride,
int flim_E, int flim_I, int hev_thresh) int flim_E, int flim_I, int hev_thresh)
{ {
ff_vp8_v_loop_filter_armv6(dstU, stride, flim_E, flim_I, hev_thresh, 2); ff_vp8_v_loop_filter_armv6(dstU, stride, flim_E, flim_I, hev_thresh, 2);
ff_vp8_v_loop_filter_armv6(dstV, stride, flim_E, flim_I, hev_thresh, 2); ff_vp8_v_loop_filter_armv6(dstV, stride, flim_E, flim_I, hev_thresh, 2);
} }
static void ff_vp8_h_loop_filter8uv_armv6(uint8_t *dstU, uint8_t *dstV, int stride, static void ff_vp8_h_loop_filter8uv_armv6(uint8_t *dstU, uint8_t *dstV, ptrdiff_t stride,
int flim_E, int flim_I, int hev_thresh) int flim_E, int flim_I, int hev_thresh)
{ {
ff_vp8_h_loop_filter_armv6(dstU, stride, flim_E, flim_I, hev_thresh, 2); ff_vp8_h_loop_filter_armv6(dstU, stride, flim_E, flim_I, hev_thresh, 2);
ff_vp8_h_loop_filter_armv6(dstV, stride, flim_E, flim_I, hev_thresh, 2); ff_vp8_h_loop_filter_armv6(dstV, stride, flim_E, flim_I, hev_thresh, 2);
} }
static void ff_vp8_v_loop_filter16_inner_armv6(uint8_t *dst, int stride, static void ff_vp8_v_loop_filter16_inner_armv6(uint8_t *dst, ptrdiff_t stride,
int flim_E, int flim_I, int hev_thresh) int flim_E, int flim_I, int hev_thresh)
{ {
ff_vp8_v_loop_filter_inner_armv6(dst, stride, flim_E, flim_I, hev_thresh, 4); ff_vp8_v_loop_filter_inner_armv6(dst, stride, flim_E, flim_I, hev_thresh, 4);
} }
static void ff_vp8_h_loop_filter16_inner_armv6(uint8_t *dst, int stride, static void ff_vp8_h_loop_filter16_inner_armv6(uint8_t *dst, ptrdiff_t stride,
int flim_E, int flim_I, int hev_thresh) int flim_E, int flim_I, int hev_thresh)
{ {
ff_vp8_h_loop_filter_inner_armv6(dst, stride, flim_E, flim_I, hev_thresh, 4); ff_vp8_h_loop_filter_inner_armv6(dst, stride, flim_E, flim_I, hev_thresh, 4);
} }
static void ff_vp8_v_loop_filter8uv_inner_armv6(uint8_t *dstU, uint8_t *dstV, static void ff_vp8_v_loop_filter8uv_inner_armv6(uint8_t *dstU, uint8_t *dstV,
int stride, int flim_E, int flim_I, ptrdiff_t stride, int flim_E, int flim_I,
int hev_thresh) int hev_thresh)
{ {
ff_vp8_v_loop_filter_inner_armv6(dstU, stride, flim_E, flim_I, hev_thresh, 2); ff_vp8_v_loop_filter_inner_armv6(dstU, stride, flim_E, flim_I, hev_thresh, 2);
@ -111,7 +111,7 @@ static void ff_vp8_v_loop_filter8uv_inner_armv6(uint8_t *dstU, uint8_t *dstV,
} }
static void ff_vp8_h_loop_filter8uv_inner_armv6(uint8_t *dstU, uint8_t *dstV, static void ff_vp8_h_loop_filter8uv_inner_armv6(uint8_t *dstU, uint8_t *dstV,
int stride, int flim_E, int flim_I, ptrdiff_t stride, int flim_E, int flim_I,
int hev_thresh) int hev_thresh)
{ {
ff_vp8_h_loop_filter_inner_armv6(dstU, stride, flim_E, flim_I, hev_thresh, 2); ff_vp8_h_loop_filter_inner_armv6(dstU, stride, flim_E, flim_I, hev_thresh, 2);
@ -119,16 +119,16 @@ static void ff_vp8_h_loop_filter8uv_inner_armv6(uint8_t *dstU, uint8_t *dstV,
} }
#define simple_lf_funcs(opt) \ #define simple_lf_funcs(opt) \
void ff_vp8_v_loop_filter16_simple_ ## opt(uint8_t *dst, int stride, int flim); \ void ff_vp8_v_loop_filter16_simple_ ## opt(uint8_t *dst, ptrdiff_t stride, int flim); \
void ff_vp8_h_loop_filter16_simple_ ## opt(uint8_t *dst, int stride, int flim) void ff_vp8_h_loop_filter16_simple_ ## opt(uint8_t *dst, ptrdiff_t stride, int flim)
simple_lf_funcs(neon); simple_lf_funcs(neon);
simple_lf_funcs(armv6); simple_lf_funcs(armv6);
#define VP8_MC_OPT(n, opt) \ #define VP8_MC(n) \
void ff_put_vp8_##n##_##opt(uint8_t *dst, int dststride, \ void ff_put_vp8_##n##_neon(uint8_t *dst, ptrdiff_t dststride, \
uint8_t *src, int srcstride, \ uint8_t *src, ptrdiff_t srcstride, \
int h, int x, int y) int h, int x, int y)
#define VP8_MC(n) \ #define VP8_MC(n) \
VP8_MC_OPT(n, neon) VP8_MC_OPT(n, neon)

View File

@ -454,7 +454,7 @@ static int decode_frame(AVCodecContext *avctx,
} }
} }
*picture= *(AVFrame*)&a->picture; *picture = a->picture;
*data_size = sizeof(AVPicture); *data_size = sizeof(AVPicture);
emms_c(); emms_c();

View File

@ -51,7 +51,7 @@ avs_decode_frame(AVCodecContext * avctx,
int buf_size = avpkt->size; int buf_size = avpkt->size;
AvsContext *const avs = avctx->priv_data; AvsContext *const avs = avctx->priv_data;
AVFrame *picture = data; AVFrame *picture = data;
AVFrame *const p = (AVFrame *) & avs->picture; AVFrame *const p = &avs->picture;
const uint8_t *table, *vect; const uint8_t *table, *vect;
uint8_t *out; uint8_t *out;
int i, j, x, y, stride, vect_w = 3, vect_h = 3; int i, j, x, y, stride, vect_w = 3, vect_h = 3;
@ -151,7 +151,7 @@ avs_decode_frame(AVCodecContext * avctx,
align_get_bits(&change_map); align_get_bits(&change_map);
} }
*picture = *(AVFrame *) & avs->picture; *picture = avs->picture;
*data_size = sizeof(AVPicture); *data_size = sizeof(AVPicture);
return buf_size; return buf_size;

View File

@ -27,8 +27,8 @@
static av_cold int bmp_decode_init(AVCodecContext *avctx){ static av_cold int bmp_decode_init(AVCodecContext *avctx){
BMPContext *s = avctx->priv_data; BMPContext *s = avctx->priv_data;
avcodec_get_frame_defaults((AVFrame*)&s->picture); avcodec_get_frame_defaults(&s->picture);
avctx->coded_frame = (AVFrame*)&s->picture; avctx->coded_frame = &s->picture;
return 0; return 0;
} }

View File

@ -34,8 +34,8 @@ static const uint32_t rgb444_masks[] = { 0x0F00, 0x00F0, 0x000F };
static av_cold int bmp_encode_init(AVCodecContext *avctx){ static av_cold int bmp_encode_init(AVCodecContext *avctx){
BMPContext *s = avctx->priv_data; BMPContext *s = avctx->priv_data;
avcodec_get_frame_defaults((AVFrame*)&s->picture); avcodec_get_frame_defaults(&s->picture);
avctx->coded_frame = (AVFrame*)&s->picture; avctx->coded_frame = &s->picture;
switch (avctx->pix_fmt) { switch (avctx->pix_fmt) {
case PIX_FMT_BGRA: case PIX_FMT_BGRA:
@ -72,7 +72,7 @@ static int bmp_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
const AVFrame *pict, int *got_packet) const AVFrame *pict, int *got_packet)
{ {
BMPContext *s = avctx->priv_data; BMPContext *s = avctx->priv_data;
AVFrame * const p= (AVFrame*)&s->picture; AVFrame * const p = &s->picture;
int n_bytes_image, n_bytes_per_row, n_bytes, i, n, hsize, ret; int n_bytes_image, n_bytes_per_row, n_bytes, i, n, hsize, ret;
const uint32_t *pal = NULL; const uint32_t *pal = NULL;
uint32_t palette256[256]; uint32_t palette256[256];

View File

@ -501,9 +501,9 @@ static int decode_pic(AVSContext *h) {
} }
/* release last B frame */ /* release last B frame */
if(h->picture.f.data[0]) if(h->picture.f.data[0])
s->avctx->release_buffer(s->avctx, (AVFrame *)&h->picture); s->avctx->release_buffer(s->avctx, &h->picture.f);
s->avctx->get_buffer(s->avctx, (AVFrame *)&h->picture); s->avctx->get_buffer(s->avctx, &h->picture.f);
ff_cavs_init_pic(h); ff_cavs_init_pic(h);
h->picture.poc = get_bits(&s->gb,8)*2; h->picture.poc = get_bits(&s->gb,8)*2;
@ -592,7 +592,7 @@ static int decode_pic(AVSContext *h) {
} }
if(h->pic_type != AV_PICTURE_TYPE_B) { if(h->pic_type != AV_PICTURE_TYPE_B) {
if(h->DPB[1].f.data[0]) if(h->DPB[1].f.data[0])
s->avctx->release_buffer(s->avctx, (AVFrame *)&h->DPB[1]); s->avctx->release_buffer(s->avctx, &h->DPB[1].f);
h->DPB[1] = h->DPB[0]; h->DPB[1] = h->DPB[0];
h->DPB[0] = h->picture; h->DPB[0] = h->picture;
memset(&h->picture,0,sizeof(Picture)); memset(&h->picture,0,sizeof(Picture));
@ -656,7 +656,7 @@ static int cavs_decode_frame(AVCodecContext * avctx,void *data, int *data_size,
if (buf_size == 0) { if (buf_size == 0) {
if (!s->low_delay && h->DPB[0].f.data[0]) { if (!s->low_delay && h->DPB[0].f.data[0]) {
*data_size = sizeof(AVPicture); *data_size = sizeof(AVPicture);
*picture = *(AVFrame *) &h->DPB[0]; *picture = h->DPB[0].f;
} }
return 0; return 0;
} }
@ -676,9 +676,9 @@ static int cavs_decode_frame(AVCodecContext * avctx,void *data, int *data_size,
case PIC_I_START_CODE: case PIC_I_START_CODE:
if(!h->got_keyframe) { if(!h->got_keyframe) {
if(h->DPB[0].f.data[0]) if(h->DPB[0].f.data[0])
avctx->release_buffer(avctx, (AVFrame *)&h->DPB[0]); avctx->release_buffer(avctx, &h->DPB[0].f);
if(h->DPB[1].f.data[0]) if(h->DPB[1].f.data[0])
avctx->release_buffer(avctx, (AVFrame *)&h->DPB[1]); avctx->release_buffer(avctx, &h->DPB[1].f);
h->got_keyframe = 1; h->got_keyframe = 1;
} }
case PIC_PB_START_CODE: case PIC_PB_START_CODE:
@ -692,12 +692,12 @@ static int cavs_decode_frame(AVCodecContext * avctx,void *data, int *data_size,
*data_size = sizeof(AVPicture); *data_size = sizeof(AVPicture);
if(h->pic_type != AV_PICTURE_TYPE_B) { if(h->pic_type != AV_PICTURE_TYPE_B) {
if(h->DPB[1].f.data[0]) { if(h->DPB[1].f.data[0]) {
*picture = *(AVFrame *) &h->DPB[1]; *picture = h->DPB[1].f;
} else { } else {
*data_size = 0; *data_size = 0;
} }
} else } else
*picture = *(AVFrame *) &h->picture; *picture = h->picture.f;
break; break;
case EXT_START_CODE: case EXT_START_CODE:
//mpeg_decode_extension(avctx,buf_ptr, input_size); //mpeg_decode_extension(avctx,buf_ptr, input_size);

View File

@ -613,7 +613,7 @@ skip_mean_and_median:
if (s->avctx->codec_id == CODEC_ID_H264) { if (s->avctx->codec_id == CODEC_ID_H264) {
// FIXME // FIXME
} else { } else {
ff_thread_await_progress((AVFrame *) s->last_picture_ptr, ff_thread_await_progress(&s->last_picture_ptr->f,
mb_y, 0); mb_y, 0);
} }
if (!s->last_picture.f.motion_val[0] || if (!s->last_picture.f.motion_val[0] ||
@ -786,7 +786,7 @@ static int is_intra_more_likely(MpegEncContext *s)
if (s->avctx->codec_id == CODEC_ID_H264) { if (s->avctx->codec_id == CODEC_ID_H264) {
// FIXME // FIXME
} else { } else {
ff_thread_await_progress((AVFrame *) s->last_picture_ptr, ff_thread_await_progress(&s->last_picture_ptr->f,
mb_y, 0); mb_y, 0);
} }
is_intra_likely += s->dsp.sad[0](NULL, last_mb_ptr, mb_ptr , s->linesize, 16); is_intra_likely += s->dsp.sad[0](NULL, last_mb_ptr, mb_ptr , s->linesize, 16);
@ -1170,7 +1170,7 @@ void ff_er_frame_end(MpegEncContext *s)
if (s->avctx->codec_id == CODEC_ID_H264) { if (s->avctx->codec_id == CODEC_ID_H264) {
// FIXME // FIXME
} else { } else {
ff_thread_await_progress((AVFrame *) s->next_picture_ptr, mb_y, 0); ff_thread_await_progress(&s->next_picture_ptr->f, mb_y, 0);
} }
s->mv[0][0][0] = s->next_picture.f.motion_val[0][xy][0] * time_pb / time_pp; s->mv[0][0][0] = s->next_picture.f.motion_val[0][xy][0] * time_pb / time_pp;
s->mv[0][0][1] = s->next_picture.f.motion_val[0][xy][1] * time_pb / time_pp; s->mv[0][0][1] = s->next_picture.f.motion_val[0][xy][1] * time_pb / time_pp;

View File

@ -62,7 +62,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
FrapsContext * const s = avctx->priv_data; FrapsContext * const s = avctx->priv_data;
avcodec_get_frame_defaults(&s->frame); avcodec_get_frame_defaults(&s->frame);
avctx->coded_frame = (AVFrame*)&s->frame; avctx->coded_frame = &s->frame;
s->avctx = avctx; s->avctx = avctx;
s->tmpbuf = NULL; s->tmpbuf = NULL;
@ -132,7 +132,7 @@ static int decode_frame(AVCodecContext *avctx,
int buf_size = avpkt->size; int buf_size = avpkt->size;
FrapsContext * const s = avctx->priv_data; FrapsContext * const s = avctx->priv_data;
AVFrame *frame = data; AVFrame *frame = data;
AVFrame * const f = (AVFrame*)&s->frame; AVFrame * const f = &s->frame;
uint32_t header; uint32_t header;
unsigned int version,header_size; unsigned int version,header_size;
unsigned int x, y; unsigned int x, y;

View File

@ -126,8 +126,8 @@ static int g722_decode_frame(AVCodecContext *avctx, void *data,
c->prev_samples[c->prev_samples_pos++] = rlow - rhigh; c->prev_samples[c->prev_samples_pos++] = rlow - rhigh;
ff_g722_apply_qmf(c->prev_samples + c->prev_samples_pos - 24, ff_g722_apply_qmf(c->prev_samples + c->prev_samples_pos - 24,
&xout1, &xout2); &xout1, &xout2);
*out_buf++ = av_clip_int16(xout1 >> 12); *out_buf++ = av_clip_int16(xout1 >> 11);
*out_buf++ = av_clip_int16(xout2 >> 12); *out_buf++ = av_clip_int16(xout2 >> 11);
if (c->prev_samples_pos >= PREV_SAMPLES_BUF_SIZE) { if (c->prev_samples_pos >= PREV_SAMPLES_BUF_SIZE) {
memmove(c->prev_samples, c->prev_samples + c->prev_samples_pos - 22, memmove(c->prev_samples, c->prev_samples + c->prev_samples_pos - 22,
22 * sizeof(c->prev_samples[0])); 22 * sizeof(c->prev_samples[0]));

View File

@ -136,8 +136,8 @@ static inline void filter_samples(G722Context *c, const int16_t *samples,
c->prev_samples[c->prev_samples_pos++] = samples[0]; c->prev_samples[c->prev_samples_pos++] = samples[0];
c->prev_samples[c->prev_samples_pos++] = samples[1]; c->prev_samples[c->prev_samples_pos++] = samples[1];
ff_g722_apply_qmf(c->prev_samples + c->prev_samples_pos - 24, &xout1, &xout2); ff_g722_apply_qmf(c->prev_samples + c->prev_samples_pos - 24, &xout1, &xout2);
*xlow = xout1 + xout2 >> 13; *xlow = xout1 + xout2 >> 14;
*xhigh = xout1 - xout2 >> 13; *xhigh = xout1 - xout2 >> 14;
if (c->prev_samples_pos >= PREV_SAMPLES_BUF_SIZE) { if (c->prev_samples_pos >= PREV_SAMPLES_BUF_SIZE) {
memmove(c->prev_samples, memmove(c->prev_samples,
c->prev_samples + c->prev_samples_pos - 22, c->prev_samples + c->prev_samples_pos - 22,

View File

@ -160,7 +160,7 @@ static int gif_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
const AVFrame *pict, int *got_packet) const AVFrame *pict, int *got_packet)
{ {
GIFContext *s = avctx->priv_data; GIFContext *s = avctx->priv_data;
AVFrame *const p = (AVFrame *)&s->picture; AVFrame *const p = &s->picture;
uint8_t *outbuf_ptr, *end; uint8_t *outbuf_ptr, *end;
int ret; int ret;

View File

@ -628,7 +628,8 @@ retry:
assert(s->current_picture.f.pict_type == s->current_picture_ptr->f.pict_type); assert(s->current_picture.f.pict_type == s->current_picture_ptr->f.pict_type);
assert(s->current_picture.f.pict_type == s->pict_type); assert(s->current_picture.f.pict_type == s->pict_type);
*pict= *(AVFrame*)s->current_picture_ptr;
*pict = s->current_picture_ptr->f;
ff_print_debug_info(s, pict); ff_print_debug_info(s, pict);
*data_size = sizeof(AVFrame); *data_size = sizeof(AVFrame);

View File

@ -357,7 +357,7 @@ uint64_t time= rdtsc();
if (buf_size == 0) { if (buf_size == 0) {
/* special case for last picture */ /* special case for last picture */
if (s->low_delay==0 && s->next_picture_ptr) { 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; s->next_picture_ptr= NULL;
*data_size = sizeof(AVFrame); *data_size = sizeof(AVFrame);
@ -727,9 +727,9 @@ intrax8_decoded:
assert(s->current_picture.f.pict_type == s->current_picture_ptr->f.pict_type); assert(s->current_picture.f.pict_type == s->current_picture_ptr->f.pict_type);
assert(s->current_picture.f.pict_type == s->pict_type); assert(s->current_picture.f.pict_type == s->pict_type);
if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) { if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) {
*pict= *(AVFrame*)s->current_picture_ptr; *pict = s->current_picture_ptr->f;
} else if (s->last_picture_ptr != NULL) { } else if (s->last_picture_ptr != NULL) {
*pict= *(AVFrame*)s->last_picture_ptr; *pict = s->last_picture_ptr->f;
} }
if(s->last_picture_ptr || s->low_delay){ if(s->last_picture_ptr || s->low_delay){

View File

@ -367,14 +367,14 @@ static void await_references(H264Context *h){
nrefs[list]--; nrefs[list]--;
if(!FIELD_PICTURE && ref_field_picture){ // frame referencing two fields if(!FIELD_PICTURE && ref_field_picture){ // frame referencing two fields
ff_thread_await_progress((AVFrame*)ref_pic, FFMIN((row >> 1) - !(row&1), pic_height-1), 1); ff_thread_await_progress(&ref_pic->f, FFMIN((row >> 1) - !(row & 1), pic_height - 1), 1);
ff_thread_await_progress((AVFrame*)ref_pic, FFMIN((row >> 1) , pic_height-1), 0); ff_thread_await_progress(&ref_pic->f, FFMIN((row >> 1), pic_height - 1), 0);
}else if(FIELD_PICTURE && !ref_field_picture){ // field referencing one field of a frame }else if(FIELD_PICTURE && !ref_field_picture){ // field referencing one field of a frame
ff_thread_await_progress((AVFrame*)ref_pic, FFMIN(row*2 + ref_field , pic_height-1), 0); ff_thread_await_progress(&ref_pic->f, FFMIN(row * 2 + ref_field, pic_height - 1), 0);
}else if(FIELD_PICTURE){ }else if(FIELD_PICTURE){
ff_thread_await_progress((AVFrame*)ref_pic, FFMIN(row, pic_height-1), ref_field); ff_thread_await_progress(&ref_pic->f, FFMIN(row, pic_height - 1), ref_field);
}else{ }else{
ff_thread_await_progress((AVFrame*)ref_pic, FFMIN(row, pic_height-1), 0); ff_thread_await_progress(&ref_pic->f, FFMIN(row, pic_height - 1), 0);
} }
} }
} }
@ -2507,8 +2507,9 @@ static int field_end(H264Context *h, int in_setup){
s->mb_y= 0; s->mb_y= 0;
if (!in_setup && !s->dropable) if (!in_setup && !s->dropable)
ff_thread_report_progress((AVFrame*)s->current_picture_ptr, (16*s->mb_height >> FIELD_PICTURE) - 1, ff_thread_report_progress(&s->current_picture_ptr->f,
s->picture_structure==PICT_BOTTOM_FIELD); (16 * s->mb_height >> FIELD_PICTURE) - 1,
s->picture_structure == PICT_BOTTOM_FIELD);
if (CONFIG_H264_VDPAU_DECODER && s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU) if (CONFIG_H264_VDPAU_DECODER && s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU)
ff_vdpau_h264_set_reference_frames(s); ff_vdpau_h264_set_reference_frames(s);
@ -2906,8 +2907,8 @@ static int decode_slice_header(H264Context *h, H264Context *h0){
h->prev_frame_num++; h->prev_frame_num++;
h->prev_frame_num %= 1<<h->sps.log2_max_frame_num; h->prev_frame_num %= 1<<h->sps.log2_max_frame_num;
s->current_picture_ptr->frame_num= h->prev_frame_num; s->current_picture_ptr->frame_num= h->prev_frame_num;
ff_thread_report_progress((AVFrame*)s->current_picture_ptr, INT_MAX, 0); ff_thread_report_progress(&s->current_picture_ptr->f, INT_MAX, 0);
ff_thread_report_progress((AVFrame*)s->current_picture_ptr, INT_MAX, 1); ff_thread_report_progress(&s->current_picture_ptr->f, INT_MAX, 1);
ff_generate_sliding_window_mmcos(h); ff_generate_sliding_window_mmcos(h);
if (ff_h264_execute_ref_pic_marking(h, h->mmco, h->mmco_index) < 0 && if (ff_h264_execute_ref_pic_marking(h, h->mmco, h->mmco_index) < 0 &&
(s->avctx->err_recognition & AV_EF_EXPLODE)) (s->avctx->err_recognition & AV_EF_EXPLODE))
@ -3577,8 +3578,8 @@ static void decode_finish_row(H264Context *h){
if (s->dropable) return; if (s->dropable) return;
ff_thread_report_progress((AVFrame*)s->current_picture_ptr, top + height - 1, ff_thread_report_progress(&s->current_picture_ptr->f, top + height - 1,
s->picture_structure==PICT_BOTTOM_FIELD); s->picture_structure == PICT_BOTTOM_FIELD);
} }
static int decode_slice(struct AVCodecContext *avctx, void *arg){ static int decode_slice(struct AVCodecContext *avctx, void *arg){
@ -4067,7 +4068,7 @@ static int decode_frame(AVCodecContext *avctx,
if(out){ if(out){
*data_size = sizeof(AVFrame); *data_size = sizeof(AVFrame);
*pict= *(AVFrame*)out; *pict = out->f;
} }
return buf_index; return buf_index;
@ -4121,7 +4122,7 @@ not_extra:
*data_size = 0; /* Wait for second field. */ *data_size = 0; /* Wait for second field. */
if (h->next_output_pic && (h->next_output_pic->sync || h->sync>1)) { if (h->next_output_pic && (h->next_output_pic->sync || h->sync>1)) {
*data_size = sizeof(AVFrame); *data_size = sizeof(AVFrame);
*pict = *(AVFrame*)h->next_output_pic; *pict = h->next_output_pic->f;
} }
} }

View File

@ -154,7 +154,8 @@ static void await_reference_mb_row(H264Context * const h, Picture *ref, int mb_y
//FIXME it can be safe to access mb stuff //FIXME it can be safe to access mb stuff
//even if pixels aren't deblocked yet //even if pixels aren't deblocked yet
ff_thread_await_progress((AVFrame*)ref, FFMIN(16*mb_y >> ref_field_picture, ref_height-1), ff_thread_await_progress(&ref->f,
FFMIN(16 * mb_y >> ref_field_picture, ref_height - 1),
ref_field_picture && ref_field); ref_field_picture && ref_field);
} }

View File

@ -143,7 +143,7 @@ static int ir2_decode_frame(AVCodecContext *avctx,
int buf_size = avpkt->size; int buf_size = avpkt->size;
Ir2Context * const s = avctx->priv_data; Ir2Context * const s = avctx->priv_data;
AVFrame *picture = data; AVFrame *picture = data;
AVFrame * const p= (AVFrame*)&s->picture; AVFrame * const p = &s->picture;
int start; int start;
p->reference = 3; p->reference = 3;
@ -188,7 +188,7 @@ static int ir2_decode_frame(AVCodecContext *avctx,
s->picture.data[1], s->picture.linesize[1], ir2_luma_table); s->picture.data[1], s->picture.linesize[1], ir2_luma_table);
} }
*picture= *(AVFrame*)&s->picture; *picture = s->picture;
*data_size = sizeof(AVPicture); *data_size = sizeof(AVPicture);
return buf_size; return buf_size;

View File

@ -232,7 +232,7 @@ static int encode_picture_ls(AVCodecContext *avctx, AVPacket *pkt,
const AVFrame *pict, int *got_packet) const AVFrame *pict, int *got_packet)
{ {
JpeglsContext * const s = avctx->priv_data; JpeglsContext * const s = avctx->priv_data;
AVFrame * const p= (AVFrame*)&s->picture; AVFrame * const p = &s->picture;
const int near = avctx->prediction_method; const int near = avctx->prediction_method;
PutBitContext pb, pb2; PutBitContext pb, pb2;
GetBitContext gb; GetBitContext gb;

View File

@ -45,7 +45,7 @@ static int encode_picture_lossless(AVCodecContext *avctx, AVPacket *pkt,
MJpegContext * const m = s->mjpeg_ctx; MJpegContext * const m = s->mjpeg_ctx;
const int width= s->width; const int width= s->width;
const int height= s->height; const int height= s->height;
AVFrame * const p= (AVFrame*)&s->current_picture; AVFrame * const p = &s->current_picture.f;
const int predictor= avctx->prediction_method+1; const int predictor= avctx->prediction_method+1;
const int mb_width = (width + s->mjpeg_hsample[0] - 1) / s->mjpeg_hsample[0]; const int mb_width = (width + s->mjpeg_hsample[0] - 1) / s->mjpeg_hsample[0];
const int mb_height = (height + s->mjpeg_vsample[0] - 1) / s->mjpeg_vsample[0]; const int mb_height = (height + s->mjpeg_vsample[0] - 1) / s->mjpeg_vsample[0];

View File

@ -166,7 +166,7 @@ static int decode_frame(AVCodecContext *avctx,
const uint8_t *buf = avpkt->data; const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size; int buf_size = avpkt->size;
LOCOContext * const l = avctx->priv_data; LOCOContext * const l = avctx->priv_data;
AVFrame * const p= (AVFrame*)&l->pic; AVFrame * const p = &l->pic;
int decoded; int decoded;
if(p->data[0]) if(p->data[0])

View File

@ -243,7 +243,7 @@ static av_cold int decode_init(AVCodecContext *avctx){
static av_cold int decode_init_thread_copy(AVCodecContext *avctx){ static av_cold int decode_init_thread_copy(AVCodecContext *avctx){
MDECContext * const a = avctx->priv_data; MDECContext * const a = avctx->priv_data;
AVFrame *p = (AVFrame*)&a->picture; AVFrame *p = &a->picture;
avctx->coded_frame= p; avctx->coded_frame= p;
a->avctx= avctx; a->avctx= avctx;

View File

@ -1577,7 +1577,7 @@ int ff_mjpeg_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
goto the_end; goto the_end;
} else if (unescaped_buf_size > (1U<<29)) { } else if (unescaped_buf_size > (1U<<29)) {
av_log(avctx, AV_LOG_ERROR, "MJPEG packet 0x%x too big (0x%x/0x%x), corrupt data?\n", av_log(avctx, AV_LOG_ERROR, "MJPEG packet 0x%x too big (0x%x/0x%x), corrupt data?\n",
start_code, unescaped_buf_ptr, buf_size); start_code, unescaped_buf_size, buf_size);
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
} else { } else {
av_log(avctx, AV_LOG_DEBUG, "marker=%x avail_size_in_buf=%td\n", av_log(avctx, AV_LOG_DEBUG, "marker=%x avail_size_in_buf=%td\n",

View File

@ -1952,7 +1952,7 @@ static int slice_end(AVCodecContext *avctx, AVFrame *pict)
ff_MPV_frame_end(s); ff_MPV_frame_end(s);
if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) { if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) {
*pict = *(AVFrame*)s->current_picture_ptr; *pict = s->current_picture_ptr->f;
ff_print_debug_info(s, pict); ff_print_debug_info(s, pict);
} else { } else {
if (avctx->active_thread_type & FF_THREAD_FRAME) if (avctx->active_thread_type & FF_THREAD_FRAME)
@ -1960,7 +1960,7 @@ static int slice_end(AVCodecContext *avctx, AVFrame *pict)
/* latency of 1 frame for I- and P-frames */ /* latency of 1 frame for I- and P-frames */
/* XXX: use another variable than picture_number */ /* XXX: use another variable than picture_number */
if (s->last_picture_ptr != NULL) { if (s->last_picture_ptr != NULL) {
*pict = *(AVFrame*)s->last_picture_ptr; *pict = s->last_picture_ptr->f;
ff_print_debug_info(s, pict); ff_print_debug_info(s, pict);
} }
} }
@ -2256,7 +2256,7 @@ static int mpeg_decode_frame(AVCodecContext *avctx,
if (buf_size == 0 || (buf_size == 4 && AV_RB32(buf) == SEQ_END_CODE)) { if (buf_size == 0 || (buf_size == 4 && AV_RB32(buf) == SEQ_END_CODE)) {
/* special case for last picture */ /* special case for last picture */
if (s2->low_delay == 0 && s2->next_picture_ptr) { if (s2->low_delay == 0 && s2->next_picture_ptr) {
*picture = *(AVFrame*)s2->next_picture_ptr; *picture = s2->next_picture_ptr->f;
s2->next_picture_ptr = NULL; s2->next_picture_ptr = NULL;
*data_size = sizeof(AVFrame); *data_size = sizeof(AVFrame);

View File

@ -1313,7 +1313,7 @@ static int mpeg4_decode_mb(MpegEncContext *s,
s->last_mv[i][1][1]= 0; s->last_mv[i][1][1]= 0;
} }
ff_thread_await_progress((AVFrame*)s->next_picture_ptr, s->mb_y, 0); ff_thread_await_progress(&s->next_picture_ptr->f, s->mb_y, 0);
} }
/* if we skipped it in the future P Frame than skip it now too */ /* if we skipped it in the future P Frame than skip it now too */
@ -1500,7 +1500,7 @@ end:
if(s->pict_type==AV_PICTURE_TYPE_B){ if(s->pict_type==AV_PICTURE_TYPE_B){
const int delta= s->mb_x + 1 == s->mb_width ? 2 : 1; const int delta= s->mb_x + 1 == s->mb_width ? 2 : 1;
ff_thread_await_progress((AVFrame*)s->next_picture_ptr, ff_thread_await_progress(&s->next_picture_ptr->f,
(s->mb_x + delta >= s->mb_width) ? FFMIN(s->mb_y+1, s->mb_height-1) : s->mb_y, 0); (s->mb_x + delta >= s->mb_width) ? FFMIN(s->mb_y+1, s->mb_height-1) : s->mb_y, 0);
if (s->next_picture.f.mbskip_table[xy + delta]) if (s->next_picture.f.mbskip_table[xy + delta])
return SLICE_OK; return SLICE_OK;

View File

@ -232,9 +232,9 @@ static void free_frame_buffer(MpegEncContext *s, Picture *pic)
* dimensions; ignore user defined callbacks for these * dimensions; ignore user defined callbacks for these
*/ */
if (s->codec_id != CODEC_ID_WMV3IMAGE && s->codec_id != CODEC_ID_VC1IMAGE) if (s->codec_id != CODEC_ID_WMV3IMAGE && s->codec_id != CODEC_ID_VC1IMAGE)
ff_thread_release_buffer(s->avctx, (AVFrame *) pic); ff_thread_release_buffer(s->avctx, &pic->f);
else else
avcodec_default_release_buffer(s->avctx, (AVFrame *) pic); avcodec_default_release_buffer(s->avctx, &pic->f);
av_freep(&pic->f.hwaccel_picture_private); av_freep(&pic->f.hwaccel_picture_private);
} }
@ -257,9 +257,9 @@ static int alloc_frame_buffer(MpegEncContext *s, Picture *pic)
} }
if (s->codec_id != CODEC_ID_WMV3IMAGE && s->codec_id != CODEC_ID_VC1IMAGE) if (s->codec_id != CODEC_ID_WMV3IMAGE && s->codec_id != CODEC_ID_VC1IMAGE)
r = ff_thread_get_buffer(s->avctx, (AVFrame *) pic); r = ff_thread_get_buffer(s->avctx, &pic->f);
else else
r = avcodec_default_get_buffer(s->avctx, (AVFrame *) pic); r = avcodec_default_get_buffer(s->avctx, &pic->f);
if (r < 0 || !pic->f.type || !pic->f.data[0]) { if (r < 0 || !pic->f.type || !pic->f.data[0]) {
av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed (%d %d %p)\n", av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed (%d %d %p)\n",
@ -729,7 +729,7 @@ av_cold int ff_MPV_common_init(MpegEncContext *s)
s->codec_tag = avpriv_toupper4(s->avctx->codec_tag); s->codec_tag = avpriv_toupper4(s->avctx->codec_tag);
s->stream_codec_tag = avpriv_toupper4(s->avctx->stream_codec_tag); s->stream_codec_tag = avpriv_toupper4(s->avctx->stream_codec_tag);
s->avctx->coded_frame = (AVFrame*)&s->current_picture; s->avctx->coded_frame = &s->current_picture.f;
FF_ALLOCZ_OR_GOTO(s->avctx, s->mb_index2xy, (s->mb_num + 1) * sizeof(int), fail); // error ressilience code looks cleaner with this FF_ALLOCZ_OR_GOTO(s->avctx, s->mb_index2xy, (s->mb_num + 1) * sizeof(int), fail); // error ressilience code looks cleaner with this
for (y = 0; y < s->mb_height; y++) for (y = 0; y < s->mb_height; y++)
@ -781,7 +781,7 @@ av_cold int ff_MPV_common_init(MpegEncContext *s)
FF_ALLOCZ_OR_GOTO(s->avctx, s->picture, FF_ALLOCZ_OR_GOTO(s->avctx, s->picture,
s->picture_count * sizeof(Picture), fail); s->picture_count * sizeof(Picture), fail);
for (i = 0; i < s->picture_count; i++) { for (i = 0; i < s->picture_count; i++) {
avcodec_get_frame_defaults((AVFrame *) &s->picture[i]); avcodec_get_frame_defaults(&s->picture[i].f);
} }
FF_ALLOCZ_OR_GOTO(s->avctx, s->error_status_table, mb_array_size*sizeof(uint8_t), fail) FF_ALLOCZ_OR_GOTO(s->avctx, s->error_status_table, mb_array_size*sizeof(uint8_t), fail)
@ -1247,10 +1247,8 @@ int ff_MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx)
memset(s->last_picture_ptr->f.data[0] + s->last_picture_ptr->f.linesize[0]*i, 16, avctx->width); memset(s->last_picture_ptr->f.data[0] + s->last_picture_ptr->f.linesize[0]*i, 16, avctx->width);
} }
ff_thread_report_progress((AVFrame *) s->last_picture_ptr, ff_thread_report_progress(&s->last_picture_ptr->f, INT_MAX, 0);
INT_MAX, 0); ff_thread_report_progress(&s->last_picture_ptr->f, INT_MAX, 1);
ff_thread_report_progress((AVFrame *) s->last_picture_ptr,
INT_MAX, 1);
} }
if ((s->next_picture_ptr == NULL || if ((s->next_picture_ptr == NULL ||
s->next_picture_ptr->f.data[0] == NULL) && s->next_picture_ptr->f.data[0] == NULL) &&
@ -1263,10 +1261,8 @@ int ff_MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx)
s->next_picture_ptr->f.key_frame = 0; s->next_picture_ptr->f.key_frame = 0;
if (ff_alloc_picture(s, s->next_picture_ptr, 0) < 0) if (ff_alloc_picture(s, s->next_picture_ptr, 0) < 0)
return -1; return -1;
ff_thread_report_progress((AVFrame *) s->next_picture_ptr, ff_thread_report_progress(&s->next_picture_ptr->f, INT_MAX, 0);
INT_MAX, 0); ff_thread_report_progress(&s->next_picture_ptr->f, INT_MAX, 1);
ff_thread_report_progress((AVFrame *) s->next_picture_ptr,
INT_MAX, 1);
} }
} }
@ -1391,10 +1387,10 @@ void ff_MPV_frame_end(MpegEncContext *s)
memset(&s->next_picture, 0, sizeof(Picture)); memset(&s->next_picture, 0, sizeof(Picture));
memset(&s->current_picture, 0, sizeof(Picture)); memset(&s->current_picture, 0, sizeof(Picture));
#endif #endif
s->avctx->coded_frame = (AVFrame *) s->current_picture_ptr; s->avctx->coded_frame = &s->current_picture_ptr->f;
if (s->codec_id != CODEC_ID_H264 && s->current_picture.f.reference) { if (s->codec_id != CODEC_ID_H264 && s->current_picture.f.reference) {
ff_thread_report_progress((AVFrame *) s->current_picture_ptr, ff_thread_report_progress(&s->current_picture_ptr->f,
s->mb_height - 1, 0); s->mb_height - 1, 0);
} }
} }
@ -2346,10 +2342,14 @@ void MPV_decode_mb_internal(MpegEncContext *s, DCTELEM block[12][64],
if(HAVE_THREADS && s->avctx->active_thread_type&FF_THREAD_FRAME) { if(HAVE_THREADS && s->avctx->active_thread_type&FF_THREAD_FRAME) {
if (s->mv_dir & MV_DIR_FORWARD) { if (s->mv_dir & MV_DIR_FORWARD) {
ff_thread_await_progress((AVFrame*)s->last_picture_ptr, ff_MPV_lowest_referenced_row(s, 0), 0); ff_thread_await_progress(&s->last_picture_ptr->f,
ff_MPV_lowest_referenced_row(s, 0),
0);
} }
if (s->mv_dir & MV_DIR_BACKWARD) { if (s->mv_dir & MV_DIR_BACKWARD) {
ff_thread_await_progress((AVFrame*)s->next_picture_ptr, ff_MPV_lowest_referenced_row(s, 1), 0); ff_thread_await_progress(&s->next_picture_ptr->f,
ff_MPV_lowest_referenced_row(s, 1),
0);
} }
} }
@ -2556,9 +2556,9 @@ void ff_draw_horiz_band(MpegEncContext *s, int y, int h){
int i; int i;
if(s->pict_type==AV_PICTURE_TYPE_B || s->low_delay || (s->avctx->slice_flags&SLICE_FLAG_CODED_ORDER)) if(s->pict_type==AV_PICTURE_TYPE_B || s->low_delay || (s->avctx->slice_flags&SLICE_FLAG_CODED_ORDER))
src= (AVFrame*)s->current_picture_ptr; src = &s->current_picture_ptr->f;
else if(s->last_picture_ptr) else if(s->last_picture_ptr)
src= (AVFrame*)s->last_picture_ptr; src = &s->last_picture_ptr->f;
else else
return; return;
@ -2867,5 +2867,5 @@ void ff_set_qscale(MpegEncContext * s, int qscale)
void ff_MPV_report_decode_progress(MpegEncContext *s) void ff_MPV_report_decode_progress(MpegEncContext *s)
{ {
if (s->pict_type != AV_PICTURE_TYPE_B && !s->partitioned_frame && !s->error_occurred) if (s->pict_type != AV_PICTURE_TYPE_B && !s->partitioned_frame && !s->error_occurred)
ff_thread_report_progress((AVFrame*)s->current_picture_ptr, s->mb_y, 0); ff_thread_report_progress(&s->current_picture_ptr->f, s->mb_y, 0);
} }

View File

@ -981,7 +981,7 @@ static int load_input_picture(MpegEncContext *s, AVFrame *pic_arg)
if (i < 0) if (i < 0)
return i; return i;
pic = (AVFrame *) &s->picture[i]; pic = &s->picture[i].f;
pic->reference = 3; pic->reference = 3;
for (i = 0; i < 4; i++) { for (i = 0; i < 4; i++) {
@ -996,7 +996,7 @@ static int load_input_picture(MpegEncContext *s, AVFrame *pic_arg)
if (i < 0) if (i < 0)
return i; return i;
pic = (AVFrame *) &s->picture[i]; pic = &s->picture[i].f;
pic->reference = 3; pic->reference = 3;
if (ff_alloc_picture(s, (Picture *) pic, 0) < 0) { if (ff_alloc_picture(s, (Picture *) pic, 0) < 0) {
@ -1252,7 +1252,7 @@ static int select_input_picture(MpegEncContext *s)
s->input_picture[0]->f.type == FF_BUFFER_TYPE_INTERNAL); s->input_picture[0]->f.type == FF_BUFFER_TYPE_INTERNAL);
s->avctx->release_buffer(s->avctx, s->avctx->release_buffer(s->avctx,
(AVFrame *) s->input_picture[0]); &s->input_picture[0]->f);
} }
emms_c(); emms_c();
@ -1385,13 +1385,13 @@ no_output_pic:
/* mark us unused / free shared pic */ /* mark us unused / free shared pic */
if (s->reordered_input_picture[0]->f.type == FF_BUFFER_TYPE_INTERNAL) if (s->reordered_input_picture[0]->f.type == FF_BUFFER_TYPE_INTERNAL)
s->avctx->release_buffer(s->avctx, s->avctx->release_buffer(s->avctx,
(AVFrame *) s->reordered_input_picture[0]); &s->reordered_input_picture[0]->f);
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
s->reordered_input_picture[0]->f.data[i] = NULL; s->reordered_input_picture[0]->f.data[i] = NULL;
s->reordered_input_picture[0]->f.type = 0; s->reordered_input_picture[0]->f.type = 0;
copy_picture_attributes(s, (AVFrame *) pic, copy_picture_attributes(s, &pic->f,
(AVFrame *) s->reordered_input_picture[0]); &s->reordered_input_picture[0]->f);
s->current_picture_ptr = pic; s->current_picture_ptr = pic;
} else { } else {

View File

@ -34,6 +34,7 @@
#include "libavutil/x86_cpu.h" #include "libavutil/x86_cpu.h"
#include "h263.h" #include "h263.h"
#include "mpeg4video.h" #include "mpeg4video.h"
#include "msmpeg4data.h"
#include "vc1data.h" #include "vc1data.h"
/* /*
@ -52,22 +53,8 @@
#define V2_MV_VLC_BITS 9 #define V2_MV_VLC_BITS 9
#define TEX_VLC_BITS 9 #define TEX_VLC_BITS 9
#define II_BITRATE 128*1024
#define MBAC_BITRATE 50*1024
#define DEFAULT_INTER_INDEX 3 #define DEFAULT_INTER_INDEX 3
static uint32_t v2_dc_lum_table[512][2];
static uint32_t v2_dc_chroma_table[512][2];
#include "msmpeg4data.h"
#if CONFIG_ENCODERS //strangely gcc includes this even if it is not referenced
static uint8_t rl_length[NB_RL_TABLES][MAX_LEVEL+1][MAX_RUN+1][2];
#endif //CONFIG_ENCODERS
static uint8_t static_rl_table_store[NB_RL_TABLES][2][2*MAX_RUN + MAX_LEVEL + 3];
/* This table is practically identical to the one from h263 /* This table is practically identical to the one from h263
* except that it is inverted. */ * except that it is inverted. */
static av_cold void init_h263_dc_for_msmpeg4(void) static av_cold void init_h263_dc_for_msmpeg4(void)
@ -102,8 +89,8 @@ static av_cold void init_h263_dc_for_msmpeg4(void)
uni_len++; uni_len++;
} }
} }
v2_dc_lum_table[level+256][0]= uni_code; ff_v2_dc_lum_table[level + 256][0] = uni_code;
v2_dc_lum_table[level+256][1]= uni_len; ff_v2_dc_lum_table[level + 256][1] = uni_len;
/* chrominance h263 */ /* chrominance h263 */
uni_code= ff_mpeg4_DCtab_chrom[size][0]; uni_code= ff_mpeg4_DCtab_chrom[size][0];
@ -118,13 +105,13 @@ static av_cold void init_h263_dc_for_msmpeg4(void)
uni_len++; uni_len++;
} }
} }
v2_dc_chroma_table[level+256][0]= uni_code; ff_v2_dc_chroma_table[level + 256][0] = uni_code;
v2_dc_chroma_table[level+256][1]= uni_len; ff_v2_dc_chroma_table[level + 256][1] = uni_len;
} }
} }
static av_cold void common_init(MpegEncContext * s) av_cold void ff_msmpeg4_common_init(MpegEncContext *s)
{ {
static int initialized=0; static int initialized=0;
@ -173,251 +160,6 @@ static av_cold void common_init(MpegEncContext * s)
} }
} }
#if CONFIG_ENCODERS
/* build the table which associate a (x,y) motion vector to a vlc */
static void init_mv_table(MVTable *tab)
{
int i, x, y;
tab->table_mv_index = av_malloc(sizeof(uint16_t) * 4096);
/* mark all entries as not used */
for(i=0;i<4096;i++)
tab->table_mv_index[i] = tab->n;
for(i=0;i<tab->n;i++) {
x = tab->table_mvx[i];
y = tab->table_mvy[i];
tab->table_mv_index[(x << 6) | y] = i;
}
}
void ff_msmpeg4_code012(PutBitContext *pb, int n)
{
if (n == 0) {
put_bits(pb, 1, 0);
} else {
put_bits(pb, 1, 1);
put_bits(pb, 1, (n >= 2));
}
}
static int get_size_of_code(MpegEncContext * s, RLTable *rl, int last, int run, int level, int intra){
int size=0;
int code;
int run_diff= intra ? 0 : 1;
code = get_rl_index(rl, last, run, level);
size+= rl->table_vlc[code][1];
if (code == rl->n) {
int level1, run1;
level1 = level - rl->max_level[last][run];
if (level1 < 1)
goto esc2;
code = get_rl_index(rl, last, run, level1);
if (code == rl->n) {
esc2:
size++;
if (level > MAX_LEVEL)
goto esc3;
run1 = run - rl->max_run[last][level] - run_diff;
if (run1 < 0)
goto esc3;
code = get_rl_index(rl, last, run1, level);
if (code == rl->n) {
esc3:
/* third escape */
size+=1+1+6+8;
} else {
/* second escape */
size+= 1+1+ rl->table_vlc[code][1];
}
} else {
/* first escape */
size+= 1+1+ rl->table_vlc[code][1];
}
} else {
size++;
}
return size;
}
av_cold void ff_msmpeg4_encode_init(MpegEncContext *s)
{
static int init_done=0;
int i;
common_init(s);
if(s->msmpeg4_version>=4){
s->min_qcoeff= -255;
s->max_qcoeff= 255;
}
if (!init_done) {
/* init various encoding tables */
init_done = 1;
init_mv_table(&ff_mv_tables[0]);
init_mv_table(&ff_mv_tables[1]);
for(i=0;i<NB_RL_TABLES;i++)
ff_init_rl(&ff_rl_table[i], static_rl_table_store[i]);
for(i=0; i<NB_RL_TABLES; i++){
int level;
for (level = 1; level <= MAX_LEVEL; level++) {
int run;
for(run=0; run<=MAX_RUN; run++){
int last;
for(last=0; last<2; last++){
rl_length[i][level][run][last]= get_size_of_code(s, &ff_rl_table[ i], last, run, level, 0);
}
}
}
}
}
}
static void find_best_tables(MpegEncContext * s)
{
int i;
int best = 0, best_size = INT_MAX;
int chroma_best = 0, best_chroma_size = INT_MAX;
for(i=0; i<3; i++){
int level;
int chroma_size=0;
int size=0;
if(i>0){// ;)
size++;
chroma_size++;
}
for(level=0; level<=MAX_LEVEL; level++){
int run;
for(run=0; run<=MAX_RUN; run++){
int last;
const int last_size= size + chroma_size;
for(last=0; last<2; last++){
int inter_count = s->ac_stats[0][0][level][run][last] + s->ac_stats[0][1][level][run][last];
int intra_luma_count = s->ac_stats[1][0][level][run][last];
int intra_chroma_count= s->ac_stats[1][1][level][run][last];
if(s->pict_type==AV_PICTURE_TYPE_I){
size += intra_luma_count *rl_length[i ][level][run][last];
chroma_size+= intra_chroma_count*rl_length[i+3][level][run][last];
}else{
size+= intra_luma_count *rl_length[i ][level][run][last]
+intra_chroma_count*rl_length[i+3][level][run][last]
+inter_count *rl_length[i+3][level][run][last];
}
}
if(last_size == size+chroma_size) break;
}
}
if(size<best_size){
best_size= size;
best= i;
}
if(chroma_size<best_chroma_size){
best_chroma_size= chroma_size;
chroma_best= i;
}
}
// printf("type:%d, best:%d, qp:%d, var:%d, mcvar:%d, size:%d //\n",
// s->pict_type, best, s->qscale, s->mb_var_sum, s->mc_mb_var_sum, best_size);
if(s->pict_type==AV_PICTURE_TYPE_P) chroma_best= best;
memset(s->ac_stats, 0, sizeof(int)*(MAX_LEVEL+1)*(MAX_RUN+1)*2*2*2);
s->rl_table_index = best;
s->rl_chroma_table_index= chroma_best;
if(s->pict_type != s->last_non_b_pict_type){
s->rl_table_index= 2;
if(s->pict_type==AV_PICTURE_TYPE_I)
s->rl_chroma_table_index= 1;
else
s->rl_chroma_table_index= 2;
}
}
/* write MSMPEG4 compatible frame header */
void ff_msmpeg4_encode_picture_header(MpegEncContext * s, int picture_number)
{
find_best_tables(s);
avpriv_align_put_bits(&s->pb);
put_bits(&s->pb, 2, s->pict_type - 1);
put_bits(&s->pb, 5, s->qscale);
if(s->msmpeg4_version<=2){
s->rl_table_index = 2;
s->rl_chroma_table_index = 2;
}
s->dc_table_index = 1;
s->mv_table_index = 1; /* only if P frame */
s->use_skip_mb_code = 1; /* only if P frame */
s->per_mb_rl_table = 0;
if(s->msmpeg4_version==4)
s->inter_intra_pred= (s->width*s->height < 320*240 && s->bit_rate<=II_BITRATE && s->pict_type==AV_PICTURE_TYPE_P);
//printf("%d %d %d %d %d\n", s->pict_type, s->bit_rate, s->inter_intra_pred, s->width, s->height);
if (s->pict_type == AV_PICTURE_TYPE_I) {
s->slice_height= s->mb_height/1;
put_bits(&s->pb, 5, 0x16 + s->mb_height/s->slice_height);
if(s->msmpeg4_version==4){
ff_msmpeg4_encode_ext_header(s);
if(s->bit_rate>MBAC_BITRATE)
put_bits(&s->pb, 1, s->per_mb_rl_table);
}
if(s->msmpeg4_version>2){
if(!s->per_mb_rl_table){
ff_msmpeg4_code012(&s->pb, s->rl_chroma_table_index);
ff_msmpeg4_code012(&s->pb, s->rl_table_index);
}
put_bits(&s->pb, 1, s->dc_table_index);
}
} else {
put_bits(&s->pb, 1, s->use_skip_mb_code);
if(s->msmpeg4_version==4 && s->bit_rate>MBAC_BITRATE)
put_bits(&s->pb, 1, s->per_mb_rl_table);
if(s->msmpeg4_version>2){
if(!s->per_mb_rl_table)
ff_msmpeg4_code012(&s->pb, s->rl_table_index);
put_bits(&s->pb, 1, s->dc_table_index);
put_bits(&s->pb, 1, s->mv_table_index);
}
}
s->esc3_level_length= 0;
s->esc3_run_length= 0;
}
void ff_msmpeg4_encode_ext_header(MpegEncContext * s)
{
put_bits(&s->pb, 5, s->avctx->time_base.den / s->avctx->time_base.num); //yes 29.97 -> 29
put_bits(&s->pb, 11, FFMIN(s->bit_rate/1024, 2047));
if(s->msmpeg4_version>=3)
put_bits(&s->pb, 1, s->flipflop_rounding);
else
assert(s->flipflop_rounding==0);
}
#endif //CONFIG_ENCODERS
/* predict coded block */ /* predict coded block */
int ff_msmpeg4_coded_block_pred(MpegEncContext * s, int n, uint8_t **coded_block_ptr) int ff_msmpeg4_coded_block_pred(MpegEncContext * s, int n, uint8_t **coded_block_ptr)
{ {
@ -445,217 +187,6 @@ int ff_msmpeg4_coded_block_pred(MpegEncContext * s, int n, uint8_t **coded_block
return pred; return pred;
} }
#if CONFIG_ENCODERS
void ff_msmpeg4_encode_motion(MpegEncContext * s,
int mx, int my)
{
int code;
MVTable *mv;
/* modulo encoding */
/* WARNING : you cannot reach all the MVs even with the modulo
encoding. This is a somewhat strange compromise they took !!! */
if (mx <= -64)
mx += 64;
else if (mx >= 64)
mx -= 64;
if (my <= -64)
my += 64;
else if (my >= 64)
my -= 64;
mx += 32;
my += 32;
#if 0
if ((unsigned)mx >= 64 ||
(unsigned)my >= 64)
av_log(s->avctx, AV_LOG_ERROR, "error mx=%d my=%d\n", mx, my);
#endif
mv = &ff_mv_tables[s->mv_table_index];
code = mv->table_mv_index[(mx << 6) | my];
put_bits(&s->pb,
mv->table_mv_bits[code],
mv->table_mv_code[code]);
if (code == mv->n) {
/* escape : code literally */
put_bits(&s->pb, 6, mx);
put_bits(&s->pb, 6, my);
}
}
void ff_msmpeg4_handle_slices(MpegEncContext *s){
if (s->mb_x == 0) {
if (s->slice_height && (s->mb_y % s->slice_height) == 0) {
if(s->msmpeg4_version < 4){
ff_mpeg4_clean_buffers(s);
}
s->first_slice_line = 1;
} else {
s->first_slice_line = 0;
}
}
}
static void msmpeg4v2_encode_motion(MpegEncContext * s, int val)
{
int range, bit_size, sign, code, bits;
if (val == 0) {
/* zero vector */
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;
if (val <= -64)
val += 64;
else if (val >= 64)
val -= 64;
if (val >= 0) {
sign = 0;
} else {
val = -val;
sign = 1;
}
val--;
code = (val >> bit_size) + 1;
bits = val & (range - 1);
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);
}
}
}
void ff_msmpeg4_encode_mb(MpegEncContext * s,
DCTELEM block[6][64],
int motion_x, int motion_y)
{
int cbp, coded_cbp, i;
int pred_x, pred_y;
uint8_t *coded_block;
ff_msmpeg4_handle_slices(s);
if (!s->mb_intra) {
/* compute cbp */
cbp = 0;
for (i = 0; i < 6; i++) {
if (s->block_last_index[i] >= 0)
cbp |= 1 << (5 - i);
}
if (s->use_skip_mb_code && (cbp | motion_x | motion_y) == 0) {
/* skip macroblock */
put_bits(&s->pb, 1, 1);
s->last_bits++;
s->misc_bits++;
s->skip_count++;
return;
}
if (s->use_skip_mb_code)
put_bits(&s->pb, 1, 0); /* mb coded */
if(s->msmpeg4_version<=2){
put_bits(&s->pb,
ff_v2_mb_type[cbp&3][1],
ff_v2_mb_type[cbp&3][0]);
if((cbp&3) != 3) coded_cbp= cbp ^ 0x3C;
else coded_cbp= cbp;
put_bits(&s->pb,
ff_h263_cbpy_tab[coded_cbp>>2][1],
ff_h263_cbpy_tab[coded_cbp>>2][0]);
s->misc_bits += get_bits_diff(s);
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{
put_bits(&s->pb,
ff_table_mb_non_intra[cbp + 64][1],
ff_table_mb_non_intra[cbp + 64][0]);
s->misc_bits += get_bits_diff(s);
/* motion vector */
ff_h263_pred_motion(s, 0, 0, &pred_x, &pred_y);
ff_msmpeg4_encode_motion(s, motion_x - pred_x,
motion_y - pred_y);
}
s->mv_bits += get_bits_diff(s);
for (i = 0; i < 6; i++) {
ff_msmpeg4_encode_block(s, block[i], i);
}
s->p_tex_bits += get_bits_diff(s);
} else {
/* compute cbp */
cbp = 0;
coded_cbp = 0;
for (i = 0; i < 6; i++) {
int val, pred;
val = (s->block_last_index[i] >= 1);
cbp |= val << (5 - i);
if (i < 4) {
/* predict value for close blocks only for luma */
pred = ff_msmpeg4_coded_block_pred(s, i, &coded_block);
*coded_block = val;
val = val ^ pred;
}
coded_cbp |= val << (5 - i);
}
if(s->msmpeg4_version<=2){
if (s->pict_type == AV_PICTURE_TYPE_I) {
put_bits(&s->pb,
ff_v2_intra_cbpc[cbp&3][1], ff_v2_intra_cbpc[cbp&3][0]);
} else {
if (s->use_skip_mb_code)
put_bits(&s->pb, 1, 0); /* mb coded */
put_bits(&s->pb,
ff_v2_mb_type[(cbp&3) + 4][1],
ff_v2_mb_type[(cbp&3) + 4][0]);
}
put_bits(&s->pb, 1, 0); /* no AC prediction yet */
put_bits(&s->pb,
ff_h263_cbpy_tab[cbp>>2][1],
ff_h263_cbpy_tab[cbp>>2][0]);
}else{
if (s->pict_type == AV_PICTURE_TYPE_I) {
put_bits(&s->pb,
ff_msmp4_mb_i_table[coded_cbp][1], ff_msmp4_mb_i_table[coded_cbp][0]);
} else {
if (s->use_skip_mb_code)
put_bits(&s->pb, 1, 0); /* mb coded */
put_bits(&s->pb,
ff_table_mb_non_intra[cbp][1],
ff_table_mb_non_intra[cbp][0]);
}
put_bits(&s->pb, 1, 0); /* no AC prediction yet */
if(s->inter_intra_pred){
s->h263_aic_dir=0;
put_bits(&s->pb, ff_table_inter_intra[s->h263_aic_dir][1], ff_table_inter_intra[s->h263_aic_dir][0]);
}
}
s->misc_bits += get_bits_diff(s);
for (i = 0; i < 6; i++) {
ff_msmpeg4_encode_block(s, block[i], i);
}
s->i_tex_bits += get_bits_diff(s);
s->i_count++;
}
}
#endif //CONFIG_ENCODERS
static inline int msmpeg4v1_pred_dc(MpegEncContext * s, int n, static inline int msmpeg4v1_pred_dc(MpegEncContext * s, int n,
int32_t **dc_val_ptr) int32_t **dc_val_ptr)
{ {
@ -685,8 +216,8 @@ static int get_dc(uint8_t *src, int stride, int scale)
} }
/* dir = 0: left, dir = 1: top prediction */ /* dir = 0: left, dir = 1: top prediction */
static inline int msmpeg4_pred_dc(MpegEncContext * s, int n, int ff_msmpeg4_pred_dc(MpegEncContext *s, int n,
int16_t **dc_val_ptr, int *dir_ptr) int16_t **dc_val_ptr, int *dir_ptr)
{ {
int a, b, c, wrap, pred, scale; int a, b, c, wrap, pred, scale;
int16_t *dc_val; int16_t *dc_val;
@ -832,207 +363,6 @@ static inline int msmpeg4_pred_dc(MpegEncContext * s, int n,
return pred; return pred;
} }
#define DC_MAX 119
static void msmpeg4_encode_dc(MpegEncContext * s, int level, int n, int *dir_ptr)
{
int sign, code;
int pred, extquant;
int extrabits = 0;
int16_t *dc_val;
pred = msmpeg4_pred_dc(s, n, &dc_val, dir_ptr);
/* update predictor */
if (n < 4) {
*dc_val = level * s->y_dc_scale;
} else {
*dc_val = level * s->c_dc_scale;
}
/* do the prediction */
level -= pred;
if(s->msmpeg4_version<=2){
if (n < 4) {
put_bits(&s->pb,
v2_dc_lum_table[level+256][1],
v2_dc_lum_table[level+256][0]);
}else{
put_bits(&s->pb,
v2_dc_chroma_table[level+256][1],
v2_dc_chroma_table[level+256][0]);
}
}else{
sign = 0;
if (level < 0) {
level = -level;
sign = 1;
}
code = level;
if (code > DC_MAX)
code = DC_MAX;
else if( s->msmpeg4_version>=6 ) {
if( s->qscale == 1 ) {
extquant = (level + 3) & 0x3;
code = ((level+3)>>2);
} else if( s->qscale == 2 ) {
extquant = (level + 1) & 0x1;
code = ((level+1)>>1);
}
}
if (s->dc_table_index == 0) {
if (n < 4) {
put_bits(&s->pb, ff_table0_dc_lum[code][1], ff_table0_dc_lum[code][0]);
} else {
put_bits(&s->pb, ff_table0_dc_chroma[code][1], ff_table0_dc_chroma[code][0]);
}
} else {
if (n < 4) {
put_bits(&s->pb, ff_table1_dc_lum[code][1], ff_table1_dc_lum[code][0]);
} else {
put_bits(&s->pb, ff_table1_dc_chroma[code][1], ff_table1_dc_chroma[code][0]);
}
}
if(s->msmpeg4_version>=6 && s->qscale<=2)
extrabits = 3 - s->qscale;
if (code == DC_MAX)
put_bits(&s->pb, 8 + extrabits, level);
else if(extrabits > 0)//== VC1 && s->qscale<=2
put_bits(&s->pb, extrabits, extquant);
if (level != 0) {
put_bits(&s->pb, 1, sign);
}
}
}
/* Encoding of a block. Very similar to MPEG4 except for a different
escape coding (same as H263) and more vlc tables.
*/
void ff_msmpeg4_encode_block(MpegEncContext * s, DCTELEM * block, int n)
{
int level, run, last, i, j, last_index;
int last_non_zero, sign, slevel;
int code, run_diff, dc_pred_dir;
const RLTable *rl;
const uint8_t *scantable;
if (s->mb_intra) {
msmpeg4_encode_dc(s, block[0], n, &dc_pred_dir);
i = 1;
if (n < 4) {
rl = &ff_rl_table[s->rl_table_index];
} else {
rl = &ff_rl_table[3 + s->rl_chroma_table_index];
}
run_diff = s->msmpeg4_version>=4;
scantable= s->intra_scantable.permutated;
} else {
i = 0;
rl = &ff_rl_table[3 + s->rl_table_index];
if(s->msmpeg4_version<=2)
run_diff = 0;
else
run_diff = 1;
scantable= s->inter_scantable.permutated;
}
/* recalculate block_last_index for M$ wmv1 */
if(s->msmpeg4_version>=4 && s->msmpeg4_version<6 && s->block_last_index[n]>0){
for(last_index=63; last_index>=0; last_index--){
if(block[scantable[last_index]]) break;
}
s->block_last_index[n]= last_index;
}else
last_index = s->block_last_index[n];
/* AC coefs */
last_non_zero = i - 1;
for (; i <= last_index; i++) {
j = scantable[i];
level = block[j];
if (level) {
run = i - last_non_zero - 1;
last = (i == last_index);
sign = 0;
slevel = level;
if (level < 0) {
sign = 1;
level = -level;
}
if(level<=MAX_LEVEL && run<=MAX_RUN){
s->ac_stats[s->mb_intra][n>3][level][run][last]++;
}
s->ac_stats[s->mb_intra][n > 3][40][63][0]++; //esc3 like
code = get_rl_index(rl, last, run, level);
put_bits(&s->pb, rl->table_vlc[code][1], rl->table_vlc[code][0]);
if (code == rl->n) {
int level1, run1;
level1 = level - rl->max_level[last][run];
if (level1 < 1)
goto esc2;
code = get_rl_index(rl, last, run, level1);
if (code == rl->n) {
esc2:
put_bits(&s->pb, 1, 0);
if (level > MAX_LEVEL)
goto esc3;
run1 = run - rl->max_run[last][level] - run_diff;
if (run1 < 0)
goto esc3;
code = get_rl_index(rl, last, run1+1, level);
if (s->msmpeg4_version == 4 && code == rl->n)
goto esc3;
code = get_rl_index(rl, last, run1, level);
if (code == rl->n) {
esc3:
/* third escape */
put_bits(&s->pb, 1, 0);
put_bits(&s->pb, 1, last);
if(s->msmpeg4_version>=4){
if(s->esc3_level_length==0){
s->esc3_level_length=8;
s->esc3_run_length= 6;
//ESCLVLSZ + ESCRUNSZ
if(s->qscale<8)
put_bits(&s->pb, 6 + (s->msmpeg4_version>=6), 3);
else
put_bits(&s->pb, 8, 3);
}
put_bits(&s->pb, s->esc3_run_length, run);
put_bits(&s->pb, 1, sign);
put_bits(&s->pb, s->esc3_level_length, level);
}else{
put_bits(&s->pb, 6, run);
put_sbits(&s->pb, 8, slevel);
}
} else {
/* second escape */
put_bits(&s->pb, 1, 1);
put_bits(&s->pb, rl->table_vlc[code][1], rl->table_vlc[code][0]);
put_bits(&s->pb, 1, sign);
}
} else {
/* first escape */
put_bits(&s->pb, 1, 1);
put_bits(&s->pb, rl->table_vlc[code][1], rl->table_vlc[code][0]);
put_bits(&s->pb, 1, sign);
}
} else {
put_bits(&s->pb, 1, sign);
}
last_non_zero = i;
}
}
}
/****************************************/ /****************************************/
/* decoding stuff */ /* decoding stuff */
@ -1263,13 +593,13 @@ av_cold int ff_msmpeg4_decode_init(AVCodecContext *avctx)
if (ff_h263_decode_init(avctx) < 0) if (ff_h263_decode_init(avctx) < 0)
return -1; return -1;
common_init(s); ff_msmpeg4_common_init(s);
if (!done) { if (!done) {
done = 1; done = 1;
for(i=0;i<NB_RL_TABLES;i++) { for(i=0;i<NB_RL_TABLES;i++) {
ff_init_rl(&ff_rl_table[i], static_rl_table_store[i]); ff_init_rl(&ff_rl_table[i], ff_static_rl_table_store[i]);
} }
INIT_VLC_RL(ff_rl_table[0], 642); INIT_VLC_RL(ff_rl_table[0], 642);
INIT_VLC_RL(ff_rl_table[1], 1104); INIT_VLC_RL(ff_rl_table[1], 1104);
@ -1301,11 +631,11 @@ av_cold int ff_msmpeg4_decode_init(AVCodecContext *avctx)
&ff_table1_dc_chroma[0][0], 8, 4, 1216); &ff_table1_dc_chroma[0][0], 8, 4, 1216);
INIT_VLC_STATIC(&v2_dc_lum_vlc, DC_VLC_BITS, 512, INIT_VLC_STATIC(&v2_dc_lum_vlc, DC_VLC_BITS, 512,
&v2_dc_lum_table[0][1], 8, 4, &ff_v2_dc_lum_table[0][1], 8, 4,
&v2_dc_lum_table[0][0], 8, 4, 1472); &ff_v2_dc_lum_table[0][0], 8, 4, 1472);
INIT_VLC_STATIC(&v2_dc_chroma_vlc, DC_VLC_BITS, 512, INIT_VLC_STATIC(&v2_dc_chroma_vlc, DC_VLC_BITS, 512,
&v2_dc_chroma_table[0][1], 8, 4, &ff_v2_dc_chroma_table[0][1], 8, 4,
&v2_dc_chroma_table[0][0], 8, 4, 1506); &ff_v2_dc_chroma_table[0][0], 8, 4, 1506);
INIT_VLC_STATIC(&v2_intra_cbpc_vlc, V2_INTRA_CBPC_VLC_BITS, 4, INIT_VLC_STATIC(&v2_intra_cbpc_vlc, V2_INTRA_CBPC_VLC_BITS, 4,
&ff_v2_intra_cbpc[0][1], 2, 1, &ff_v2_intra_cbpc[0][1], 2, 1,
@ -1588,7 +918,7 @@ static int msmpeg4_decode_dc(MpegEncContext * s, int n, int *dir_ptr)
*dc_val= level; *dc_val= level;
}else{ }else{
int16_t *dc_val; int16_t *dc_val;
pred = msmpeg4_pred_dc(s, n, &dc_val, dir_ptr); pred = ff_msmpeg4_pred_dc(s, n, &dc_val, dir_ptr);
level += pred; level += pred;
/* update predictor */ /* update predictor */

View File

@ -22,19 +22,29 @@
#ifndef AVCODEC_MSMPEG4_H #ifndef AVCODEC_MSMPEG4_H
#define AVCODEC_MSMPEG4_H #define AVCODEC_MSMPEG4_H
#include <stdint.h>
#include "config.h" #include "config.h"
#include "avcodec.h" #include "avcodec.h"
#include "dsputil.h" #include "dsputil.h"
#include "mpegvideo.h" #include "mpegvideo.h"
#include "msmpeg4data.h"
#include "put_bits.h"
#define INTER_INTRA_VLC_BITS 3 #define INTER_INTRA_VLC_BITS 3
#define MB_NON_INTRA_VLC_BITS 9 #define MB_NON_INTRA_VLC_BITS 9
#define MB_INTRA_VLC_BITS 9 #define MB_INTRA_VLC_BITS 9
#define II_BITRATE 128*1024
#define MBAC_BITRATE 50*1024
#define DC_MAX 119
extern VLC ff_mb_non_intra_vlc[4]; extern VLC ff_mb_non_intra_vlc[4];
extern VLC ff_inter_intra_vlc; extern VLC ff_inter_intra_vlc;
void ff_msmpeg4_code012(PutBitContext *pb, int n); void ff_msmpeg4_code012(PutBitContext *pb, int n);
void ff_msmpeg4_common_init(MpegEncContext *s);
void ff_msmpeg4_encode_block(MpegEncContext * s, DCTELEM * block, int n); void ff_msmpeg4_encode_block(MpegEncContext * s, DCTELEM * block, int n);
void ff_msmpeg4_handle_slices(MpegEncContext *s); void ff_msmpeg4_handle_slices(MpegEncContext *s);
void ff_msmpeg4_encode_motion(MpegEncContext * s, int mx, int my); void ff_msmpeg4_encode_motion(MpegEncContext * s, int mx, int my);
@ -43,6 +53,8 @@ int ff_msmpeg4_coded_block_pred(MpegEncContext * s, int n,
int ff_msmpeg4_decode_motion(MpegEncContext * s, int *mx_ptr, int *my_ptr); int ff_msmpeg4_decode_motion(MpegEncContext * s, int *mx_ptr, int *my_ptr);
int ff_msmpeg4_decode_block(MpegEncContext * s, DCTELEM * block, int ff_msmpeg4_decode_block(MpegEncContext * s, DCTELEM * block,
int n, int coded, const uint8_t *scan_table); int n, int coded, const uint8_t *scan_table);
int ff_msmpeg4_pred_dc(MpegEncContext *s, int n,
int16_t **dc_val_ptr, int *dir_ptr);
int ff_wmv2_decode_mb(MpegEncContext *s, DCTELEM block[6][64]); int ff_wmv2_decode_mb(MpegEncContext *s, DCTELEM block[6][64]);
#define CONFIG_MSMPEG4_DECODER (CONFIG_MSMPEG4V1_DECODER || \ #define CONFIG_MSMPEG4_DECODER (CONFIG_MSMPEG4V1_DECODER || \

View File

@ -29,6 +29,10 @@
#include "msmpeg4data.h" #include "msmpeg4data.h"
uint32_t ff_v2_dc_lum_table[512][2];
uint32_t ff_v2_dc_chroma_table[512][2];
uint8_t ff_static_rl_table_store[NB_RL_TABLES][2][2 * MAX_RUN + MAX_LEVEL + 3];
VLC ff_msmp4_mb_i_vlc; VLC ff_msmp4_mb_i_vlc;
VLC ff_msmp4_dc_luma_vlc[2]; VLC ff_msmp4_dc_luma_vlc[2];
VLC ff_msmp4_dc_chroma_vlc[2]; VLC ff_msmp4_dc_chroma_vlc[2];

View File

@ -59,6 +59,10 @@ extern const uint8_t ff_wmv1_scantable[WMV1_SCANTABLE_COUNT][64];
#define NB_RL_TABLES 6 #define NB_RL_TABLES 6
extern RLTable ff_rl_table[NB_RL_TABLES]; extern RLTable ff_rl_table[NB_RL_TABLES];
extern uint8_t ff_static_rl_table_store[NB_RL_TABLES][2][2 * MAX_RUN + MAX_LEVEL + 3];
extern uint32_t ff_v2_dc_lum_table[512][2];
extern uint32_t ff_v2_dc_chroma_table[512][2];
extern const uint8_t ff_wmv1_y_dc_scale_table[32]; extern const uint8_t ff_wmv1_y_dc_scale_table[32];
extern const uint8_t ff_wmv1_c_dc_scale_table[32]; extern const uint8_t ff_wmv1_c_dc_scale_table[32];

692
libavcodec/msmpeg4enc.c Normal file
View File

@ -0,0 +1,692 @@
/*
* MSMPEG4 encoder backend
* Copyright (c) 2001 Fabrice Bellard
* Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
*
* msmpeg4v1 & v2 stuff by Michael Niedermayer <michaelni@gmx.at>
*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/**
* @file
* MSMPEG4 encoder backend
*/
#include <stdint.h>
#include <string.h>
#include "libavutil/avutil.h"
#include "libavutil/mem.h"
#include "mpegvideo.h"
#include "msmpeg4.h"
#include "h263.h"
#include "mpeg4video.h"
#include "msmpeg4.h"
#include "msmpeg4data.h"
#include "put_bits.h"
#include "rl.h"
#include "vc1data.h"
static uint8_t rl_length[NB_RL_TABLES][MAX_LEVEL+1][MAX_RUN+1][2];
/* build the table which associate a (x,y) motion vector to a vlc */
static void init_mv_table(MVTable *tab)
{
int i, x, y;
tab->table_mv_index = av_malloc(sizeof(uint16_t) * 4096);
/* mark all entries as not used */
for(i=0;i<4096;i++)
tab->table_mv_index[i] = tab->n;
for(i=0;i<tab->n;i++) {
x = tab->table_mvx[i];
y = tab->table_mvy[i];
tab->table_mv_index[(x << 6) | y] = i;
}
}
void ff_msmpeg4_code012(PutBitContext *pb, int n)
{
if (n == 0) {
put_bits(pb, 1, 0);
} else {
put_bits(pb, 1, 1);
put_bits(pb, 1, (n >= 2));
}
}
static int get_size_of_code(MpegEncContext * s, RLTable *rl, int last, int run, int level, int intra){
int size=0;
int code;
int run_diff= intra ? 0 : 1;
code = get_rl_index(rl, last, run, level);
size+= rl->table_vlc[code][1];
if (code == rl->n) {
int level1, run1;
level1 = level - rl->max_level[last][run];
if (level1 < 1)
goto esc2;
code = get_rl_index(rl, last, run, level1);
if (code == rl->n) {
esc2:
size++;
if (level > MAX_LEVEL)
goto esc3;
run1 = run - rl->max_run[last][level] - run_diff;
if (run1 < 0)
goto esc3;
code = get_rl_index(rl, last, run1, level);
if (code == rl->n) {
esc3:
/* third escape */
size+=1+1+6+8;
} else {
/* second escape */
size+= 1+1+ rl->table_vlc[code][1];
}
} else {
/* first escape */
size+= 1+1+ rl->table_vlc[code][1];
}
} else {
size++;
}
return size;
}
av_cold void ff_msmpeg4_encode_init(MpegEncContext *s)
{
static int init_done=0;
int i;
ff_msmpeg4_common_init(s);
if(s->msmpeg4_version>=4){
s->min_qcoeff= -255;
s->max_qcoeff= 255;
}
if (!init_done) {
/* init various encoding tables */
init_done = 1;
init_mv_table(&ff_mv_tables[0]);
init_mv_table(&ff_mv_tables[1]);
for(i=0;i<NB_RL_TABLES;i++)
ff_init_rl(&ff_rl_table[i], ff_static_rl_table_store[i]);
for(i=0; i<NB_RL_TABLES; i++){
int level;
for (level = 1; level <= MAX_LEVEL; level++) {
int run;
for(run=0; run<=MAX_RUN; run++){
int last;
for(last=0; last<2; last++){
rl_length[i][level][run][last]= get_size_of_code(s, &ff_rl_table[ i], last, run, level, 0);
}
}
}
}
}
}
static void find_best_tables(MpegEncContext * s)
{
int i;
int best = 0, best_size = INT_MAX;
int chroma_best = 0, best_chroma_size = INT_MAX;
for(i=0; i<3; i++){
int level;
int chroma_size=0;
int size=0;
if(i>0){// ;)
size++;
chroma_size++;
}
for(level=0; level<=MAX_LEVEL; level++){
int run;
for(run=0; run<=MAX_RUN; run++){
int last;
const int last_size= size + chroma_size;
for(last=0; last<2; last++){
int inter_count = s->ac_stats[0][0][level][run][last] + s->ac_stats[0][1][level][run][last];
int intra_luma_count = s->ac_stats[1][0][level][run][last];
int intra_chroma_count= s->ac_stats[1][1][level][run][last];
if(s->pict_type==AV_PICTURE_TYPE_I){
size += intra_luma_count *rl_length[i ][level][run][last];
chroma_size+= intra_chroma_count*rl_length[i+3][level][run][last];
}else{
size+= intra_luma_count *rl_length[i ][level][run][last]
+intra_chroma_count*rl_length[i+3][level][run][last]
+inter_count *rl_length[i+3][level][run][last];
}
}
if(last_size == size+chroma_size) break;
}
}
if(size<best_size){
best_size= size;
best= i;
}
if(chroma_size<best_chroma_size){
best_chroma_size= chroma_size;
chroma_best= i;
}
}
// printf("type:%d, best:%d, qp:%d, var:%d, mcvar:%d, size:%d //\n",
// s->pict_type, best, s->qscale, s->mb_var_sum, s->mc_mb_var_sum, best_size);
if(s->pict_type==AV_PICTURE_TYPE_P) chroma_best= best;
memset(s->ac_stats, 0, sizeof(int)*(MAX_LEVEL+1)*(MAX_RUN+1)*2*2*2);
s->rl_table_index = best;
s->rl_chroma_table_index= chroma_best;
if(s->pict_type != s->last_non_b_pict_type){
s->rl_table_index= 2;
if(s->pict_type==AV_PICTURE_TYPE_I)
s->rl_chroma_table_index= 1;
else
s->rl_chroma_table_index= 2;
}
}
/* write MSMPEG4 compatible frame header */
void ff_msmpeg4_encode_picture_header(MpegEncContext * s, int picture_number)
{
find_best_tables(s);
avpriv_align_put_bits(&s->pb);
put_bits(&s->pb, 2, s->pict_type - 1);
put_bits(&s->pb, 5, s->qscale);
if(s->msmpeg4_version<=2){
s->rl_table_index = 2;
s->rl_chroma_table_index = 2;
}
s->dc_table_index = 1;
s->mv_table_index = 1; /* only if P frame */
s->use_skip_mb_code = 1; /* only if P frame */
s->per_mb_rl_table = 0;
if(s->msmpeg4_version==4)
s->inter_intra_pred= (s->width*s->height < 320*240 && s->bit_rate<=II_BITRATE && s->pict_type==AV_PICTURE_TYPE_P);
//printf("%d %d %d %d %d\n", s->pict_type, s->bit_rate, s->inter_intra_pred, s->width, s->height);
if (s->pict_type == AV_PICTURE_TYPE_I) {
s->slice_height= s->mb_height/1;
put_bits(&s->pb, 5, 0x16 + s->mb_height/s->slice_height);
if(s->msmpeg4_version==4){
ff_msmpeg4_encode_ext_header(s);
if(s->bit_rate>MBAC_BITRATE)
put_bits(&s->pb, 1, s->per_mb_rl_table);
}
if(s->msmpeg4_version>2){
if(!s->per_mb_rl_table){
ff_msmpeg4_code012(&s->pb, s->rl_chroma_table_index);
ff_msmpeg4_code012(&s->pb, s->rl_table_index);
}
put_bits(&s->pb, 1, s->dc_table_index);
}
} else {
put_bits(&s->pb, 1, s->use_skip_mb_code);
if(s->msmpeg4_version==4 && s->bit_rate>MBAC_BITRATE)
put_bits(&s->pb, 1, s->per_mb_rl_table);
if(s->msmpeg4_version>2){
if(!s->per_mb_rl_table)
ff_msmpeg4_code012(&s->pb, s->rl_table_index);
put_bits(&s->pb, 1, s->dc_table_index);
put_bits(&s->pb, 1, s->mv_table_index);
}
}
s->esc3_level_length= 0;
s->esc3_run_length= 0;
}
void ff_msmpeg4_encode_ext_header(MpegEncContext * s)
{
put_bits(&s->pb, 5, s->avctx->time_base.den / s->avctx->time_base.num); //yes 29.97 -> 29
put_bits(&s->pb, 11, FFMIN(s->bit_rate/1024, 2047));
if(s->msmpeg4_version>=3)
put_bits(&s->pb, 1, s->flipflop_rounding);
else
assert(s->flipflop_rounding==0);
}
void ff_msmpeg4_encode_motion(MpegEncContext * s,
int mx, int my)
{
int code;
MVTable *mv;
/* modulo encoding */
/* WARNING : you cannot reach all the MVs even with the modulo
encoding. This is a somewhat strange compromise they took !!! */
if (mx <= -64)
mx += 64;
else if (mx >= 64)
mx -= 64;
if (my <= -64)
my += 64;
else if (my >= 64)
my -= 64;
mx += 32;
my += 32;
#if 0
if ((unsigned)mx >= 64 ||
(unsigned)my >= 64)
av_log(s->avctx, AV_LOG_ERROR, "error mx=%d my=%d\n", mx, my);
#endif
mv = &ff_mv_tables[s->mv_table_index];
code = mv->table_mv_index[(mx << 6) | my];
put_bits(&s->pb,
mv->table_mv_bits[code],
mv->table_mv_code[code]);
if (code == mv->n) {
/* escape : code literally */
put_bits(&s->pb, 6, mx);
put_bits(&s->pb, 6, my);
}
}
void ff_msmpeg4_handle_slices(MpegEncContext *s){
if (s->mb_x == 0) {
if (s->slice_height && (s->mb_y % s->slice_height) == 0) {
if(s->msmpeg4_version < 4){
ff_mpeg4_clean_buffers(s);
}
s->first_slice_line = 1;
} else {
s->first_slice_line = 0;
}
}
}
static void msmpeg4v2_encode_motion(MpegEncContext * s, int val)
{
int range, bit_size, sign, code, bits;
if (val == 0) {
/* zero vector */
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;
if (val <= -64)
val += 64;
else if (val >= 64)
val -= 64;
if (val >= 0) {
sign = 0;
} else {
val = -val;
sign = 1;
}
val--;
code = (val >> bit_size) + 1;
bits = val & (range - 1);
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);
}
}
}
void ff_msmpeg4_encode_mb(MpegEncContext * s,
DCTELEM block[6][64],
int motion_x, int motion_y)
{
int cbp, coded_cbp, i;
int pred_x, pred_y;
uint8_t *coded_block;
ff_msmpeg4_handle_slices(s);
if (!s->mb_intra) {
/* compute cbp */
cbp = 0;
for (i = 0; i < 6; i++) {
if (s->block_last_index[i] >= 0)
cbp |= 1 << (5 - i);
}
if (s->use_skip_mb_code && (cbp | motion_x | motion_y) == 0) {
/* skip macroblock */
put_bits(&s->pb, 1, 1);
s->last_bits++;
s->misc_bits++;
s->skip_count++;
return;
}
if (s->use_skip_mb_code)
put_bits(&s->pb, 1, 0); /* mb coded */
if(s->msmpeg4_version<=2){
put_bits(&s->pb,
ff_v2_mb_type[cbp&3][1],
ff_v2_mb_type[cbp&3][0]);
if((cbp&3) != 3) coded_cbp= cbp ^ 0x3C;
else coded_cbp= cbp;
put_bits(&s->pb,
ff_h263_cbpy_tab[coded_cbp>>2][1],
ff_h263_cbpy_tab[coded_cbp>>2][0]);
s->misc_bits += get_bits_diff(s);
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{
put_bits(&s->pb,
ff_table_mb_non_intra[cbp + 64][1],
ff_table_mb_non_intra[cbp + 64][0]);
s->misc_bits += get_bits_diff(s);
/* motion vector */
ff_h263_pred_motion(s, 0, 0, &pred_x, &pred_y);
ff_msmpeg4_encode_motion(s, motion_x - pred_x,
motion_y - pred_y);
}
s->mv_bits += get_bits_diff(s);
for (i = 0; i < 6; i++) {
ff_msmpeg4_encode_block(s, block[i], i);
}
s->p_tex_bits += get_bits_diff(s);
} else {
/* compute cbp */
cbp = 0;
coded_cbp = 0;
for (i = 0; i < 6; i++) {
int val, pred;
val = (s->block_last_index[i] >= 1);
cbp |= val << (5 - i);
if (i < 4) {
/* predict value for close blocks only for luma */
pred = ff_msmpeg4_coded_block_pred(s, i, &coded_block);
*coded_block = val;
val = val ^ pred;
}
coded_cbp |= val << (5 - i);
}
if(s->msmpeg4_version<=2){
if (s->pict_type == AV_PICTURE_TYPE_I) {
put_bits(&s->pb,
ff_v2_intra_cbpc[cbp&3][1], ff_v2_intra_cbpc[cbp&3][0]);
} else {
if (s->use_skip_mb_code)
put_bits(&s->pb, 1, 0); /* mb coded */
put_bits(&s->pb,
ff_v2_mb_type[(cbp&3) + 4][1],
ff_v2_mb_type[(cbp&3) + 4][0]);
}
put_bits(&s->pb, 1, 0); /* no AC prediction yet */
put_bits(&s->pb,
ff_h263_cbpy_tab[cbp>>2][1],
ff_h263_cbpy_tab[cbp>>2][0]);
}else{
if (s->pict_type == AV_PICTURE_TYPE_I) {
put_bits(&s->pb,
ff_msmp4_mb_i_table[coded_cbp][1], ff_msmp4_mb_i_table[coded_cbp][0]);
} else {
if (s->use_skip_mb_code)
put_bits(&s->pb, 1, 0); /* mb coded */
put_bits(&s->pb,
ff_table_mb_non_intra[cbp][1],
ff_table_mb_non_intra[cbp][0]);
}
put_bits(&s->pb, 1, 0); /* no AC prediction yet */
if(s->inter_intra_pred){
s->h263_aic_dir=0;
put_bits(&s->pb, ff_table_inter_intra[s->h263_aic_dir][1], ff_table_inter_intra[s->h263_aic_dir][0]);
}
}
s->misc_bits += get_bits_diff(s);
for (i = 0; i < 6; i++) {
ff_msmpeg4_encode_block(s, block[i], i);
}
s->i_tex_bits += get_bits_diff(s);
s->i_count++;
}
}
static void msmpeg4_encode_dc(MpegEncContext * s, int level, int n, int *dir_ptr)
{
int sign, code;
int pred, extquant;
int extrabits = 0;
int16_t *dc_val;
pred = ff_msmpeg4_pred_dc(s, n, &dc_val, dir_ptr);
/* update predictor */
if (n < 4) {
*dc_val = level * s->y_dc_scale;
} else {
*dc_val = level * s->c_dc_scale;
}
/* do the prediction */
level -= pred;
if(s->msmpeg4_version<=2){
if (n < 4) {
put_bits(&s->pb,
ff_v2_dc_lum_table[level + 256][1],
ff_v2_dc_lum_table[level + 256][0]);
}else{
put_bits(&s->pb,
ff_v2_dc_chroma_table[level + 256][1],
ff_v2_dc_chroma_table[level + 256][0]);
}
}else{
sign = 0;
if (level < 0) {
level = -level;
sign = 1;
}
code = level;
if (code > DC_MAX)
code = DC_MAX;
else if( s->msmpeg4_version>=6 ) {
if( s->qscale == 1 ) {
extquant = (level + 3) & 0x3;
code = ((level+3)>>2);
} else if( s->qscale == 2 ) {
extquant = (level + 1) & 0x1;
code = ((level+1)>>1);
}
}
if (s->dc_table_index == 0) {
if (n < 4) {
put_bits(&s->pb, ff_table0_dc_lum[code][1], ff_table0_dc_lum[code][0]);
} else {
put_bits(&s->pb, ff_table0_dc_chroma[code][1], ff_table0_dc_chroma[code][0]);
}
} else {
if (n < 4) {
put_bits(&s->pb, ff_table1_dc_lum[code][1], ff_table1_dc_lum[code][0]);
} else {
put_bits(&s->pb, ff_table1_dc_chroma[code][1], ff_table1_dc_chroma[code][0]);
}
}
if(s->msmpeg4_version>=6 && s->qscale<=2)
extrabits = 3 - s->qscale;
if (code == DC_MAX)
put_bits(&s->pb, 8 + extrabits, level);
else if(extrabits > 0)//== VC1 && s->qscale<=2
put_bits(&s->pb, extrabits, extquant);
if (level != 0) {
put_bits(&s->pb, 1, sign);
}
}
}
/* Encoding of a block. Very similar to MPEG4 except for a different
escape coding (same as H263) and more vlc tables.
*/
void ff_msmpeg4_encode_block(MpegEncContext * s, DCTELEM * block, int n)
{
int level, run, last, i, j, last_index;
int last_non_zero, sign, slevel;
int code, run_diff, dc_pred_dir;
const RLTable *rl;
const uint8_t *scantable;
if (s->mb_intra) {
msmpeg4_encode_dc(s, block[0], n, &dc_pred_dir);
i = 1;
if (n < 4) {
rl = &ff_rl_table[s->rl_table_index];
} else {
rl = &ff_rl_table[3 + s->rl_chroma_table_index];
}
run_diff = s->msmpeg4_version>=4;
scantable= s->intra_scantable.permutated;
} else {
i = 0;
rl = &ff_rl_table[3 + s->rl_table_index];
if(s->msmpeg4_version<=2)
run_diff = 0;
else
run_diff = 1;
scantable= s->inter_scantable.permutated;
}
/* recalculate block_last_index for M$ wmv1 */
if(s->msmpeg4_version>=4 && s->msmpeg4_version<6 && s->block_last_index[n]>0){
for(last_index=63; last_index>=0; last_index--){
if(block[scantable[last_index]]) break;
}
s->block_last_index[n]= last_index;
}else
last_index = s->block_last_index[n];
/* AC coefs */
last_non_zero = i - 1;
for (; i <= last_index; i++) {
j = scantable[i];
level = block[j];
if (level) {
run = i - last_non_zero - 1;
last = (i == last_index);
sign = 0;
slevel = level;
if (level < 0) {
sign = 1;
level = -level;
}
if(level<=MAX_LEVEL && run<=MAX_RUN){
s->ac_stats[s->mb_intra][n>3][level][run][last]++;
}
s->ac_stats[s->mb_intra][n > 3][40][63][0]++; //esc3 like
code = get_rl_index(rl, last, run, level);
put_bits(&s->pb, rl->table_vlc[code][1], rl->table_vlc[code][0]);
if (code == rl->n) {
int level1, run1;
level1 = level - rl->max_level[last][run];
if (level1 < 1)
goto esc2;
code = get_rl_index(rl, last, run, level1);
if (code == rl->n) {
esc2:
put_bits(&s->pb, 1, 0);
if (level > MAX_LEVEL)
goto esc3;
run1 = run - rl->max_run[last][level] - run_diff;
if (run1 < 0)
goto esc3;
code = get_rl_index(rl, last, run1+1, level);
if (s->msmpeg4_version == 4 && code == rl->n)
goto esc3;
code = get_rl_index(rl, last, run1, level);
if (code == rl->n) {
esc3:
/* third escape */
put_bits(&s->pb, 1, 0);
put_bits(&s->pb, 1, last);
if(s->msmpeg4_version>=4){
if(s->esc3_level_length==0){
s->esc3_level_length=8;
s->esc3_run_length= 6;
//ESCLVLSZ + ESCRUNSZ
if(s->qscale<8)
put_bits(&s->pb, 6 + (s->msmpeg4_version>=6), 3);
else
put_bits(&s->pb, 8, 3);
}
put_bits(&s->pb, s->esc3_run_length, run);
put_bits(&s->pb, 1, sign);
put_bits(&s->pb, s->esc3_level_length, level);
}else{
put_bits(&s->pb, 6, run);
put_sbits(&s->pb, 8, slevel);
}
} else {
/* second escape */
put_bits(&s->pb, 1, 1);
put_bits(&s->pb, rl->table_vlc[code][1], rl->table_vlc[code][0]);
put_bits(&s->pb, 1, sign);
}
} else {
/* first escape */
put_bits(&s->pb, 1, 1);
put_bits(&s->pb, rl->table_vlc[code][1], rl->table_vlc[code][0]);
put_bits(&s->pb, 1, sign);
}
} else {
put_bits(&s->pb, 1, sign);
}
last_non_zero = i;
}
}
}

View File

@ -28,7 +28,7 @@ static int pam_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
const AVFrame *pict, int *got_packet) const AVFrame *pict, int *got_packet)
{ {
PNMContext *s = avctx->priv_data; PNMContext *s = avctx->priv_data;
AVFrame * const p = (AVFrame*)&s->picture; AVFrame * const p = &s->picture;
int i, h, w, n, linesize, depth, maxval, ret; int i, h, w, n, linesize, depth, maxval, ret;
const char *tuple_type; const char *tuple_type;
uint8_t *ptr; uint8_t *ptr;

View File

@ -198,8 +198,8 @@ av_cold int ff_pnm_init(AVCodecContext *avctx)
{ {
PNMContext *s = avctx->priv_data; PNMContext *s = avctx->priv_data;
avcodec_get_frame_defaults((AVFrame*)&s->picture); avcodec_get_frame_defaults(&s->picture);
avctx->coded_frame = (AVFrame*)&s->picture; avctx->coded_frame = &s->picture;
return 0; return 0;
} }

View File

@ -31,7 +31,7 @@ static int pnm_decode_frame(AVCodecContext *avctx, void *data,
int buf_size = avpkt->size; int buf_size = avpkt->size;
PNMContext * const s = avctx->priv_data; PNMContext * const s = avctx->priv_data;
AVFrame *picture = data; AVFrame *picture = data;
AVFrame * const p = (AVFrame*)&s->picture; AVFrame * const p = &s->picture;
int i, j, n, linesize, h, upgrade = 0, is_mono = 0; int i, j, n, linesize, h, upgrade = 0, is_mono = 0;
unsigned char *ptr; unsigned char *ptr;
int components, sample_len; int components, sample_len;
@ -184,7 +184,7 @@ static int pnm_decode_frame(AVCodecContext *avctx, void *data,
} }
break; break;
} }
*picture = *(AVFrame*)&s->picture; *picture = s->picture;
*data_size = sizeof(AVPicture); *data_size = sizeof(AVPicture);
return s->bytestream - s->bytestream_start; return s->bytestream - s->bytestream_start;

View File

@ -28,7 +28,7 @@ static int pnm_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
const AVFrame *pict, int *got_packet) const AVFrame *pict, int *got_packet)
{ {
PNMContext *s = avctx->priv_data; PNMContext *s = avctx->priv_data;
AVFrame * const p = (AVFrame*)&s->picture; AVFrame * const p = &s->picture;
int i, h, h1, c, n, linesize, ret; int i, h, h1, c, n, linesize, ret;
uint8_t *ptr, *ptr1, *ptr2; uint8_t *ptr, *ptr1, *ptr2;

View File

@ -75,8 +75,8 @@ static const vec_s8 h_subpel_filters_outer[3] =
dstv = vec_sra(dstv, c7) dstv = vec_sra(dstv, c7)
static av_always_inline static av_always_inline
void put_vp8_epel_h_altivec_core(uint8_t *dst, int dst_stride, void put_vp8_epel_h_altivec_core(uint8_t *dst, ptrdiff_t dst_stride,
uint8_t *src, int src_stride, uint8_t *src, ptrdiff_t src_stride,
int h, int mx, int w, int is6tap) int h, int mx, int w, int is6tap)
{ {
LOAD_H_SUBPEL_FILTER(mx-1); LOAD_H_SUBPEL_FILTER(mx-1);
@ -161,8 +161,8 @@ static const vec_u8 v_subpel_filters[7] =
dstv = vec_sra(dstv, c7) dstv = vec_sra(dstv, c7)
static av_always_inline static av_always_inline
void put_vp8_epel_v_altivec_core(uint8_t *dst, int dst_stride, void put_vp8_epel_v_altivec_core(uint8_t *dst, ptrdiff_t dst_stride,
uint8_t *src, int src_stride, uint8_t *src, ptrdiff_t src_stride,
int h, int my, int w, int is6tap) int h, int my, int w, int is6tap)
{ {
LOAD_V_SUBPEL_FILTER(my-1); LOAD_V_SUBPEL_FILTER(my-1);
@ -226,19 +226,19 @@ void put_vp8_epel_v_altivec_core(uint8_t *dst, int dst_stride,
#define EPEL_FUNCS(WIDTH, TAPS) \ #define EPEL_FUNCS(WIDTH, TAPS) \
static av_noinline \ static av_noinline \
void put_vp8_epel ## WIDTH ## _h ## TAPS ## _altivec(uint8_t *dst, int dst_stride, uint8_t *src, int src_stride, int h, int mx, int my) \ void put_vp8_epel ## WIDTH ## _h ## TAPS ## _altivec(uint8_t *dst, ptrdiff_t dst_stride, uint8_t *src, ptrdiff_t src_stride, int h, int mx, int my) \
{ \ { \
put_vp8_epel_h_altivec_core(dst, dst_stride, src, src_stride, h, mx, WIDTH, TAPS == 6); \ put_vp8_epel_h_altivec_core(dst, dst_stride, src, src_stride, h, mx, WIDTH, TAPS == 6); \
} \ } \
\ \
static av_noinline \ static av_noinline \
void put_vp8_epel ## WIDTH ## _v ## TAPS ## _altivec(uint8_t *dst, int dst_stride, uint8_t *src, int src_stride, int h, int mx, int my) \ void put_vp8_epel ## WIDTH ## _v ## TAPS ## _altivec(uint8_t *dst, ptrdiff_t dst_stride, uint8_t *src, ptrdiff_t src_stride, int h, int mx, int my) \
{ \ { \
put_vp8_epel_v_altivec_core(dst, dst_stride, src, src_stride, h, my, WIDTH, TAPS == 6); \ put_vp8_epel_v_altivec_core(dst, dst_stride, src, src_stride, h, my, WIDTH, TAPS == 6); \
} }
#define EPEL_HV(WIDTH, HTAPS, VTAPS) \ #define EPEL_HV(WIDTH, HTAPS, VTAPS) \
static void put_vp8_epel ## WIDTH ## _h ## HTAPS ## v ## VTAPS ## _altivec(uint8_t *dst, int stride, uint8_t *src, int s, int h, int mx, int my) \ static void put_vp8_epel ## WIDTH ## _h ## HTAPS ## v ## VTAPS ## _altivec(uint8_t *dst, ptrdiff_t stride, uint8_t *src, ptrdiff_t s, int h, int mx, int my) \
{ \ { \
DECLARE_ALIGNED(16, uint8_t, tmp)[(2*WIDTH+5)*16]; \ DECLARE_ALIGNED(16, uint8_t, tmp)[(2*WIDTH+5)*16]; \
if (VTAPS == 6) { \ if (VTAPS == 6) { \
@ -266,7 +266,7 @@ EPEL_HV(4, 4,6)
EPEL_HV(4, 6,4) EPEL_HV(4, 6,4)
EPEL_HV(4, 4,4) EPEL_HV(4, 4,4)
static void put_vp8_pixels16_altivec(uint8_t *dst, int stride, uint8_t *src, int s, int h, int mx, int my) static void put_vp8_pixels16_altivec(uint8_t *dst, ptrdiff_t stride, uint8_t *src, ptrdiff_t s, int h, int mx, int my)
{ {
ff_put_pixels16_altivec(dst, src, stride, h); ff_put_pixels16_altivec(dst, src, stride, h);
} }

View File

@ -40,7 +40,7 @@ static int decode_frame(AVCodecContext *avctx,
const uint8_t *buf_end = avpkt->data + avpkt->size; const uint8_t *buf_end = avpkt->data + avpkt->size;
int buf_size = avpkt->size; int buf_size = avpkt->size;
QdrawContext * const a = avctx->priv_data; QdrawContext * const a = avctx->priv_data;
AVFrame * const p= (AVFrame*)&a->pic; AVFrame * const p = &a->pic;
uint8_t* outdata; uint8_t* outdata;
int colors; int colors;
int i; int i;

View File

@ -259,8 +259,8 @@ static int decode_frame(AVCodecContext *avctx,
const uint8_t *buf = avpkt->data; const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size; int buf_size = avpkt->size;
QpegContext * const a = avctx->priv_data; QpegContext * const a = avctx->priv_data;
AVFrame * p= (AVFrame*)&a->pic; AVFrame * p = &a->pic;
AVFrame * ref= (AVFrame*)&a->ref; AVFrame * ref= &a->ref;
uint8_t* outdata; uint8_t* outdata;
int delta, ret = 0; int delta, ret = 0;
const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, NULL); const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, NULL);
@ -311,8 +311,8 @@ static av_cold int decode_init(AVCodecContext *avctx){
static av_cold int decode_end(AVCodecContext *avctx){ static av_cold int decode_end(AVCodecContext *avctx){
QpegContext * const a = avctx->priv_data; QpegContext * const a = avctx->priv_data;
AVFrame * const p= (AVFrame*)&a->pic; AVFrame * const p = &a->pic;
AVFrame * const ref= (AVFrame*)&a->ref; AVFrame * const ref= &a->ref;
if(p->data[0]) if(p->data[0])
avctx->release_buffer(avctx, p); avctx->release_buffer(avctx, p);

View File

@ -140,8 +140,8 @@ static int raw_decode(AVCodecContext *avctx,
int linesize_align = 4; int linesize_align = 4;
RawVideoContext *context = avctx->priv_data; RawVideoContext *context = avctx->priv_data;
AVFrame * frame = (AVFrame *) data; AVFrame *frame = data;
AVPicture * picture = (AVPicture *) data; AVPicture *picture = data;
frame->pict_type = avctx->coded_frame->pict_type; frame->pict_type = avctx->coded_frame->pict_type;
frame->interlaced_frame = avctx->coded_frame->interlaced_frame; frame->interlaced_frame = avctx->coded_frame->interlaced_frame;

View File

@ -32,7 +32,7 @@
static av_cold int raw_init_encoder(AVCodecContext *avctx) static av_cold int raw_init_encoder(AVCodecContext *avctx)
{ {
avctx->coded_frame = (AVFrame *)avctx->priv_data; avctx->coded_frame = avctx->priv_data;
avcodec_get_frame_defaults(avctx->coded_frame); avcodec_get_frame_defaults(avctx->coded_frame);
avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I; avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
avctx->bits_per_coded_sample = av_get_bits_per_pixel(&av_pix_fmt_descriptors[avctx->pix_fmt]); avctx->bits_per_coded_sample = av_get_bits_per_pixel(&av_pix_fmt_descriptors[avctx->pix_fmt]);

View File

@ -515,9 +515,10 @@ static int rv10_decode_packet(AVCodecContext *avctx,
const uint8_t *buf, int buf_size, int buf_size2) const uint8_t *buf, int buf_size, int buf_size2)
{ {
MpegEncContext *s = avctx->priv_data; MpegEncContext *s = avctx->priv_data;
int mb_count, mb_pos, left, start_mb_x; int mb_count, mb_pos, left, start_mb_x, active_bits_size;
init_get_bits(&s->gb, buf, buf_size*8); active_bits_size = buf_size * 8;
init_get_bits(&s->gb, buf, FFMAX(buf_size, buf_size2) * 8);
if(s->codec_id ==CODEC_ID_RV10) if(s->codec_id ==CODEC_ID_RV10)
mb_count = rv10_decode_picture_header(s); mb_count = rv10_decode_picture_header(s);
else else
@ -601,13 +602,26 @@ static int rv10_decode_packet(AVCodecContext *avctx,
s->mv_type = MV_TYPE_16X16; s->mv_type = MV_TYPE_16X16;
ret=ff_h263_decode_mb(s, s->block); ret=ff_h263_decode_mb(s, s->block);
if (ret != SLICE_ERROR && s->gb.size_in_bits < get_bits_count(&s->gb) && 8*buf_size2 >= get_bits_count(&s->gb)){ // Repeat the slice end check from ff_h263_decode_mb with our active
av_log(avctx, AV_LOG_DEBUG, "update size from %d to %d\n", s->gb.size_in_bits, 8*buf_size2); // bitstream size
s->gb.size_in_bits= 8*buf_size2; if (ret != SLICE_ERROR) {
int v = show_bits(&s->gb, 16);
if (get_bits_count(&s->gb) + 16 > active_bits_size)
v >>= get_bits_count(&s->gb) + 16 - active_bits_size;
if (!v)
ret = SLICE_END;
}
if (ret != SLICE_ERROR && active_bits_size < get_bits_count(&s->gb) &&
8 * buf_size2 >= get_bits_count(&s->gb)) {
active_bits_size = buf_size2 * 8;
av_log(avctx, AV_LOG_DEBUG, "update size from %d to %d\n",
8 * buf_size, active_bits_size);
ret= SLICE_OK; ret= SLICE_OK;
} }
if (ret == SLICE_ERROR || s->gb.size_in_bits < get_bits_count(&s->gb)) { if (ret == SLICE_ERROR || active_bits_size < get_bits_count(&s->gb)) {
av_log(s->avctx, AV_LOG_ERROR, "ERROR at MB %d %d\n", s->mb_x, s->mb_y); av_log(s->avctx, AV_LOG_ERROR, "ERROR at MB %d %d\n", s->mb_x, s->mb_y);
return -1; return -1;
} }
@ -629,7 +643,7 @@ static int rv10_decode_packet(AVCodecContext *avctx,
ff_er_add_slice(s, start_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, ER_MB_END); ff_er_add_slice(s, start_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, ER_MB_END);
return s->gb.size_in_bits; return active_bits_size;
} }
static int get_slice_offset(AVCodecContext *avctx, const uint8_t *buf, int n) static int get_slice_offset(AVCodecContext *avctx, const uint8_t *buf, int n)
@ -661,8 +675,12 @@ static int rv10_decode_frame(AVCodecContext *avctx,
if(!avctx->slice_count){ if(!avctx->slice_count){
slice_count = (*buf++) + 1; slice_count = (*buf++) + 1;
buf_size--;
slices_hdr = buf + 4; slices_hdr = buf + 4;
buf += 8 * slice_count; buf += 8 * slice_count;
buf_size -= 8 * slice_count;
if (buf_size <= 0)
return AVERROR_INVALIDDATA;
}else }else
slice_count = avctx->slice_count; slice_count = avctx->slice_count;
@ -696,9 +714,9 @@ static int rv10_decode_frame(AVCodecContext *avctx,
ff_MPV_frame_end(s); ff_MPV_frame_end(s);
if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) { if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) {
*pict= *(AVFrame*)s->current_picture_ptr; *pict = s->current_picture_ptr->f;
} else if (s->last_picture_ptr != NULL) { } else if (s->last_picture_ptr != NULL) {
*pict= *(AVFrame*)s->last_picture_ptr; *pict = s->last_picture_ptr->f;
} }
if(s->last_picture_ptr || s->low_delay){ if(s->last_picture_ptr || s->low_delay){
@ -708,7 +726,7 @@ static int rv10_decode_frame(AVCodecContext *avctx,
s->current_picture_ptr= NULL; //so we can detect if frame_end wasnt called (find some nicer solution...) s->current_picture_ptr= NULL; //so we can detect if frame_end wasnt called (find some nicer solution...)
} }
return buf_size; return avpkt->size;
} }
AVCodec ff_rv10_decoder = { AVCodec ff_rv10_decoder = {

View File

@ -1660,7 +1660,7 @@ int ff_rv34_decode_frame(AVCodecContext *avctx,
if (buf_size == 0) { if (buf_size == 0) {
/* special case for last picture */ /* special case for last picture */
if (s->low_delay==0 && s->next_picture_ptr) { 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; s->next_picture_ptr = NULL;
*data_size = sizeof(AVFrame); *data_size = sizeof(AVFrame);
@ -1747,9 +1747,9 @@ int ff_rv34_decode_frame(AVCodecContext *avctx,
ff_thread_report_progress(&s->current_picture_ptr->f, INT_MAX, 0); ff_thread_report_progress(&s->current_picture_ptr->f, INT_MAX, 0);
if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) { if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) {
*pict = *(AVFrame*)s->current_picture_ptr; *pict = s->current_picture_ptr->f;
} else if (s->last_picture_ptr != NULL) { } else if (s->last_picture_ptr != NULL) {
*pict = *(AVFrame*)s->last_picture_ptr; *pict = s->last_picture_ptr->f;
} }
if(s->last_picture_ptr || s->low_delay){ if(s->last_picture_ptr || s->low_delay){

View File

@ -735,7 +735,7 @@ static int svq1_decode_frame(AVCodecContext *avctx,
} }
} }
*pict = *(AVFrame*)&s->current_picture; *pict = s->current_picture.f;
ff_MPV_frame_end(s); ff_MPV_frame_end(s);

View File

@ -473,7 +473,7 @@ static av_cold int svq1_encode_init(AVCodecContext *avctx)
SVQ1Context * const s = avctx->priv_data; SVQ1Context * const s = avctx->priv_data;
ff_dsputil_init(&s->dsp, avctx); ff_dsputil_init(&s->dsp, avctx);
avctx->coded_frame= (AVFrame*)&s->picture; avctx->coded_frame = &s->picture;
s->frame_width = avctx->width; s->frame_width = avctx->width;
s->frame_height = avctx->height; s->frame_height = avctx->height;
@ -501,7 +501,7 @@ static int svq1_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
const AVFrame *pict, int *got_packet) const AVFrame *pict, int *got_packet)
{ {
SVQ1Context * const s = avctx->priv_data; SVQ1Context * const s = avctx->priv_data;
AVFrame * const p= (AVFrame*)&s->picture; AVFrame * const p = &s->picture;
AVFrame temp; AVFrame temp;
int i, ret; int i, ret;

View File

@ -958,7 +958,7 @@ static int svq3_decode_frame(AVCodecContext *avctx,
/* special case for last picture */ /* special case for last picture */
if (buf_size == 0) { if (buf_size == 0) {
if (s->next_picture_ptr && !s->low_delay) { if (s->next_picture_ptr && !s->low_delay) {
*(AVFrame *) data = *(AVFrame *) &s->next_picture; *(AVFrame *) data = s->next_picture.f;
s->next_picture_ptr = NULL; s->next_picture_ptr = NULL;
*data_size = sizeof(AVFrame); *data_size = sizeof(AVFrame);
} }
@ -1101,9 +1101,9 @@ static int svq3_decode_frame(AVCodecContext *avctx,
ff_MPV_frame_end(s); ff_MPV_frame_end(s);
if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) { if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) {
*(AVFrame *) data = *(AVFrame *) &s->current_picture; *(AVFrame *) data = s->current_picture.f;
} else { } else {
*(AVFrame *) data = *(AVFrame *) &s->last_picture; *(AVFrame *) data = s->last_picture.f;
} }
/* Do not output the last pic after seeking. */ /* Do not output the last pic after seeking. */

View File

@ -106,7 +106,7 @@ static int decode_frame(AVCodecContext *avctx,
const uint8_t *buf_end = avpkt->data + avpkt->size; const uint8_t *buf_end = avpkt->data + avpkt->size;
TargaContext * const s = avctx->priv_data; TargaContext * const s = avctx->priv_data;
AVFrame *picture = data; AVFrame *picture = data;
AVFrame * const p= (AVFrame*)&s->picture; AVFrame * const p = &s->picture;
uint8_t *dst; uint8_t *dst;
int stride; int stride;
int idlen, pal, compr, y, w, h, bpp, flags; int idlen, pal, compr, y, w, h, bpp, flags;
@ -262,7 +262,7 @@ static int decode_frame(AVCodecContext *avctx,
} }
} }
*picture= *(AVFrame*)&s->picture; *picture = s->picture;
*data_size = sizeof(AVPicture); *data_size = sizeof(AVPicture);
return avpkt->size; return avpkt->size;
@ -271,8 +271,8 @@ static int decode_frame(AVCodecContext *avctx,
static av_cold int targa_init(AVCodecContext *avctx){ static av_cold int targa_init(AVCodecContext *avctx){
TargaContext *s = avctx->priv_data; TargaContext *s = avctx->priv_data;
avcodec_get_frame_defaults((AVFrame*)&s->picture); avcodec_get_frame_defaults(&s->picture);
avctx->coded_frame= (AVFrame*)&s->picture; avctx->coded_frame = &s->picture;
return 0; return 0;
} }

View File

@ -577,7 +577,7 @@ static int decode_frame(AVCodecContext *avctx,
int buf_size = avpkt->size; int buf_size = avpkt->size;
TiffContext * const s = avctx->priv_data; TiffContext * const s = avctx->priv_data;
AVFrame *picture = data; AVFrame *picture = data;
AVFrame * const p= (AVFrame*)&s->picture; AVFrame * const p = &s->picture;
const uint8_t *orig_buf = buf, *end_buf = buf + buf_size; const uint8_t *orig_buf = buf, *end_buf = buf + buf_size;
unsigned off; unsigned off;
int id, le, ret; int id, le, ret;
@ -691,7 +691,7 @@ static int decode_frame(AVCodecContext *avctx,
dst += s->picture.linesize[0]; dst += s->picture.linesize[0];
} }
} }
*picture= *(AVFrame*)&s->picture; *picture = s->picture;
*data_size = sizeof(AVPicture); *data_size = sizeof(AVPicture);
return buf_size; return buf_size;
@ -703,8 +703,8 @@ static av_cold int tiff_init(AVCodecContext *avctx){
s->width = 0; s->width = 0;
s->height = 0; s->height = 0;
s->avctx = avctx; s->avctx = avctx;
avcodec_get_frame_defaults((AVFrame*)&s->picture); avcodec_get_frame_defaults(&s->picture);
avctx->coded_frame= (AVFrame*)&s->picture; avctx->coded_frame = &s->picture;
ff_lzw_decode_open(&s->lzw); ff_lzw_decode_open(&s->lzw);
ff_ccitt_unpack_init(); ff_ccitt_unpack_init();

View File

@ -206,7 +206,7 @@ static int encode_frame(AVCodecContext * avctx, AVPacket *pkt,
const AVFrame *pict, int *got_packet) const AVFrame *pict, int *got_packet)
{ {
TiffEncoderContext *s = avctx->priv_data; TiffEncoderContext *s = avctx->priv_data;
AVFrame *const p = (AVFrame *) & s->picture; AVFrame *const p = &s->picture;
int i; int i;
uint8_t *ptr; uint8_t *ptr;
uint8_t *offset; uint8_t *offset;

View File

@ -767,7 +767,7 @@ static int decode_frame(AVCodecContext *avctx,
const uint8_t *buf = avpkt->data; const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size; int buf_size = avpkt->size;
TM2Context * const l = avctx->priv_data; TM2Context * const l = avctx->priv_data;
AVFrame * const p= (AVFrame*)&l->pic; AVFrame * const p = &l->pic;
int i, skip, t; int i, skip, t;
av_fast_padded_malloc(&l->buffer, &l->buffer_size, buf_size); av_fast_padded_malloc(&l->buffer, &l->buffer_size, buf_size);

View File

@ -50,7 +50,7 @@ static av_cold int ulti_decode_init(AVCodecContext *avctx)
s->height = avctx->height; s->height = avctx->height;
s->blocks = (s->width / 8) * (s->height / 8); s->blocks = (s->width / 8) * (s->height / 8);
avctx->pix_fmt = PIX_FMT_YUV410P; avctx->pix_fmt = PIX_FMT_YUV410P;
avcodec_get_frame_defaults(&s->frame); avctx->coded_frame = &s->frame;
avctx->coded_frame = (AVFrame*) &s->frame; avctx->coded_frame = (AVFrame*) &s->frame;
s->ulti_codebook = ulti_codebook; s->ulti_codebook = ulti_codebook;

View File

@ -1226,6 +1226,12 @@ int attribute_align_arg avcodec_encode_video2(AVCodecContext *avctx,
avpkt->data = new_data; avpkt->data = new_data;
} }
if (!user_packet && avpkt->data) {
uint8_t *new_data = av_realloc(avpkt->data, avpkt->size);
if (new_data)
avpkt->data = new_data;
}
avctx->frame_number++; avctx->frame_number++;
} }

View File

@ -5456,7 +5456,7 @@ static int vc1_decode_frame(AVCodecContext *avctx, void *data,
if (buf_size == 0 || (buf_size == 4 && AV_RB32(buf) == VC1_CODE_ENDOFSEQ)) { if (buf_size == 0 || (buf_size == 4 && AV_RB32(buf) == VC1_CODE_ENDOFSEQ)) {
/* special case for last picture */ /* special case for last picture */
if (s->low_delay == 0 && s->next_picture_ptr) { 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; s->next_picture_ptr = NULL;
*data_size = sizeof(AVFrame); *data_size = sizeof(AVFrame);
@ -5764,9 +5764,9 @@ image:
*data_size = sizeof(AVFrame); *data_size = sizeof(AVFrame);
} else { } else {
if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) { if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) {
*pict = *(AVFrame*)s->current_picture_ptr; *pict = s->current_picture_ptr->f;
} else if (s->last_picture_ptr != NULL) { } else if (s->last_picture_ptr != NULL) {
*pict = *(AVFrame*)s->last_picture_ptr; *pict = s->last_picture_ptr->f;
} }
if (s->last_picture_ptr || s->low_delay) { if (s->last_picture_ptr || s->low_delay) {
*data_size = sizeof(AVFrame); *data_size = sizeof(AVFrame);

View File

@ -49,7 +49,7 @@ static int decode_frame(AVCodecContext *avctx,
int buf_size = avpkt->size; int buf_size = avpkt->size;
VCR1Context * const a = avctx->priv_data; VCR1Context * const a = avctx->priv_data;
AVFrame *picture = data; AVFrame *picture = data;
AVFrame * const p= (AVFrame*)&a->picture; AVFrame * const p = &a->picture;
const uint8_t *bytestream= buf; const uint8_t *bytestream= buf;
int i, x, y; int i, x, y;
@ -116,7 +116,7 @@ static int decode_frame(AVCodecContext *avctx,
} }
} }
*picture= *(AVFrame*)&a->picture; *picture = a->picture;
*data_size = sizeof(AVPicture); *data_size = sizeof(AVPicture);
return buf_size; return buf_size;
@ -126,7 +126,7 @@ static int decode_frame(AVCodecContext *avctx,
static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size, void *data){ static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size, void *data){
VCR1Context * const a = avctx->priv_data; VCR1Context * const a = avctx->priv_data;
AVFrame *pict = data; AVFrame *pict = data;
AVFrame * const p= (AVFrame*)&a->picture; AVFrame * const p = &a->picture;
int size; int size;
*p = *pict; *p = *pict;
@ -146,7 +146,7 @@ static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size,
static av_cold void common_init(AVCodecContext *avctx){ static av_cold void common_init(AVCodecContext *avctx){
VCR1Context * const a = avctx->priv_data; VCR1Context * const a = avctx->priv_data;
avctx->coded_frame= (AVFrame*)&a->picture; avctx->coded_frame = &a->picture;
avcodec_get_frame_defaults(&a->picture); avcodec_get_frame_defaults(&a->picture);
a->avctx= avctx; a->avctx= avctx;
} }

View File

@ -21,7 +21,7 @@
#define AVCODEC_VERSION_H #define AVCODEC_VERSION_H
#define LIBAVCODEC_VERSION_MAJOR 54 #define LIBAVCODEC_VERSION_MAJOR 54
#define LIBAVCODEC_VERSION_MINOR 5 #define LIBAVCODEC_VERSION_MINOR 6
#define LIBAVCODEC_VERSION_MICRO 100 #define LIBAVCODEC_VERSION_MICRO 100
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \

View File

@ -77,7 +77,7 @@ static void vp8_luma_dc_wht_dc_c(DCTELEM block[4][4][16], DCTELEM dc[16])
#define MUL_20091(a) ((((a)*20091) >> 16) + (a)) #define MUL_20091(a) ((((a)*20091) >> 16) + (a))
#define MUL_35468(a) (((a)*35468) >> 16) #define MUL_35468(a) (((a)*35468) >> 16)
static void vp8_idct_add_c(uint8_t *dst, DCTELEM block[16], int stride) static void vp8_idct_add_c(uint8_t *dst, DCTELEM block[16], ptrdiff_t stride)
{ {
int i, t0, t1, t2, t3; int i, t0, t1, t2, t3;
uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
@ -113,7 +113,7 @@ static void vp8_idct_add_c(uint8_t *dst, DCTELEM block[16], int stride)
} }
} }
static void vp8_idct_dc_add_c(uint8_t *dst, DCTELEM block[16], int stride) static void vp8_idct_dc_add_c(uint8_t *dst, DCTELEM block[16], ptrdiff_t stride)
{ {
int i, dc = (block[0] + 4) >> 3; int i, dc = (block[0] + 4) >> 3;
uint8_t *cm = ff_cropTbl + MAX_NEG_CROP + dc; uint8_t *cm = ff_cropTbl + MAX_NEG_CROP + dc;
@ -128,7 +128,7 @@ static void vp8_idct_dc_add_c(uint8_t *dst, DCTELEM block[16], int stride)
} }
} }
static void vp8_idct_dc_add4uv_c(uint8_t *dst, DCTELEM block[4][16], int stride) static void vp8_idct_dc_add4uv_c(uint8_t *dst, DCTELEM block[4][16], ptrdiff_t stride)
{ {
vp8_idct_dc_add_c(dst+stride*0+0, block[0], stride); vp8_idct_dc_add_c(dst+stride*0+0, block[0], stride);
vp8_idct_dc_add_c(dst+stride*0+4, block[1], stride); vp8_idct_dc_add_c(dst+stride*0+4, block[1], stride);
@ -136,7 +136,7 @@ static void vp8_idct_dc_add4uv_c(uint8_t *dst, DCTELEM block[4][16], int stride)
vp8_idct_dc_add_c(dst+stride*4+4, block[3], stride); vp8_idct_dc_add_c(dst+stride*4+4, block[3], stride);
} }
static void vp8_idct_dc_add4y_c(uint8_t *dst, DCTELEM block[4][16], int stride) static void vp8_idct_dc_add4y_c(uint8_t *dst, DCTELEM block[4][16], ptrdiff_t stride)
{ {
vp8_idct_dc_add_c(dst+ 0, block[0], stride); vp8_idct_dc_add_c(dst+ 0, block[0], stride);
vp8_idct_dc_add_c(dst+ 4, block[1], stride); vp8_idct_dc_add_c(dst+ 4, block[1], stride);
@ -157,7 +157,7 @@ static void vp8_idct_dc_add4y_c(uint8_t *dst, DCTELEM block[4][16], int stride)
#define clip_int8(n) (cm[n+0x80]-0x80) #define clip_int8(n) (cm[n+0x80]-0x80)
static av_always_inline void filter_common(uint8_t *p, int stride, int is4tap) static av_always_inline void filter_common(uint8_t *p, ptrdiff_t stride, int is4tap)
{ {
LOAD_PIXELS LOAD_PIXELS
int a, f1, f2; int a, f1, f2;
@ -188,7 +188,7 @@ static av_always_inline void filter_common(uint8_t *p, int stride, int is4tap)
} }
} }
static av_always_inline int simple_limit(uint8_t *p, int stride, int flim) static av_always_inline int simple_limit(uint8_t *p, ptrdiff_t stride, int flim)
{ {
LOAD_PIXELS LOAD_PIXELS
return 2*FFABS(p0-q0) + (FFABS(p1-q1) >> 1) <= flim; return 2*FFABS(p0-q0) + (FFABS(p1-q1) >> 1) <= flim;
@ -198,7 +198,7 @@ static av_always_inline int simple_limit(uint8_t *p, int stride, int flim)
* E - limit at the macroblock edge * E - limit at the macroblock edge
* I - limit for interior difference * I - limit for interior difference
*/ */
static av_always_inline int normal_limit(uint8_t *p, int stride, int E, int I) static av_always_inline int normal_limit(uint8_t *p, ptrdiff_t stride, int E, int I)
{ {
LOAD_PIXELS LOAD_PIXELS
return simple_limit(p, stride, E) return simple_limit(p, stride, E)
@ -207,13 +207,13 @@ static av_always_inline int normal_limit(uint8_t *p, int stride, int E, int I)
} }
// high edge variance // high edge variance
static av_always_inline int hev(uint8_t *p, int stride, int thresh) static av_always_inline int hev(uint8_t *p, ptrdiff_t stride, int thresh)
{ {
LOAD_PIXELS LOAD_PIXELS
return FFABS(p1-p0) > thresh || FFABS(q1-q0) > thresh; return FFABS(p1-p0) > thresh || FFABS(q1-q0) > thresh;
} }
static av_always_inline void filter_mbedge(uint8_t *p, int stride) static av_always_inline void filter_mbedge(uint8_t *p, ptrdiff_t stride)
{ {
int a0, a1, a2, w; int a0, a1, a2, w;
uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
@ -236,7 +236,7 @@ static av_always_inline void filter_mbedge(uint8_t *p, int stride)
} }
#define LOOP_FILTER(dir, size, stridea, strideb, maybe_inline) \ #define LOOP_FILTER(dir, size, stridea, strideb, maybe_inline) \
static maybe_inline void vp8_ ## dir ## _loop_filter ## size ## _c(uint8_t *dst, int stride,\ static maybe_inline void vp8_ ## dir ## _loop_filter ## size ## _c(uint8_t *dst, ptrdiff_t stride,\
int flim_E, int flim_I, int hev_thresh)\ int flim_E, int flim_I, int hev_thresh)\
{\ {\
int i;\ int i;\
@ -250,7 +250,7 @@ static maybe_inline void vp8_ ## dir ## _loop_filter ## size ## _c(uint8_t *dst,
}\ }\
}\ }\
\ \
static maybe_inline void vp8_ ## dir ## _loop_filter ## size ## _inner_c(uint8_t *dst, int stride,\ static maybe_inline void vp8_ ## dir ## _loop_filter ## size ## _inner_c(uint8_t *dst, ptrdiff_t stride,\
int flim_E, int flim_I, int hev_thresh)\ int flim_E, int flim_I, int hev_thresh)\
{\ {\
int i;\ int i;\
@ -270,13 +270,13 @@ LOOP_FILTER(h, 16, stride, 1,)
#define UV_LOOP_FILTER(dir, stridea, strideb) \ #define UV_LOOP_FILTER(dir, stridea, strideb) \
LOOP_FILTER(dir, 8, stridea, strideb, av_always_inline) \ LOOP_FILTER(dir, 8, stridea, strideb, av_always_inline) \
static void vp8_ ## dir ## _loop_filter8uv_c(uint8_t *dstU, uint8_t *dstV, int stride,\ static void vp8_ ## dir ## _loop_filter8uv_c(uint8_t *dstU, uint8_t *dstV, ptrdiff_t stride,\
int fE, int fI, int hev_thresh)\ int fE, int fI, int hev_thresh)\
{\ {\
vp8_ ## dir ## _loop_filter8_c(dstU, stride, fE, fI, hev_thresh);\ vp8_ ## dir ## _loop_filter8_c(dstU, stride, fE, fI, hev_thresh);\
vp8_ ## dir ## _loop_filter8_c(dstV, stride, fE, fI, hev_thresh);\ vp8_ ## dir ## _loop_filter8_c(dstV, stride, fE, fI, hev_thresh);\
}\ }\
static void vp8_ ## dir ## _loop_filter8uv_inner_c(uint8_t *dstU, uint8_t *dstV, int stride,\ static void vp8_ ## dir ## _loop_filter8uv_inner_c(uint8_t *dstU, uint8_t *dstV, ptrdiff_t stride,\
int fE, int fI, int hev_thresh)\ int fE, int fI, int hev_thresh)\
{\ {\
vp8_ ## dir ## _loop_filter8_inner_c(dstU, stride, fE, fI, hev_thresh);\ vp8_ ## dir ## _loop_filter8_inner_c(dstU, stride, fE, fI, hev_thresh);\
@ -286,7 +286,7 @@ static void vp8_ ## dir ## _loop_filter8uv_inner_c(uint8_t *dstU, uint8_t *dstV,
UV_LOOP_FILTER(v, 1, stride) UV_LOOP_FILTER(v, 1, stride)
UV_LOOP_FILTER(h, stride, 1) UV_LOOP_FILTER(h, stride, 1)
static void vp8_v_loop_filter_simple_c(uint8_t *dst, int stride, int flim) static void vp8_v_loop_filter_simple_c(uint8_t *dst, ptrdiff_t stride, int flim)
{ {
int i; int i;
@ -295,7 +295,7 @@ static void vp8_v_loop_filter_simple_c(uint8_t *dst, int stride, int flim)
filter_common(dst+i, stride, 1); filter_common(dst+i, stride, 1);
} }
static void vp8_h_loop_filter_simple_c(uint8_t *dst, int stride, int flim) static void vp8_h_loop_filter_simple_c(uint8_t *dst, ptrdiff_t stride, int flim)
{ {
int i; int i;
@ -315,7 +315,7 @@ static const uint8_t subpel_filters[7][6] = {
}; };
#define PUT_PIXELS(WIDTH) \ #define PUT_PIXELS(WIDTH) \
static void put_vp8_pixels ## WIDTH ##_c(uint8_t *dst, int dststride, uint8_t *src, int srcstride, int h, int x, int y) { \ static void put_vp8_pixels ## WIDTH ##_c(uint8_t *dst, ptrdiff_t dststride, uint8_t *src, ptrdiff_t srcstride, int h, int x, int y) { \
int i; \ int i; \
for (i = 0; i < h; i++, dst+= dststride, src+= srcstride) { \ for (i = 0; i < h; i++, dst+= dststride, src+= srcstride) { \
memcpy(dst, src, WIDTH); \ memcpy(dst, src, WIDTH); \
@ -335,7 +335,7 @@ PUT_PIXELS(4)
F[3]*src[x+1*stride] - F[4]*src[x+2*stride] + 64) >> 7] F[3]*src[x+1*stride] - F[4]*src[x+2*stride] + 64) >> 7]
#define VP8_EPEL_H(SIZE, TAPS) \ #define VP8_EPEL_H(SIZE, TAPS) \
static void put_vp8_epel ## SIZE ## _h ## TAPS ## _c(uint8_t *dst, int dststride, uint8_t *src, int srcstride, int h, int mx, int my) \ static void put_vp8_epel ## SIZE ## _h ## TAPS ## _c(uint8_t *dst, ptrdiff_t dststride, uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my) \
{ \ { \
const uint8_t *filter = subpel_filters[mx-1]; \ const uint8_t *filter = subpel_filters[mx-1]; \
uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; \ uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; \
@ -349,7 +349,7 @@ static void put_vp8_epel ## SIZE ## _h ## TAPS ## _c(uint8_t *dst, int dststride
} \ } \
} }
#define VP8_EPEL_V(SIZE, TAPS) \ #define VP8_EPEL_V(SIZE, TAPS) \
static void put_vp8_epel ## SIZE ## _v ## TAPS ## _c(uint8_t *dst, int dststride, uint8_t *src, int srcstride, int h, int mx, int my) \ static void put_vp8_epel ## SIZE ## _v ## TAPS ## _c(uint8_t *dst, ptrdiff_t dststride, uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my) \
{ \ { \
const uint8_t *filter = subpel_filters[my-1]; \ const uint8_t *filter = subpel_filters[my-1]; \
uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; \ uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; \
@ -363,7 +363,7 @@ static void put_vp8_epel ## SIZE ## _v ## TAPS ## _c(uint8_t *dst, int dststride
} \ } \
} }
#define VP8_EPEL_HV(SIZE, HTAPS, VTAPS) \ #define VP8_EPEL_HV(SIZE, HTAPS, VTAPS) \
static void put_vp8_epel ## SIZE ## _h ## HTAPS ## v ## VTAPS ## _c(uint8_t *dst, int dststride, uint8_t *src, int srcstride, int h, int mx, int my) \ static void put_vp8_epel ## SIZE ## _h ## HTAPS ## v ## VTAPS ## _c(uint8_t *dst, ptrdiff_t dststride, uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my) \
{ \ { \
const uint8_t *filter = subpel_filters[mx-1]; \ const uint8_t *filter = subpel_filters[mx-1]; \
uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; \ uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; \
@ -416,7 +416,7 @@ VP8_EPEL_HV(8, 6, 6)
VP8_EPEL_HV(4, 6, 6) VP8_EPEL_HV(4, 6, 6)
#define VP8_BILINEAR(SIZE) \ #define VP8_BILINEAR(SIZE) \
static void put_vp8_bilinear ## SIZE ## _h_c(uint8_t *dst, int stride, uint8_t *src, int s2, int h, int mx, int my) \ static void put_vp8_bilinear ## SIZE ## _h_c(uint8_t *dst, ptrdiff_t stride, uint8_t *src, ptrdiff_t s2, int h, int mx, int my) \
{ \ { \
int a = 8-mx, b = mx; \ int a = 8-mx, b = mx; \
int x, y; \ int x, y; \
@ -428,7 +428,7 @@ static void put_vp8_bilinear ## SIZE ## _h_c(uint8_t *dst, int stride, uint8_t *
src += stride; \ src += stride; \
} \ } \
} \ } \
static void put_vp8_bilinear ## SIZE ## _v_c(uint8_t *dst, int stride, uint8_t *src, int s2, int h, int mx, int my) \ static void put_vp8_bilinear ## SIZE ## _v_c(uint8_t *dst, ptrdiff_t stride, uint8_t *src, ptrdiff_t s2, int h, int mx, int my) \
{ \ { \
int c = 8-my, d = my; \ int c = 8-my, d = my; \
int x, y; \ int x, y; \
@ -441,7 +441,7 @@ static void put_vp8_bilinear ## SIZE ## _v_c(uint8_t *dst, int stride, uint8_t *
} \ } \
} \ } \
\ \
static void put_vp8_bilinear ## SIZE ## _hv_c(uint8_t *dst, int stride, uint8_t *src, int s2, int h, int mx, int my) \ static void put_vp8_bilinear ## SIZE ## _hv_c(uint8_t *dst, ptrdiff_t stride, uint8_t *src, ptrdiff_t s2, int h, int mx, int my) \
{ \ { \
int a = 8-mx, b = mx; \ int a = 8-mx, b = mx; \
int c = 8-my, d = my; \ int c = 8-my, d = my; \

View File

@ -29,40 +29,44 @@
#include "dsputil.h" #include "dsputil.h"
typedef void (*vp8_mc_func)(uint8_t *dst/*align 8*/, int dstStride, typedef void (*vp8_mc_func)(uint8_t *dst/*align 8*/, ptrdiff_t dstStride,
uint8_t *src/*align 1*/, int srcStride, uint8_t *src/*align 1*/, ptrdiff_t srcStride,
int h, int x, int y); int h, int x, int y);
typedef struct VP8DSPContext { typedef struct VP8DSPContext {
void (*vp8_luma_dc_wht)(DCTELEM block[4][4][16], DCTELEM dc[16]); void (*vp8_luma_dc_wht)(DCTELEM block[4][4][16], DCTELEM dc[16]);
void (*vp8_luma_dc_wht_dc)(DCTELEM block[4][4][16], DCTELEM dc[16]); void (*vp8_luma_dc_wht_dc)(DCTELEM block[4][4][16], DCTELEM dc[16]);
void (*vp8_idct_add)(uint8_t *dst, DCTELEM block[16], int stride); void (*vp8_idct_add)(uint8_t *dst, DCTELEM block[16], ptrdiff_t stride);
void (*vp8_idct_dc_add)(uint8_t *dst, DCTELEM block[16], int stride); void (*vp8_idct_dc_add)(uint8_t *dst, DCTELEM block[16], ptrdiff_t stride);
void (*vp8_idct_dc_add4y)(uint8_t *dst, DCTELEM block[4][16], int stride); void (*vp8_idct_dc_add4y)(uint8_t *dst, DCTELEM block[4][16],
void (*vp8_idct_dc_add4uv)(uint8_t *dst, DCTELEM block[4][16], int stride); ptrdiff_t stride);
void (*vp8_idct_dc_add4uv)(uint8_t *dst, DCTELEM block[4][16],
ptrdiff_t stride);
// loop filter applied to edges between macroblocks // loop filter applied to edges between macroblocks
void (*vp8_v_loop_filter16y)(uint8_t *dst, int stride, void (*vp8_v_loop_filter16y)(uint8_t *dst, ptrdiff_t stride,
int flim_E, int flim_I, int hev_thresh); int flim_E, int flim_I, int hev_thresh);
void (*vp8_h_loop_filter16y)(uint8_t *dst, int stride, void (*vp8_h_loop_filter16y)(uint8_t *dst, ptrdiff_t stride,
int flim_E, int flim_I, int hev_thresh); int flim_E, int flim_I, int hev_thresh);
void (*vp8_v_loop_filter8uv)(uint8_t *dstU, uint8_t *dstV, int stride, void (*vp8_v_loop_filter8uv)(uint8_t *dstU, uint8_t *dstV, ptrdiff_t stride,
int flim_E, int flim_I, int hev_thresh); int flim_E, int flim_I, int hev_thresh);
void (*vp8_h_loop_filter8uv)(uint8_t *dstU, uint8_t *dstV, int stride, void (*vp8_h_loop_filter8uv)(uint8_t *dstU, uint8_t *dstV, ptrdiff_t stride,
int flim_E, int flim_I, int hev_thresh); int flim_E, int flim_I, int hev_thresh);
// loop filter applied to inner macroblock edges // loop filter applied to inner macroblock edges
void (*vp8_v_loop_filter16y_inner)(uint8_t *dst, int stride, void (*vp8_v_loop_filter16y_inner)(uint8_t *dst, ptrdiff_t stride,
int flim_E, int flim_I, int hev_thresh); int flim_E, int flim_I, int hev_thresh);
void (*vp8_h_loop_filter16y_inner)(uint8_t *dst, int stride, void (*vp8_h_loop_filter16y_inner)(uint8_t *dst, ptrdiff_t stride,
int flim_E, int flim_I, int hev_thresh); int flim_E, int flim_I, int hev_thresh);
void (*vp8_v_loop_filter8uv_inner)(uint8_t *dstU, uint8_t *dstV, int stride, void (*vp8_v_loop_filter8uv_inner)(uint8_t *dstU, uint8_t *dstV,
ptrdiff_t stride,
int flim_E, int flim_I, int hev_thresh); int flim_E, int flim_I, int hev_thresh);
void (*vp8_h_loop_filter8uv_inner)(uint8_t *dstU, uint8_t *dstV, int stride, void (*vp8_h_loop_filter8uv_inner)(uint8_t *dstU, uint8_t *dstV,
ptrdiff_t stride,
int flim_E, int flim_I, int hev_thresh); int flim_E, int flim_I, int hev_thresh);
void (*vp8_v_loop_filter_simple)(uint8_t *dst, int stride, int flim); void (*vp8_v_loop_filter_simple)(uint8_t *dst, ptrdiff_t stride, int flim);
void (*vp8_h_loop_filter_simple)(uint8_t *dst, int stride, int flim); void (*vp8_h_loop_filter_simple)(uint8_t *dst, ptrdiff_t stride, int flim);
/** /**
* first dimension: width>>3, height is assumed equal to width * first dimension: width>>3, height is assumed equal to width
@ -76,9 +80,12 @@ typedef struct VP8DSPContext {
vp8_mc_func put_vp8_bilinear_pixels_tab[3][3][3]; vp8_mc_func put_vp8_bilinear_pixels_tab[3][3][3];
} VP8DSPContext; } VP8DSPContext;
void ff_put_vp8_pixels16_c(uint8_t *dst, uint8_t *src, int stride, int h, int x, int y); void ff_put_vp8_pixels16_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride,
void ff_put_vp8_pixels8_c(uint8_t *dst, uint8_t *src, int stride, int h, int x, int y); int h, int x, int y);
void ff_put_vp8_pixels4_c(uint8_t *dst, uint8_t *src, int stride, int h, int x, int y); void ff_put_vp8_pixels8_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride,
int h, int x, int y);
void ff_put_vp8_pixels4_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride,
int h, int x, int y);
void ff_vp8dsp_init(VP8DSPContext *c); void ff_vp8dsp_init(VP8DSPContext *c);
void ff_vp8dsp_init_x86(VP8DSPContext *c); void ff_vp8dsp_init_x86(VP8DSPContext *c);

View File

@ -124,7 +124,7 @@ typedef struct WMACodecContext {
/* output buffer for one frame and the last for IMDCT windowing */ /* output buffer for one frame and the last for IMDCT windowing */
DECLARE_ALIGNED(32, float, frame_out)[MAX_CHANNELS][BLOCK_MAX_SIZE * 2]; DECLARE_ALIGNED(32, float, frame_out)[MAX_CHANNELS][BLOCK_MAX_SIZE * 2];
/* last frame info */ /* last frame info */
uint8_t last_superframe[MAX_CODED_SUPERFRAME_SIZE + 4]; /* padding added */ uint8_t last_superframe[MAX_CODED_SUPERFRAME_SIZE + FF_INPUT_BUFFER_PADDING_SIZE]; /* padding added */
int last_bitoffset; int last_bitoffset;
int last_superframe_len; int last_superframe_len;
float noise_table[NOISE_TAB_SIZE]; float noise_table[NOISE_TAB_SIZE];

View File

@ -863,6 +863,12 @@ static int wma_decode_superframe(AVCodecContext *avctx, void *data,
if (s->use_bit_reservoir) { if (s->use_bit_reservoir) {
bit_offset = get_bits(&s->gb, s->byte_offset_bits + 3); bit_offset = get_bits(&s->gb, s->byte_offset_bits + 3);
if (bit_offset > get_bits_left(&s->gb)) {
av_log(avctx, AV_LOG_ERROR,
"Invalid last frame bit offset %d > buf size %d (%d)\n",
bit_offset, get_bits_left(&s->gb), buf_size);
goto fail;
}
if (s->last_superframe_len > 0) { if (s->last_superframe_len > 0) {
// printf("skip=%d\n", s->last_bitoffset); // printf("skip=%d\n", s->last_bitoffset);
@ -879,9 +885,10 @@ static int wma_decode_superframe(AVCodecContext *avctx, void *data,
if (len > 0) { if (len > 0) {
*q++ = (get_bits)(&s->gb, len) << (8 - len); *q++ = (get_bits)(&s->gb, len) << (8 - len);
} }
memset(q, 0, FF_INPUT_BUFFER_PADDING_SIZE);
/* XXX: bit_offset bits into last frame */ /* XXX: bit_offset bits into last frame */
init_get_bits(&s->gb, s->last_superframe, MAX_CODED_SUPERFRAME_SIZE*8); init_get_bits(&s->gb, s->last_superframe, s->last_superframe_len * 8 + bit_offset);
/* skip unused bits */ /* skip unused bits */
if (s->last_bitoffset > 0) if (s->last_bitoffset > 0)
skip_bits(&s->gb, s->last_bitoffset); skip_bits(&s->gb, s->last_bitoffset);
@ -895,9 +902,9 @@ static int wma_decode_superframe(AVCodecContext *avctx, void *data,
/* read each frame starting from bit_offset */ /* read each frame starting from bit_offset */
pos = bit_offset + 4 + 4 + s->byte_offset_bits + 3; pos = bit_offset + 4 + 4 + s->byte_offset_bits + 3;
if (pos >= MAX_CODED_SUPERFRAME_SIZE * 8) if (pos >= MAX_CODED_SUPERFRAME_SIZE * 8 || pos > buf_size * 8)
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
init_get_bits(&s->gb, buf + (pos >> 3), (MAX_CODED_SUPERFRAME_SIZE - (pos >> 3))*8); init_get_bits(&s->gb, buf + (pos >> 3), (buf_size - (pos >> 3))*8);
len = pos & 7; len = pos & 7;
if (len > 0) if (len > 0)
skip_bits(&s->gb, len); skip_bits(&s->gb, len);

File diff suppressed because it is too large Load Diff

View File

@ -64,7 +64,7 @@ static int decode_frame(AVCodecContext *avctx,
const uint8_t *buf = avpkt->data; const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size; int buf_size = avpkt->size;
WNV1Context * const l = avctx->priv_data; WNV1Context * const l = avctx->priv_data;
AVFrame * const p= (AVFrame*)&l->pic; AVFrame * const p = &l->pic;
unsigned char *Y,*U,*V; unsigned char *Y,*U,*V;
int i, j; int i, j;
int prev_y = 0, prev_u = 0, prev_v = 0; int prev_y = 0, prev_u = 0, prev_v = 0;

View File

@ -619,7 +619,7 @@ MC MC33
%define PAD 12 %define PAD 12
%define COUNT 2 %define COUNT 2
%else %else
%define PAD 0 %define PAD 4
%define COUNT 3 %define COUNT 3
%endif %endif
put_hv%2_10_%1: put_hv%2_10_%1:

View File

@ -29,98 +29,98 @@
/* /*
* MC functions * MC functions
*/ */
extern void ff_put_vp8_epel4_h4_mmxext(uint8_t *dst, int dststride, extern void ff_put_vp8_epel4_h4_mmxext(uint8_t *dst, ptrdiff_t dststride,
uint8_t *src, int srcstride, uint8_t *src, ptrdiff_t srcstride,
int height, int mx, int my); int height, int mx, int my);
extern void ff_put_vp8_epel4_h6_mmxext(uint8_t *dst, int dststride, extern void ff_put_vp8_epel4_h6_mmxext(uint8_t *dst, ptrdiff_t dststride,
uint8_t *src, int srcstride, uint8_t *src, ptrdiff_t srcstride,
int height, int mx, int my); int height, int mx, int my);
extern void ff_put_vp8_epel4_v4_mmxext(uint8_t *dst, int dststride, extern void ff_put_vp8_epel4_v4_mmxext(uint8_t *dst, ptrdiff_t dststride,
uint8_t *src, int srcstride, uint8_t *src, ptrdiff_t srcstride,
int height, int mx, int my); int height, int mx, int my);
extern void ff_put_vp8_epel4_v6_mmxext(uint8_t *dst, int dststride, extern void ff_put_vp8_epel4_v6_mmxext(uint8_t *dst, ptrdiff_t dststride,
uint8_t *src, int srcstride, uint8_t *src, ptrdiff_t srcstride,
int height, int mx, int my); int height, int mx, int my);
extern void ff_put_vp8_epel8_h4_sse2 (uint8_t *dst, int dststride, extern void ff_put_vp8_epel8_h4_sse2 (uint8_t *dst, ptrdiff_t dststride,
uint8_t *src, int srcstride, uint8_t *src, ptrdiff_t srcstride,
int height, int mx, int my); int height, int mx, int my);
extern void ff_put_vp8_epel8_h6_sse2 (uint8_t *dst, int dststride, extern void ff_put_vp8_epel8_h6_sse2 (uint8_t *dst, ptrdiff_t dststride,
uint8_t *src, int srcstride, uint8_t *src, ptrdiff_t srcstride,
int height, int mx, int my); int height, int mx, int my);
extern void ff_put_vp8_epel8_v4_sse2 (uint8_t *dst, int dststride, extern void ff_put_vp8_epel8_v4_sse2 (uint8_t *dst, ptrdiff_t dststride,
uint8_t *src, int srcstride, uint8_t *src, ptrdiff_t srcstride,
int height, int mx, int my); int height, int mx, int my);
extern void ff_put_vp8_epel8_v6_sse2 (uint8_t *dst, int dststride, extern void ff_put_vp8_epel8_v6_sse2 (uint8_t *dst, ptrdiff_t dststride,
uint8_t *src, int srcstride, uint8_t *src, ptrdiff_t srcstride,
int height, int mx, int my); int height, int mx, int my);
extern void ff_put_vp8_epel4_h4_ssse3 (uint8_t *dst, int dststride, extern void ff_put_vp8_epel4_h4_ssse3 (uint8_t *dst, ptrdiff_t dststride,
uint8_t *src, int srcstride, uint8_t *src, ptrdiff_t srcstride,
int height, int mx, int my); int height, int mx, int my);
extern void ff_put_vp8_epel4_h6_ssse3 (uint8_t *dst, int dststride, extern void ff_put_vp8_epel4_h6_ssse3 (uint8_t *dst, ptrdiff_t dststride,
uint8_t *src, int srcstride, uint8_t *src, ptrdiff_t srcstride,
int height, int mx, int my); int height, int mx, int my);
extern void ff_put_vp8_epel4_v4_ssse3 (uint8_t *dst, int dststride, extern void ff_put_vp8_epel4_v4_ssse3 (uint8_t *dst, ptrdiff_t dststride,
uint8_t *src, int srcstride, uint8_t *src, ptrdiff_t srcstride,
int height, int mx, int my); int height, int mx, int my);
extern void ff_put_vp8_epel4_v6_ssse3 (uint8_t *dst, int dststride, extern void ff_put_vp8_epel4_v6_ssse3 (uint8_t *dst, ptrdiff_t dststride,
uint8_t *src, int srcstride, uint8_t *src, ptrdiff_t srcstride,
int height, int mx, int my); int height, int mx, int my);
extern void ff_put_vp8_epel8_h4_ssse3 (uint8_t *dst, int dststride, extern void ff_put_vp8_epel8_h4_ssse3 (uint8_t *dst, ptrdiff_t dststride,
uint8_t *src, int srcstride, uint8_t *src, ptrdiff_t srcstride,
int height, int mx, int my); int height, int mx, int my);
extern void ff_put_vp8_epel8_h6_ssse3 (uint8_t *dst, int dststride, extern void ff_put_vp8_epel8_h6_ssse3 (uint8_t *dst, ptrdiff_t dststride,
uint8_t *src, int srcstride, uint8_t *src, ptrdiff_t srcstride,
int height, int mx, int my); int height, int mx, int my);
extern void ff_put_vp8_epel8_v4_ssse3 (uint8_t *dst, int dststride, extern void ff_put_vp8_epel8_v4_ssse3 (uint8_t *dst, ptrdiff_t dststride,
uint8_t *src, int srcstride, uint8_t *src, ptrdiff_t srcstride,
int height, int mx, int my); int height, int mx, int my);
extern void ff_put_vp8_epel8_v6_ssse3 (uint8_t *dst, int dststride, extern void ff_put_vp8_epel8_v6_ssse3 (uint8_t *dst, ptrdiff_t dststride,
uint8_t *src, int srcstride, uint8_t *src, ptrdiff_t srcstride,
int height, int mx, int my); int height, int mx, int my);
extern void ff_put_vp8_bilinear4_h_mmxext(uint8_t *dst, int dststride, extern void ff_put_vp8_bilinear4_h_mmxext(uint8_t *dst, ptrdiff_t dststride,
uint8_t *src, int srcstride, uint8_t *src, ptrdiff_t srcstride,
int height, int mx, int my); int height, int mx, int my);
extern void ff_put_vp8_bilinear8_h_sse2 (uint8_t *dst, int dststride, extern void ff_put_vp8_bilinear8_h_sse2 (uint8_t *dst, ptrdiff_t dststride,
uint8_t *src, int srcstride, uint8_t *src, ptrdiff_t srcstride,
int height, int mx, int my); int height, int mx, int my);
extern void ff_put_vp8_bilinear4_h_ssse3 (uint8_t *dst, int dststride, extern void ff_put_vp8_bilinear4_h_ssse3 (uint8_t *dst, ptrdiff_t dststride,
uint8_t *src, int srcstride, uint8_t *src, ptrdiff_t srcstride,
int height, int mx, int my); int height, int mx, int my);
extern void ff_put_vp8_bilinear8_h_ssse3 (uint8_t *dst, int dststride, extern void ff_put_vp8_bilinear8_h_ssse3 (uint8_t *dst, ptrdiff_t dststride,
uint8_t *src, int srcstride, uint8_t *src, ptrdiff_t srcstride,
int height, int mx, int my); int height, int mx, int my);
extern void ff_put_vp8_bilinear4_v_mmxext(uint8_t *dst, int dststride, extern void ff_put_vp8_bilinear4_v_mmxext(uint8_t *dst, ptrdiff_t dststride,
uint8_t *src, int srcstride, uint8_t *src, ptrdiff_t srcstride,
int height, int mx, int my); int height, int mx, int my);
extern void ff_put_vp8_bilinear8_v_sse2 (uint8_t *dst, int dststride, extern void ff_put_vp8_bilinear8_v_sse2 (uint8_t *dst, ptrdiff_t dststride,
uint8_t *src, int srcstride, uint8_t *src, ptrdiff_t srcstride,
int height, int mx, int my); int height, int mx, int my);
extern void ff_put_vp8_bilinear4_v_ssse3 (uint8_t *dst, int dststride, extern void ff_put_vp8_bilinear4_v_ssse3 (uint8_t *dst, ptrdiff_t dststride,
uint8_t *src, int srcstride, uint8_t *src, ptrdiff_t srcstride,
int height, int mx, int my); int height, int mx, int my);
extern void ff_put_vp8_bilinear8_v_ssse3 (uint8_t *dst, int dststride, extern void ff_put_vp8_bilinear8_v_ssse3 (uint8_t *dst, ptrdiff_t dststride,
uint8_t *src, int srcstride, uint8_t *src, ptrdiff_t srcstride,
int height, int mx, int my); int height, int mx, int my);
extern void ff_put_vp8_pixels8_mmx (uint8_t *dst, int dststride, extern void ff_put_vp8_pixels8_mmx (uint8_t *dst, ptrdiff_t dststride,
uint8_t *src, int srcstride, uint8_t *src, ptrdiff_t srcstride,
int height, int mx, int my); int height, int mx, int my);
extern void ff_put_vp8_pixels16_mmx(uint8_t *dst, int dststride, extern void ff_put_vp8_pixels16_mmx(uint8_t *dst, ptrdiff_t dststride,
uint8_t *src, int srcstride, uint8_t *src, ptrdiff_t srcstride,
int height, int mx, int my); int height, int mx, int my);
extern void ff_put_vp8_pixels16_sse(uint8_t *dst, int dststride, extern void ff_put_vp8_pixels16_sse(uint8_t *dst, ptrdiff_t dststride,
uint8_t *src, int srcstride, uint8_t *src, ptrdiff_t srcstride,
int height, int mx, int my); int height, int mx, int my);
#define TAP_W16(OPT, FILTERTYPE, TAPTYPE) \ #define TAP_W16(OPT, FILTERTYPE, TAPTYPE) \
static void ff_put_vp8_ ## FILTERTYPE ## 16_ ## TAPTYPE ## _ ## OPT( \ static void ff_put_vp8_ ## FILTERTYPE ## 16_ ## TAPTYPE ## _ ## OPT( \
uint8_t *dst, int dststride, uint8_t *src, \ uint8_t *dst, ptrdiff_t dststride, uint8_t *src, \
int srcstride, int height, int mx, int my) \ ptrdiff_t srcstride, int height, int mx, int my) \
{ \ { \
ff_put_vp8_ ## FILTERTYPE ## 8_ ## TAPTYPE ## _ ## OPT( \ ff_put_vp8_ ## FILTERTYPE ## 8_ ## TAPTYPE ## _ ## OPT( \
dst, dststride, src, srcstride, height, mx, my); \ dst, dststride, src, srcstride, height, mx, my); \
@ -129,8 +129,8 @@ static void ff_put_vp8_ ## FILTERTYPE ## 16_ ## TAPTYPE ## _ ## OPT( \
} }
#define TAP_W8(OPT, FILTERTYPE, TAPTYPE) \ #define TAP_W8(OPT, FILTERTYPE, TAPTYPE) \
static void ff_put_vp8_ ## FILTERTYPE ## 8_ ## TAPTYPE ## _ ## OPT( \ static void ff_put_vp8_ ## FILTERTYPE ## 8_ ## TAPTYPE ## _ ## OPT( \
uint8_t *dst, int dststride, uint8_t *src, \ uint8_t *dst, ptrdiff_t dststride, uint8_t *src, \
int srcstride, int height, int mx, int my) \ ptrdiff_t srcstride, int height, int mx, int my) \
{ \ { \
ff_put_vp8_ ## FILTERTYPE ## 4_ ## TAPTYPE ## _ ## OPT( \ ff_put_vp8_ ## FILTERTYPE ## 4_ ## TAPTYPE ## _ ## OPT( \
dst, dststride, src, srcstride, height, mx, my); \ dst, dststride, src, srcstride, height, mx, my); \
@ -138,6 +138,7 @@ static void ff_put_vp8_ ## FILTERTYPE ## 8_ ## TAPTYPE ## _ ## OPT( \
dst + 4, dststride, src + 4, srcstride, height, mx, my); \ dst + 4, dststride, src + 4, srcstride, height, mx, my); \
} }
#if ARCH_X86_32
TAP_W8 (mmxext, epel, h4) TAP_W8 (mmxext, epel, h4)
TAP_W8 (mmxext, epel, h6) TAP_W8 (mmxext, epel, h6)
TAP_W16(mmxext, epel, h6) TAP_W16(mmxext, epel, h6)
@ -148,6 +149,7 @@ TAP_W8 (mmxext, bilinear, h)
TAP_W16(mmxext, bilinear, h) TAP_W16(mmxext, bilinear, h)
TAP_W8 (mmxext, bilinear, v) TAP_W8 (mmxext, bilinear, v)
TAP_W16(mmxext, bilinear, v) TAP_W16(mmxext, bilinear, v)
#endif
TAP_W16(sse2, epel, h6) TAP_W16(sse2, epel, h6)
TAP_W16(sse2, epel, v6) TAP_W16(sse2, epel, v6)
@ -161,8 +163,8 @@ TAP_W16(ssse3, bilinear, v)
#define HVTAP(OPT, ALIGN, TAPNUMX, TAPNUMY, SIZE, MAXHEIGHT) \ #define HVTAP(OPT, ALIGN, TAPNUMX, TAPNUMY, SIZE, MAXHEIGHT) \
static void ff_put_vp8_epel ## SIZE ## _h ## TAPNUMX ## v ## TAPNUMY ## _ ## OPT( \ static void ff_put_vp8_epel ## SIZE ## _h ## TAPNUMX ## v ## TAPNUMY ## _ ## OPT( \
uint8_t *dst, int dststride, uint8_t *src, \ uint8_t *dst, ptrdiff_t dststride, uint8_t *src, \
int srcstride, int height, int mx, int my) \ ptrdiff_t srcstride, int height, int mx, int my) \
{ \ { \
DECLARE_ALIGNED(ALIGN, uint8_t, tmp)[SIZE * (MAXHEIGHT + TAPNUMY - 1)]; \ DECLARE_ALIGNED(ALIGN, uint8_t, tmp)[SIZE * (MAXHEIGHT + TAPNUMY - 1)]; \
uint8_t *tmpptr = tmp + SIZE * (TAPNUMY / 2 - 1); \ uint8_t *tmpptr = tmp + SIZE * (TAPNUMY / 2 - 1); \
@ -173,15 +175,21 @@ static void ff_put_vp8_epel ## SIZE ## _h ## TAPNUMX ## v ## TAPNUMY ## _ ## OPT
dst, dststride, tmpptr, SIZE, height, mx, my); \ dst, dststride, tmpptr, SIZE, height, mx, my); \
} }
#if ARCH_X86_32
#define HVTAPMMX(x, y) \ #define HVTAPMMX(x, y) \
HVTAP(mmxext, 8, x, y, 4, 8) \ HVTAP(mmxext, 8, x, y, 4, 8) \
HVTAP(mmxext, 8, x, y, 8, 16) HVTAP(mmxext, 8, x, y, 8, 16)
HVTAP(mmxext, 8, 6, 6, 16, 16)
#else
#define HVTAPMMX(x, y) \
HVTAP(mmxext, 8, x, y, 4, 8)
#endif
HVTAPMMX(4, 4) HVTAPMMX(4, 4)
HVTAPMMX(4, 6) HVTAPMMX(4, 6)
HVTAPMMX(6, 4) HVTAPMMX(6, 4)
HVTAPMMX(6, 6) HVTAPMMX(6, 6)
HVTAP(mmxext, 8, 6, 6, 16, 16)
#define HVTAPSSE2(x, y, w) \ #define HVTAPSSE2(x, y, w) \
HVTAP(sse2, 16, x, y, w, 16) \ HVTAP(sse2, 16, x, y, w, 16) \
@ -200,8 +208,8 @@ HVTAP(ssse3, 16, 6, 6, 4, 8)
#define HVBILIN(OPT, ALIGN, SIZE, MAXHEIGHT) \ #define HVBILIN(OPT, ALIGN, SIZE, MAXHEIGHT) \
static void ff_put_vp8_bilinear ## SIZE ## _hv_ ## OPT( \ static void ff_put_vp8_bilinear ## SIZE ## _hv_ ## OPT( \
uint8_t *dst, int dststride, uint8_t *src, \ uint8_t *dst, ptrdiff_t dststride, uint8_t *src, \
int srcstride, int height, int mx, int my) \ ptrdiff_t srcstride, int height, int mx, int my) \
{ \ { \
DECLARE_ALIGNED(ALIGN, uint8_t, tmp)[SIZE * (MAXHEIGHT + 2)]; \ DECLARE_ALIGNED(ALIGN, uint8_t, tmp)[SIZE * (MAXHEIGHT + 2)]; \
ff_put_vp8_bilinear ## SIZE ## _h_ ## OPT( \ ff_put_vp8_bilinear ## SIZE ## _h_ ## OPT( \
@ -211,43 +219,68 @@ static void ff_put_vp8_bilinear ## SIZE ## _hv_ ## OPT( \
} }
HVBILIN(mmxext, 8, 4, 8) HVBILIN(mmxext, 8, 4, 8)
#if ARCH_X86_32
HVBILIN(mmxext, 8, 8, 16) HVBILIN(mmxext, 8, 8, 16)
HVBILIN(mmxext, 8, 16, 16) HVBILIN(mmxext, 8, 16, 16)
#endif
HVBILIN(sse2, 8, 8, 16) HVBILIN(sse2, 8, 8, 16)
HVBILIN(sse2, 8, 16, 16) HVBILIN(sse2, 8, 16, 16)
HVBILIN(ssse3, 8, 4, 8) HVBILIN(ssse3, 8, 4, 8)
HVBILIN(ssse3, 8, 8, 16) HVBILIN(ssse3, 8, 8, 16)
HVBILIN(ssse3, 8, 16, 16) HVBILIN(ssse3, 8, 16, 16)
extern void ff_vp8_idct_dc_add_mmx(uint8_t *dst, DCTELEM block[16], int stride); extern void ff_vp8_idct_dc_add_mmx(uint8_t *dst, DCTELEM block[16],
extern void ff_vp8_idct_dc_add_sse4(uint8_t *dst, DCTELEM block[16], int stride); ptrdiff_t stride);
extern void ff_vp8_idct_dc_add4y_mmx(uint8_t *dst, DCTELEM block[4][16], int stride); extern void ff_vp8_idct_dc_add_sse4(uint8_t *dst, DCTELEM block[16],
extern void ff_vp8_idct_dc_add4y_sse2(uint8_t *dst, DCTELEM block[4][16], int stride); ptrdiff_t stride);
extern void ff_vp8_idct_dc_add4uv_mmx(uint8_t *dst, DCTELEM block[2][16], int stride); extern void ff_vp8_idct_dc_add4y_mmx(uint8_t *dst, DCTELEM block[4][16],
ptrdiff_t stride);
extern void ff_vp8_idct_dc_add4y_sse2(uint8_t *dst, DCTELEM block[4][16],
ptrdiff_t stride);
extern void ff_vp8_idct_dc_add4uv_mmx(uint8_t *dst, DCTELEM block[2][16],
ptrdiff_t stride);
extern void ff_vp8_luma_dc_wht_mmx(DCTELEM block[4][4][16], DCTELEM dc[16]); extern void ff_vp8_luma_dc_wht_mmx(DCTELEM block[4][4][16], DCTELEM dc[16]);
extern void ff_vp8_luma_dc_wht_sse(DCTELEM block[4][4][16], DCTELEM dc[16]); extern void ff_vp8_luma_dc_wht_sse(DCTELEM block[4][4][16], DCTELEM dc[16]);
extern void ff_vp8_idct_add_mmx(uint8_t *dst, DCTELEM block[16], int stride); extern void ff_vp8_idct_add_mmx(uint8_t *dst, DCTELEM block[16],
extern void ff_vp8_idct_add_sse(uint8_t *dst, DCTELEM block[16], int stride); ptrdiff_t stride);
extern void ff_vp8_idct_add_sse(uint8_t *dst, DCTELEM block[16],
ptrdiff_t stride);
#define DECLARE_LOOP_FILTER(NAME)\ #define DECLARE_LOOP_FILTER(NAME)\
extern void ff_vp8_v_loop_filter_simple_ ## NAME(uint8_t *dst, int stride, int flim);\ extern void ff_vp8_v_loop_filter_simple_ ## NAME(uint8_t *dst, \
extern void ff_vp8_h_loop_filter_simple_ ## NAME(uint8_t *dst, int stride, int flim);\ ptrdiff_t stride, \
extern void ff_vp8_v_loop_filter16y_inner_ ## NAME (uint8_t *dst, int stride,\ int flim);\
extern void ff_vp8_h_loop_filter_simple_ ## NAME(uint8_t *dst, \
ptrdiff_t stride, \
int flim);\
extern void ff_vp8_v_loop_filter16y_inner_ ## NAME (uint8_t *dst, \
ptrdiff_t stride,\
int e, int i, int hvt);\ int e, int i, int hvt);\
extern void ff_vp8_h_loop_filter16y_inner_ ## NAME (uint8_t *dst, int stride,\ extern void ff_vp8_h_loop_filter16y_inner_ ## NAME (uint8_t *dst, \
ptrdiff_t stride,\
int e, int i, int hvt);\ int e, int i, int hvt);\
extern void ff_vp8_v_loop_filter8uv_inner_ ## NAME (uint8_t *dstU, uint8_t *dstV,\ extern void ff_vp8_v_loop_filter8uv_inner_ ## NAME (uint8_t *dstU, \
int s, int e, int i, int hvt);\ uint8_t *dstV,\
extern void ff_vp8_h_loop_filter8uv_inner_ ## NAME (uint8_t *dstU, uint8_t *dstV,\ ptrdiff_t s, \
int s, int e, int i, int hvt);\
extern void ff_vp8_v_loop_filter16y_mbedge_ ## NAME(uint8_t *dst, int stride,\
int e, int i, int hvt);\ int e, int i, int hvt);\
extern void ff_vp8_h_loop_filter16y_mbedge_ ## NAME(uint8_t *dst, int stride,\ extern void ff_vp8_h_loop_filter8uv_inner_ ## NAME (uint8_t *dstU, \
uint8_t *dstV,\
ptrdiff_t s, \
int e, int i, int hvt);\ int e, int i, int hvt);\
extern void ff_vp8_v_loop_filter8uv_mbedge_ ## NAME(uint8_t *dstU, uint8_t *dstV,\ extern void ff_vp8_v_loop_filter16y_mbedge_ ## NAME(uint8_t *dst, \
int s, int e, int i, int hvt);\ ptrdiff_t stride,\
extern void ff_vp8_h_loop_filter8uv_mbedge_ ## NAME(uint8_t *dstU, uint8_t *dstV,\ int e, int i, int hvt);\
int s, int e, int i, int hvt); extern void ff_vp8_h_loop_filter16y_mbedge_ ## NAME(uint8_t *dst, \
ptrdiff_t stride,\
int e, int i, int hvt);\
extern void ff_vp8_v_loop_filter8uv_mbedge_ ## NAME(uint8_t *dstU, \
uint8_t *dstV,\
ptrdiff_t s, \
int e, int i, int hvt);\
extern void ff_vp8_h_loop_filter8uv_mbedge_ ## NAME(uint8_t *dstU, \
uint8_t *dstV,\
ptrdiff_t s, \
int e, int i, int hvt);
DECLARE_LOOP_FILTER(mmx) DECLARE_LOOP_FILTER(mmx)
DECLARE_LOOP_FILTER(mmxext) DECLARE_LOOP_FILTER(mmxext)
@ -288,15 +321,18 @@ av_cold void ff_vp8dsp_init_x86(VP8DSPContext* c)
if (mm_flags & AV_CPU_FLAG_MMX) { if (mm_flags & AV_CPU_FLAG_MMX) {
c->vp8_idct_dc_add = ff_vp8_idct_dc_add_mmx; c->vp8_idct_dc_add = ff_vp8_idct_dc_add_mmx;
c->vp8_idct_dc_add4y = ff_vp8_idct_dc_add4y_mmx;
c->vp8_idct_dc_add4uv = ff_vp8_idct_dc_add4uv_mmx; c->vp8_idct_dc_add4uv = ff_vp8_idct_dc_add4uv_mmx;
#if ARCH_X86_32
c->vp8_idct_dc_add4y = ff_vp8_idct_dc_add4y_mmx;
c->vp8_idct_add = ff_vp8_idct_add_mmx; c->vp8_idct_add = ff_vp8_idct_add_mmx;
c->vp8_luma_dc_wht = ff_vp8_luma_dc_wht_mmx; c->vp8_luma_dc_wht = ff_vp8_luma_dc_wht_mmx;
c->put_vp8_epel_pixels_tab[0][0][0] = c->put_vp8_epel_pixels_tab[0][0][0] =
c->put_vp8_bilinear_pixels_tab[0][0][0] = ff_put_vp8_pixels16_mmx; c->put_vp8_bilinear_pixels_tab[0][0][0] = ff_put_vp8_pixels16_mmx;
#endif
c->put_vp8_epel_pixels_tab[1][0][0] = c->put_vp8_epel_pixels_tab[1][0][0] =
c->put_vp8_bilinear_pixels_tab[1][0][0] = ff_put_vp8_pixels8_mmx; c->put_vp8_bilinear_pixels_tab[1][0][0] = ff_put_vp8_pixels8_mmx;
#if ARCH_X86_32
c->vp8_v_loop_filter_simple = ff_vp8_v_loop_filter_simple_mmx; c->vp8_v_loop_filter_simple = ff_vp8_v_loop_filter_simple_mmx;
c->vp8_h_loop_filter_simple = ff_vp8_h_loop_filter_simple_mmx; c->vp8_h_loop_filter_simple = ff_vp8_h_loop_filter_simple_mmx;
@ -309,17 +345,19 @@ av_cold void ff_vp8dsp_init_x86(VP8DSPContext* c)
c->vp8_h_loop_filter16y = ff_vp8_h_loop_filter16y_mbedge_mmx; c->vp8_h_loop_filter16y = ff_vp8_h_loop_filter16y_mbedge_mmx;
c->vp8_v_loop_filter8uv = ff_vp8_v_loop_filter8uv_mbedge_mmx; c->vp8_v_loop_filter8uv = ff_vp8_v_loop_filter8uv_mbedge_mmx;
c->vp8_h_loop_filter8uv = ff_vp8_h_loop_filter8uv_mbedge_mmx; c->vp8_h_loop_filter8uv = ff_vp8_h_loop_filter8uv_mbedge_mmx;
#endif
} }
/* note that 4-tap width=16 functions are missing because w=16 /* note that 4-tap width=16 functions are missing because w=16
* is only used for luma, and luma is always a copy or sixtap. */ * is only used for luma, and luma is always a copy or sixtap. */
if (mm_flags & AV_CPU_FLAG_MMX2) { if (mm_flags & AV_CPU_FLAG_MMX2) {
VP8_MC_FUNC(2, 4, mmxext);
VP8_BILINEAR_MC_FUNC(2, 4, mmxext);
#if ARCH_X86_32
VP8_LUMA_MC_FUNC(0, 16, mmxext); VP8_LUMA_MC_FUNC(0, 16, mmxext);
VP8_MC_FUNC(1, 8, mmxext); VP8_MC_FUNC(1, 8, mmxext);
VP8_MC_FUNC(2, 4, mmxext);
VP8_BILINEAR_MC_FUNC(0, 16, mmxext); VP8_BILINEAR_MC_FUNC(0, 16, mmxext);
VP8_BILINEAR_MC_FUNC(1, 8, mmxext); VP8_BILINEAR_MC_FUNC(1, 8, mmxext);
VP8_BILINEAR_MC_FUNC(2, 4, mmxext);
c->vp8_v_loop_filter_simple = ff_vp8_v_loop_filter_simple_mmxext; c->vp8_v_loop_filter_simple = ff_vp8_v_loop_filter_simple_mmxext;
c->vp8_h_loop_filter_simple = ff_vp8_h_loop_filter_simple_mmxext; c->vp8_h_loop_filter_simple = ff_vp8_h_loop_filter_simple_mmxext;
@ -333,6 +371,7 @@ av_cold void ff_vp8dsp_init_x86(VP8DSPContext* c)
c->vp8_h_loop_filter16y = ff_vp8_h_loop_filter16y_mbedge_mmxext; c->vp8_h_loop_filter16y = ff_vp8_h_loop_filter16y_mbedge_mmxext;
c->vp8_v_loop_filter8uv = ff_vp8_v_loop_filter8uv_mbedge_mmxext; c->vp8_v_loop_filter8uv = ff_vp8_v_loop_filter8uv_mbedge_mmxext;
c->vp8_h_loop_filter8uv = ff_vp8_h_loop_filter8uv_mbedge_mmxext; c->vp8_h_loop_filter8uv = ff_vp8_h_loop_filter8uv_mbedge_mmxext;
#endif
} }
if (mm_flags & AV_CPU_FLAG_SSE) { if (mm_flags & AV_CPU_FLAG_SSE) {

View File

@ -865,6 +865,7 @@ cglobal put_vp8_pixels8_mmx, 5,5
jg .nextrow jg .nextrow
REP_RET REP_RET
%if ARCH_X86_32
cglobal put_vp8_pixels16_mmx, 5,5 cglobal put_vp8_pixels16_mmx, 5,5
.nextrow: .nextrow:
movq mm0, [r2+r3*0+0] movq mm0, [r2+r3*0+0]
@ -880,6 +881,7 @@ cglobal put_vp8_pixels16_mmx, 5,5
sub r4d, 2 sub r4d, 2
jg .nextrow jg .nextrow
REP_RET REP_RET
%endif
cglobal put_vp8_pixels16_sse, 5,5,2 cglobal put_vp8_pixels16_sse, 5,5,2
.nextrow: .nextrow:
@ -973,6 +975,7 @@ cglobal vp8_idct_dc_add_sse4, 3, 3, 6
; void vp8_idct_dc_add4y_<opt>(uint8_t *dst, DCTELEM block[4][16], int stride); ; void vp8_idct_dc_add4y_<opt>(uint8_t *dst, DCTELEM block[4][16], int stride);
;----------------------------------------------------------------------------- ;-----------------------------------------------------------------------------
%if ARCH_X86_32
INIT_MMX INIT_MMX
cglobal vp8_idct_dc_add4y_mmx, 3, 3 cglobal vp8_idct_dc_add4y_mmx, 3, 3
; load data ; load data
@ -1007,6 +1010,7 @@ cglobal vp8_idct_dc_add4y_mmx, 3, 3
ADD_DC m0, m6, 0, mova ADD_DC m0, m6, 0, mova
ADD_DC m1, m7, 8, mova ADD_DC m1, m7, 8, mova
RET RET
%endif
INIT_XMM INIT_XMM
cglobal vp8_idct_dc_add4y_sse2, 3, 3, 6 cglobal vp8_idct_dc_add4y_sse2, 3, 3, 6
@ -1152,7 +1156,9 @@ cglobal vp8_idct_add_%1, 3, 3
RET RET
%endmacro %endmacro
%if ARCH_X86_32
VP8_IDCT_ADD mmx VP8_IDCT_ADD mmx
%endif
VP8_IDCT_ADD sse VP8_IDCT_ADD sse
;----------------------------------------------------------------------------- ;-----------------------------------------------------------------------------
@ -1217,7 +1223,9 @@ cglobal vp8_luma_dc_wht_%1, 2,3
%endmacro %endmacro
INIT_MMX INIT_MMX
%if ARCH_X86_32
VP8_DC_WHT mmx VP8_DC_WHT mmx
%endif
VP8_DC_WHT sse VP8_DC_WHT sse
;----------------------------------------------------------------------------- ;-----------------------------------------------------------------------------
@ -1610,6 +1618,7 @@ cglobal vp8_%2_loop_filter_simple_%1, 3, %3, %4
%endif %endif
%endmacro %endmacro
%if ARCH_X86_32
INIT_MMX INIT_MMX
%define SPLATB_REG SPLATB_REG_MMX %define SPLATB_REG SPLATB_REG_MMX
SIMPLE_LOOPFILTER mmx, v, 4, 0 SIMPLE_LOOPFILTER mmx, v, 4, 0
@ -1617,6 +1626,8 @@ SIMPLE_LOOPFILTER mmx, h, 5, 0
%define SPLATB_REG SPLATB_REG_MMXEXT %define SPLATB_REG SPLATB_REG_MMXEXT
SIMPLE_LOOPFILTER mmxext, v, 4, 0 SIMPLE_LOOPFILTER mmxext, v, 4, 0
SIMPLE_LOOPFILTER mmxext, h, 5, 0 SIMPLE_LOOPFILTER mmxext, h, 5, 0
%endif
INIT_XMM INIT_XMM
%define SPLATB_REG SPLATB_REG_SSE2 %define SPLATB_REG SPLATB_REG_SSE2
%define WRITE_8W WRITE_8W_SSE2 %define WRITE_8W WRITE_8W_SSE2
@ -2118,6 +2129,7 @@ cglobal vp8_%2_loop_filter16y_inner_%1, 5, %3, %5
RET RET
%endmacro %endmacro
%if ARCH_X86_32
INIT_MMX INIT_MMX
%define SPLATB_REG SPLATB_REG_MMX %define SPLATB_REG SPLATB_REG_MMX
INNER_LOOPFILTER mmx, v, 6, 16, 0 INNER_LOOPFILTER mmx, v, 6, 16, 0
@ -2130,6 +2142,7 @@ INNER_LOOPFILTER mmxext, v, 6, 16, 0
INNER_LOOPFILTER mmxext, h, 6, 16, 0 INNER_LOOPFILTER mmxext, h, 6, 16, 0
INNER_LOOPFILTER mmxext, v, 6, 8, 0 INNER_LOOPFILTER mmxext, v, 6, 8, 0
INNER_LOOPFILTER mmxext, h, 6, 8, 0 INNER_LOOPFILTER mmxext, h, 6, 8, 0
%endif
INIT_XMM INIT_XMM
%define SPLATB_REG SPLATB_REG_SSE2 %define SPLATB_REG SPLATB_REG_SSE2
@ -2814,6 +2827,7 @@ cglobal vp8_%2_loop_filter16y_mbedge_%1, 5, %3, %5
RET RET
%endmacro %endmacro
%if ARCH_X86_32
INIT_MMX INIT_MMX
%define SPLATB_REG SPLATB_REG_MMX %define SPLATB_REG SPLATB_REG_MMX
MBEDGE_LOOPFILTER mmx, v, 6, 16, 0 MBEDGE_LOOPFILTER mmx, v, 6, 16, 0
@ -2826,6 +2840,7 @@ MBEDGE_LOOPFILTER mmxext, v, 6, 16, 0
MBEDGE_LOOPFILTER mmxext, h, 6, 16, 0 MBEDGE_LOOPFILTER mmxext, h, 6, 16, 0
MBEDGE_LOOPFILTER mmxext, v, 6, 8, 0 MBEDGE_LOOPFILTER mmxext, v, 6, 8, 0
MBEDGE_LOOPFILTER mmxext, h, 6, 8, 0 MBEDGE_LOOPFILTER mmxext, h, 6, 8, 0
%endif
INIT_XMM INIT_XMM
%define SPLATB_REG SPLATB_REG_SSE2 %define SPLATB_REG SPLATB_REG_SSE2

View File

@ -45,7 +45,7 @@ static int decode_frame(AVCodecContext *avctx,
const uint8_t *buf = avpkt->data; const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size; int buf_size = avpkt->size;
VideoXLContext * const a = avctx->priv_data; VideoXLContext * const a = avctx->priv_data;
AVFrame * const p= (AVFrame*)&a->pic; AVFrame * const p = &a->pic;
uint8_t *Y, *U, *V; uint8_t *Y, *U, *V;
int i, j; int i, j;
int stride; int stride;

View File

@ -313,7 +313,7 @@ static av_cold int encode_init(AVCodecContext *avctx)
return -1; return -1;
} }
avctx->coded_frame = (AVFrame*)&c->pic; avctx->coded_frame = &c->pic;
return 0; return 0;
} }

View File

@ -188,8 +188,8 @@ static int avs_read_packet(AVFormatContext * s, AVPacket * pkt)
avs->st_video->codec->height = avs->height; avs->st_video->codec->height = avs->height;
avs->st_video->codec->bits_per_coded_sample=avs->bits_per_sample; avs->st_video->codec->bits_per_coded_sample=avs->bits_per_sample;
avs->st_video->nb_frames = avs->nb_frames; avs->st_video->nb_frames = avs->nb_frames;
avs->st_video->codec->time_base = (AVRational) { avs->st_video->r_frame_rate = avs->st_video->avg_frame_rate =
1, avs->fps}; (AVRational){avs->fps, 1};
} }
return avs_read_video_packet(s, pkt, type, sub_type, size, return avs_read_video_packet(s, pkt, type, sub_type, size,
palette, palette_size); palette, palette_size);

View File

@ -283,6 +283,20 @@ static int process_video_header_vp6(AVFormatContext *s)
return 1; return 1;
} }
static int process_video_header_cmv(AVFormatContext *s)
{
EaDemuxContext *ea = s->priv_data;
int fps;
avio_skip(s->pb, 10);
fps = avio_rl16(s->pb);
if (fps)
ea->time_base = (AVRational){1, fps};
ea->video_codec = CODEC_ID_CMV;
return 0;
}
/* /*
* Process EA file header * Process EA file header
* Returns 1 if the EA file is valid and successfully opened, 0 otherwise * Returns 1 if the EA file is valid and successfully opened, 0 otherwise
@ -330,7 +344,7 @@ static int process_ea_header(AVFormatContext *s) {
break; break;
case MVIh_TAG : case MVIh_TAG :
ea->video_codec = CODEC_ID_CMV; err = process_video_header_cmv(s);
break; break;
case kVGT_TAG: case kVGT_TAG:
@ -418,10 +432,12 @@ static int ea_read_header(AVFormatContext *s)
if (st->codec->codec_id == CODEC_ID_MPEG2VIDEO) if (st->codec->codec_id == CODEC_ID_MPEG2VIDEO)
st->need_parsing = AVSTREAM_PARSE_HEADERS; st->need_parsing = AVSTREAM_PARSE_HEADERS;
st->codec->codec_tag = 0; /* no fourcc */ st->codec->codec_tag = 0; /* no fourcc */
if (ea->time_base.num)
avpriv_set_pts_info(st, 64, ea->time_base.num, ea->time_base.den);
st->codec->width = ea->width; st->codec->width = ea->width;
st->codec->height = ea->height; st->codec->height = ea->height;
if (ea->time_base.num)
avpriv_set_pts_info(st, 64, ea->time_base.num, ea->time_base.den);
st->r_frame_rate = st->avg_frame_rate = (AVRational){ea->time_base.den,
ea->time_base.num};
} }
if (ea->audio_codec) { if (ea->audio_codec) {

View File

@ -1921,15 +1921,31 @@ static int matroska_parse_block(MatroskaDemuxContext *matroska, uint8_t *data,
if (!track->audio.pkt_cnt) { if (!track->audio.pkt_cnt) {
if (track->audio.sub_packet_cnt == 0) if (track->audio.sub_packet_cnt == 0)
track->audio.buf_timecode = timecode; track->audio.buf_timecode = timecode;
if (st->codec->codec_id == CODEC_ID_RA_288) if (st->codec->codec_id == CODEC_ID_RA_288) {
if (size < cfs * h / 2) {
av_log(matroska->ctx, AV_LOG_ERROR,
"Corrupt int4 RM-style audio packet size\n");
return AVERROR_INVALIDDATA;
}
for (x=0; x<h/2; x++) for (x=0; x<h/2; x++)
memcpy(track->audio.buf+x*2*w+y*cfs, memcpy(track->audio.buf+x*2*w+y*cfs,
data+x*cfs, cfs); data+x*cfs, cfs);
else if (st->codec->codec_id == CODEC_ID_SIPR) } else if (st->codec->codec_id == CODEC_ID_SIPR) {
if (size < w) {
av_log(matroska->ctx, AV_LOG_ERROR,
"Corrupt sipr RM-style audio packet size\n");
return AVERROR_INVALIDDATA;
}
memcpy(track->audio.buf + y*w, data, w); memcpy(track->audio.buf + y*w, data, w);
else } else {
if (size < sps * w / sps) {
av_log(matroska->ctx, AV_LOG_ERROR,
"Corrupt generic RM-style audio packet size\n");
return AVERROR_INVALIDDATA;
}
for (x=0; x<w/sps; x++) for (x=0; x<w/sps; x++)
memcpy(track->audio.buf+sps*(h*x+((h+1)/2)*(y&1)+(y>>1)), data+x*sps, sps); memcpy(track->audio.buf+sps*(h*x+((h+1)/2)*(y&1)+(y>>1)), data+x*sps, sps);
}
if (++track->audio.sub_packet_cnt >= h) { if (++track->audio.sub_packet_cnt >= h) {
if (st->codec->codec_id == CODEC_ID_SIPR) if (st->codec->codec_id == CODEC_ID_SIPR)

View File

@ -84,9 +84,7 @@ ogm_header(AVFormatContext *s, int idx)
if(st->codec->codec_type == AVMEDIA_TYPE_VIDEO){ if(st->codec->codec_type == AVMEDIA_TYPE_VIDEO){
st->codec->width = bytestream_get_le32(&p); st->codec->width = bytestream_get_le32(&p);
st->codec->height = bytestream_get_le32(&p); st->codec->height = bytestream_get_le32(&p);
st->codec->time_base.den = spu * 10000000; avpriv_set_pts_info(st, 64, spu * 10000000, time_unit);
st->codec->time_base.num = time_unit;
avpriv_set_pts_info(st, 64, st->codec->time_base.num, st->codec->time_base.den);
} else { } else {
st->codec->channels = bytestream_get_le16(&p); st->codec->channels = bytestream_get_le16(&p);
p += 2; /* block_align */ p += 2; /* block_align */
@ -132,8 +130,7 @@ ogm_dshow_header(AVFormatContext *s, int idx)
if(t == 0x05589f80){ if(t == 0x05589f80){
st->codec->codec_type = AVMEDIA_TYPE_VIDEO; st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = ff_codec_get_id(ff_codec_bmp_tags, AV_RL32(p + 68)); st->codec->codec_id = ff_codec_get_id(ff_codec_bmp_tags, AV_RL32(p + 68));
st->codec->time_base.den = 10000000; avpriv_set_pts_info(st, 64, AV_RL64(p + 164), 10000000);
st->codec->time_base.num = AV_RL64(p + 164);
st->codec->width = AV_RL32(p + 176); st->codec->width = AV_RL32(p + 176);
st->codec->height = AV_RL32(p + 180); st->codec->height = AV_RL32(p + 180);
} else if(t == 0x05589f81){ } else if(t == 0x05589f81){

View File

@ -56,6 +56,7 @@ theora_header (AVFormatContext * s, int idx)
if (os->buf[os->pstart] == 0x80) { if (os->buf[os->pstart] == 0x80) {
GetBitContext gb; GetBitContext gb;
int width, height; int width, height;
AVRational timebase;
init_get_bits(&gb, os->buf + os->pstart, os->psize*8); init_get_bits(&gb, os->buf + os->pstart, os->psize*8);
@ -85,14 +86,14 @@ theora_header (AVFormatContext * s, int idx)
skip_bits(&gb, 16); skip_bits(&gb, 16);
} }
st->codec->time_base.den = get_bits_long(&gb, 32); timebase.den = get_bits_long(&gb, 32);
st->codec->time_base.num = get_bits_long(&gb, 32); timebase.num = get_bits_long(&gb, 32);
if (!(st->codec->time_base.num > 0 && st->codec->time_base.den > 0)) { if (!(timebase.num > 0 && timebase.den > 0)) {
av_log(s, AV_LOG_WARNING, "Invalid time base in theora stream, assuming 25 FPS\n"); av_log(s, AV_LOG_WARNING, "Invalid time base in theora stream, assuming 25 FPS\n");
st->codec->time_base.num = 1; timebase.num = 1;
st->codec->time_base.den = 25; timebase.den = 25;
} }
avpriv_set_pts_info(st, 64, st->codec->time_base.num, st->codec->time_base.den); avpriv_set_pts_info(st, 64, timebase.num, timebase.den);
st->sample_aspect_ratio.num = get_bits_long(&gb, 24); st->sample_aspect_ratio.num = get_bits_long(&gb, 24);
st->sample_aspect_ratio.den = get_bits_long(&gb, 24); st->sample_aspect_ratio.den = get_bits_long(&gb, 24);

View File

@ -57,6 +57,7 @@ static int r3d_read_red1(AVFormatContext *s)
char filename[258]; char filename[258];
int tmp; int tmp;
int av_unused tmp2; int av_unused tmp2;
AVRational framerate;
if (!st) if (!st)
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
@ -84,8 +85,10 @@ static int r3d_read_red1(AVFormatContext *s)
tmp = avio_rb16(s->pb); // unknown tmp = avio_rb16(s->pb); // unknown
av_dlog(s, "unknown2 %d\n", tmp); av_dlog(s, "unknown2 %d\n", tmp);
st->codec->time_base.den = avio_rb16(s->pb); framerate.num = avio_rb16(s->pb);
st->codec->time_base.num = avio_rb16(s->pb); framerate.den = avio_rb16(s->pb);
if (framerate.num && framerate.den)
st->r_frame_rate = st->avg_frame_rate = framerate;
tmp = avio_r8(s->pb); // audio channels tmp = avio_r8(s->pb); // audio channels
av_dlog(s, "audio channels %d\n", tmp); av_dlog(s, "audio channels %d\n", tmp);
@ -107,7 +110,7 @@ static int r3d_read_red1(AVFormatContext *s)
av_dlog(s, "resolution %dx%d\n", st->codec->width, st->codec->height); av_dlog(s, "resolution %dx%d\n", st->codec->width, st->codec->height);
av_dlog(s, "timescale %d\n", st->time_base.den); av_dlog(s, "timescale %d\n", st->time_base.den);
av_dlog(s, "frame rate %d/%d\n", av_dlog(s, "frame rate %d/%d\n",
st->codec->time_base.num, st->codec->time_base.den); framerate.num, framerate.den);
return 0; return 0;
} }
@ -132,9 +135,11 @@ static int r3d_read_rdvo(AVFormatContext *s, Atom *atom)
av_dlog(s, "video offset %d: %#x\n", i, r3d->video_offsets[i]); av_dlog(s, "video offset %d: %#x\n", i, r3d->video_offsets[i]);
} }
if (st->codec->time_base.den) if (st->r_frame_rate.num)
st->duration = (uint64_t)r3d->video_offsets_count* st->duration = av_rescale_q(r3d->video_offsets_count,
st->time_base.den*st->codec->time_base.num/st->codec->time_base.den; (AVRational){st->r_frame_rate.den,
st->r_frame_rate.num},
st->time_base);
av_dlog(s, "duration %"PRId64"\n", st->duration); av_dlog(s, "duration %"PRId64"\n", st->duration);
return 0; return 0;
@ -257,9 +262,9 @@ static int r3d_read_redv(AVFormatContext *s, AVPacket *pkt, Atom *atom)
pkt->stream_index = 0; pkt->stream_index = 0;
pkt->dts = dts; pkt->dts = dts;
if (st->codec->time_base.den) if (st->r_frame_rate.num)
pkt->duration = (uint64_t)st->time_base.den* pkt->duration = (uint64_t)st->time_base.den*
st->codec->time_base.num/st->codec->time_base.den; st->r_frame_rate.den/st->r_frame_rate.num;
av_dlog(s, "pkt dts %"PRId64" duration %d\n", pkt->dts, pkt->duration); av_dlog(s, "pkt dts %"PRId64" duration %d\n", pkt->dts, pkt->duration);
return 0; return 0;
@ -357,11 +362,11 @@ static int r3d_seek(AVFormatContext *s, int stream_index, int64_t sample_time, i
R3DContext *r3d = s->priv_data; R3DContext *r3d = s->priv_data;
int frame_num; int frame_num;
if (!st->codec->time_base.num || !st->time_base.den) if (!st->r_frame_rate.num)
return -1; return -1;
frame_num = sample_time*st->codec->time_base.den/ frame_num = av_rescale_q(sample_time, st->time_base,
((int64_t)st->codec->time_base.num*st->time_base.den); (AVRational){st->r_frame_rate.den, st->r_frame_rate.num});
av_dlog(s, "seek frame num %d timestamp %"PRId64"\n", av_dlog(s, "seek frame num %d timestamp %"PRId64"\n",
frame_num, sample_time); frame_num, sample_time);

View File

@ -439,10 +439,8 @@ static int rm_read_header(AVFormatContext *s)
return AVERROR(EIO); return AVERROR(EIO);
} }
avio_rb32(pb); /* header size */ tag_size = avio_rb32(pb);
avio_rb16(pb); avio_skip(pb, tag_size - 8);
avio_rb32(pb);
avio_rb32(pb); /* number of headers */
for(;;) { for(;;) {
if (url_feof(pb)) if (url_feof(pb))

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
b813a52d4efe6cf7974190ea9c4c7e8c *./tests/data/acodec/g722.wav d1a10c4d35f752f60798114a156be3a8 *./tests/data/acodec/g722.wav
48053 ./tests/data/acodec/g722.wav 48053 ./tests/data/acodec/g722.wav
d8344d14a11eef0418b856af70694cbe *./tests/data/g722.acodec.out.wav 8dafe5b74ccd5f08fed2fb2a69c5475f *./tests/data/g722.acodec.out.wav
stddev: 8841.18 PSNR: 17.40 MAXDIFF:36225 bytes: 191980/ 1058400 stddev: 8939.47 PSNR: 17.30 MAXDIFF:40370 bytes: 191980/ 1058400

View File

@ -1,168 +1,168 @@
#tb 0: 1/16000 #tb 0: 1/16000
0, 0, 0, 2048, 4096, 0xde68394d 0, 0, 0, 2048, 4096, 0x4f9228b3
0, 2048, 2048, 2048, 4096, 0xa5c28cb7 0, 2048, 2048, 2048, 4096, 0xfab58157
0, 4096, 4096, 2048, 4096, 0x2e3c2f23 0, 4096, 4096, 2048, 4096, 0x0b641c78
0, 6144, 6144, 2048, 4096, 0xd7757825 0, 6144, 6144, 2048, 4096, 0x601c6803
0, 8192, 8192, 2048, 4096, 0xafd1fd61 0, 8192, 8192, 2048, 4096, 0xb3e2f166
0, 10240, 10240, 2048, 4096, 0x686afcbe 0, 10240, 10240, 2048, 4096, 0x5681f206
0, 12288, 12288, 2048, 4096, 0x2290e848 0, 12288, 12288, 2048, 4096, 0x1e69e71f
0, 14336, 14336, 2048, 4096, 0xddd484ad 0, 14336, 14336, 2048, 4096, 0x05628be3
0, 16384, 16384, 2048, 4096, 0x148811a6 0, 16384, 16384, 2048, 4096, 0x109b1aef
0, 18432, 18432, 2048, 4096, 0x8b965613 0, 18432, 18432, 2048, 4096, 0xd5435a9e
0, 20480, 20480, 2048, 4096, 0x8b095d51 0, 20480, 20480, 2048, 4096, 0xb38b5d28
0, 22528, 22528, 2048, 4096, 0xf7625485 0, 22528, 22528, 2048, 4096, 0x64514c93
0, 24576, 24576, 2048, 4096, 0x982a688c 0, 24576, 24576, 2048, 4096, 0x453350e7
0, 26624, 26624, 2048, 4096, 0xc290dcfc 0, 26624, 26624, 2048, 4096, 0x6deccce6
0, 28672, 28672, 2048, 4096, 0x8bdef225 0, 28672, 28672, 2048, 4096, 0xd427ede1
0, 30720, 30720, 2048, 4096, 0xfca27fdc 0, 30720, 30720, 2048, 4096, 0xdecb8c42
0, 32768, 32768, 2048, 4096, 0x95eff313 0, 32768, 32768, 2048, 4096, 0x3841e4d2
0, 34816, 34816, 2048, 4096, 0x691ed4f7 0, 34816, 34816, 2048, 4096, 0x858ac1b1
0, 36864, 36864, 2048, 4096, 0xd7e7b492 0, 36864, 36864, 2048, 4096, 0x8e9dbfa0
0, 38912, 38912, 2048, 4096, 0xb0416bfe 0, 38912, 38912, 2048, 4096, 0xcbc0766f
0, 40960, 40960, 2048, 4096, 0xf94b3ebd 0, 40960, 40960, 2048, 4096, 0x78d52555
0, 43008, 43008, 2048, 4096, 0x7f73ca12 0, 43008, 43008, 2048, 4096, 0x600ac7d5
0, 45056, 45056, 2048, 4096, 0xe91da4a3 0, 45056, 45056, 2048, 4096, 0xafadb7ee
0, 47104, 47104, 2048, 4096, 0x1f74dc0e 0, 47104, 47104, 2048, 4096, 0x8009d5a1
0, 49152, 49152, 2048, 4096, 0xd95b35e8 0, 49152, 49152, 2048, 4096, 0xb07d475e
0, 51200, 51200, 2048, 4096, 0x6dcdde1a 0, 51200, 51200, 2048, 4096, 0xfcfecceb
0, 53248, 53248, 2048, 4096, 0x614fd4e4 0, 53248, 53248, 2048, 4096, 0x38b5d85f
0, 55296, 55296, 2048, 4096, 0xe38d0fd5 0, 55296, 55296, 2048, 4096, 0xbd48072e
0, 57344, 57344, 2048, 4096, 0xfeba2999 0, 57344, 57344, 2048, 4096, 0xd04724d8
0, 59392, 59392, 2048, 4096, 0x1bf541e1 0, 59392, 59392, 2048, 4096, 0x08425144
0, 61440, 61440, 2048, 4096, 0x689f50d8 0, 61440, 61440, 2048, 4096, 0x7b14483e
0, 63488, 63488, 2048, 4096, 0x0aa60f5f 0, 63488, 63488, 2048, 4096, 0x8858ef4c
0, 65536, 65536, 2048, 4096, 0x60ac3116 0, 65536, 65536, 2048, 4096, 0x1e3024c2
0, 67584, 67584, 2048, 4096, 0xfa60e5e6 0, 67584, 67584, 2048, 4096, 0xcd6bfe4f
0, 69632, 69632, 2048, 4096, 0xc7207c5b 0, 69632, 69632, 2048, 4096, 0x8cde8d18
0, 71680, 71680, 2048, 4096, 0x01196277 0, 71680, 71680, 2048, 4096, 0xbbd856b8
0, 73728, 73728, 2048, 4096, 0x609ca46c 0, 73728, 73728, 2048, 4096, 0x988c9b7a
0, 75776, 75776, 2048, 4096, 0xfb799142 0, 75776, 75776, 2048, 4096, 0x2a858e03
0, 77824, 77824, 2048, 4096, 0x720910df 0, 77824, 77824, 2048, 4096, 0x6dee1e4a
0, 79872, 79872, 2048, 4096, 0xe21a8662 0, 79872, 79872, 2048, 4096, 0x8cc38b41
0, 81920, 81920, 2048, 4096, 0x07105120 0, 81920, 81920, 2048, 4096, 0x48bd5cec
0, 83968, 83968, 2048, 4096, 0x593f627e 0, 83968, 83968, 2048, 4096, 0xeb7f606b
0, 86016, 86016, 2048, 4096, 0x28ddc80c 0, 86016, 86016, 2048, 4096, 0x75f5d28c
0, 88064, 88064, 2048, 4096, 0xc69ef356 0, 88064, 88064, 2048, 4096, 0x5bfeec4b
0, 90112, 90112, 2048, 4096, 0x2defc5bd 0, 90112, 90112, 2048, 4096, 0xfc35c22a
0, 92160, 92160, 2048, 4096, 0x82a4f418 0, 92160, 92160, 2048, 4096, 0x3a95efba
0, 94208, 94208, 2048, 4096, 0x424cb997 0, 94208, 94208, 2048, 4096, 0xefdbce9c
0, 96256, 96256, 2048, 4096, 0x167a49b7 0, 96256, 96256, 2048, 4096, 0x00594ada
0, 98304, 98304, 2048, 4096, 0x32a3e0d4 0, 98304, 98304, 2048, 4096, 0x20ffebfa
0, 100352, 100352, 2048, 4096, 0x08a353ae 0, 100352, 100352, 2048, 4096, 0x1b31370a
0, 102400, 102400, 2048, 4096, 0x9543577b 0, 102400, 102400, 2048, 4096, 0x50766a56
0, 104448, 104448, 2048, 4096, 0x2ed137cf 0, 104448, 104448, 2048, 4096, 0x0058315a
0, 106496, 106496, 2048, 4096, 0xd80b0538 0, 106496, 106496, 2048, 4096, 0x98090cbf
0, 108544, 108544, 2048, 4096, 0x2ad31bef 0, 108544, 108544, 2048, 4096, 0x66ed2d40
0, 110592, 110592, 2048, 4096, 0x1060cff8 0, 110592, 110592, 2048, 4096, 0xdfd7c0a7
0, 112640, 112640, 2048, 4096, 0x76ab5ab8 0, 112640, 112640, 2048, 4096, 0x2adc57e1
0, 114688, 114688, 2048, 4096, 0x8eedb68d 0, 114688, 114688, 2048, 4096, 0x838bbc82
0, 116736, 116736, 2048, 4096, 0xf4e2dc46 0, 116736, 116736, 2048, 4096, 0x2c55de1a
0, 118784, 118784, 2048, 4096, 0xc52d3326 0, 118784, 118784, 2048, 4096, 0xeae027f4
0, 120832, 120832, 2048, 4096, 0x25201a26 0, 120832, 120832, 2048, 4096, 0x09fe00f6
0, 122880, 122880, 2048, 4096, 0x16419378 0, 122880, 122880, 2048, 4096, 0xa25d9970
0, 124928, 124928, 2048, 4096, 0x97061f3c 0, 124928, 124928, 2048, 4096, 0xedb11a20
0, 126976, 126976, 2048, 4096, 0xd54edecd 0, 126976, 126976, 2048, 4096, 0x9ce2e63e
0, 129024, 129024, 2048, 4096, 0xc830b07b 0, 129024, 129024, 2048, 4096, 0xeb699974
0, 131072, 131072, 2048, 4096, 0x804bae00 0, 131072, 131072, 2048, 4096, 0xcc04a296
0, 133120, 133120, 2048, 4096, 0xbb279150 0, 133120, 133120, 2048, 4096, 0xe90e9a12
0, 135168, 135168, 2048, 4096, 0x95c4d5aa 0, 135168, 135168, 2048, 4096, 0xae85c0f7
0, 137216, 137216, 2048, 4096, 0xc51d5259 0, 137216, 137216, 2048, 4096, 0x7ee877db
0, 139264, 139264, 2048, 4096, 0x856e1ab0 0, 139264, 139264, 2048, 4096, 0x9ecf14ee
0, 141312, 141312, 2048, 4096, 0x9e6ccb12 0, 141312, 141312, 2048, 4096, 0xa821cecd
0, 143360, 143360, 2048, 4096, 0xa2e5c1bb 0, 143360, 143360, 2048, 4096, 0x2714bb11
0, 145408, 145408, 2048, 4096, 0xe62fb62f 0, 145408, 145408, 2048, 4096, 0x28f1c1e0
0, 147456, 147456, 2048, 4096, 0xf10e3df0 0, 147456, 147456, 2048, 4096, 0xf81c4f60
0, 149504, 149504, 2048, 4096, 0x76def18b 0, 149504, 149504, 2048, 4096, 0x1ae0e5a1
0, 151552, 151552, 2048, 4096, 0xc9c3a26d 0, 151552, 151552, 2048, 4096, 0xbdae9d9a
0, 153600, 153600, 2048, 4096, 0x8ec0e061 0, 153600, 153600, 2048, 4096, 0x5202e560
0, 155648, 155648, 2048, 4096, 0x3d4e8512 0, 155648, 155648, 2048, 4096, 0x82408396
0, 157696, 157696, 2048, 4096, 0xec45cd46 0, 157696, 157696, 2048, 4096, 0xc850ce0c
0, 159744, 159744, 2048, 4096, 0xa34f3ddf 0, 159744, 159744, 2048, 4096, 0x1d732d88
0, 161792, 161792, 2048, 4096, 0x52b81c53 0, 161792, 161792, 2048, 4096, 0xc5c01e33
0, 163840, 163840, 2048, 4096, 0xd0f0397a 0, 163840, 163840, 2048, 4096, 0x84942d6c
0, 165888, 165888, 2048, 4096, 0x7c0de231 0, 165888, 165888, 2048, 4096, 0x7c27cd3a
0, 167936, 167936, 2048, 4096, 0xfe86c032 0, 167936, 167936, 2048, 4096, 0x22adc503
0, 169984, 169984, 2048, 4096, 0x67cdb848 0, 169984, 169984, 2048, 4096, 0xfbc3af31
0, 172032, 172032, 2048, 4096, 0x90532cc0 0, 172032, 172032, 2048, 4096, 0xe9652b18
0, 174080, 174080, 2048, 4096, 0x03bca9e9 0, 174080, 174080, 2048, 4096, 0xae75987e
0, 176128, 176128, 2048, 4096, 0x73169fd1 0, 176128, 176128, 2048, 4096, 0x0f7ea428
0, 178176, 178176, 2048, 4096, 0x0b93967d 0, 178176, 178176, 2048, 4096, 0x92b89582
0, 180224, 180224, 2048, 4096, 0x6486d8be 0, 180224, 180224, 2048, 4096, 0xf393d910
0, 182272, 182272, 2048, 4096, 0x555cc2ac 0, 182272, 182272, 2048, 4096, 0x6349b600
0, 184320, 184320, 2048, 4096, 0x07c1912e 0, 184320, 184320, 2048, 4096, 0x16918dbd
0, 186368, 186368, 2048, 4096, 0xe0423c66 0, 186368, 186368, 2048, 4096, 0x14ee15ad
0, 188416, 188416, 2048, 4096, 0xc12d0fa1 0, 188416, 188416, 2048, 4096, 0x26b510d3
0, 190464, 190464, 2048, 4096, 0xdf497c2f 0, 190464, 190464, 2048, 4096, 0x97007bf8
0, 192512, 192512, 2048, 4096, 0x9298d1ba 0, 192512, 192512, 2048, 4096, 0x3718c509
0, 194560, 194560, 2048, 4096, 0x691a4e15 0, 194560, 194560, 2048, 4096, 0x24a54ccd
0, 196608, 196608, 2048, 4096, 0x725adc6e 0, 196608, 196608, 2048, 4096, 0xc960df4e
0, 198656, 198656, 2048, 4096, 0xf68e88de 0, 198656, 198656, 2048, 4096, 0xc7cb6e6f
0, 200704, 200704, 2048, 4096, 0x37a234aa 0, 200704, 200704, 2048, 4096, 0x4c563ae5
0, 202752, 202752, 2048, 4096, 0x43fb0558 0, 202752, 202752, 2048, 4096, 0x0dd51432
0, 204800, 204800, 2048, 4096, 0x653e4320 0, 204800, 204800, 2048, 4096, 0xdb4243c8
0, 206848, 206848, 2048, 4096, 0x651e2f13 0, 206848, 206848, 2048, 4096, 0x9bb6417f
0, 208896, 208896, 2048, 4096, 0x179049f9 0, 208896, 208896, 2048, 4096, 0xec6a40a1
0, 210944, 210944, 2048, 4096, 0xe02fbb9d 0, 210944, 210944, 2048, 4096, 0x82d6c3b4
0, 212992, 212992, 2048, 4096, 0xb7e9f2a0 0, 212992, 212992, 2048, 4096, 0xd181e2ec
0, 215040, 215040, 2048, 4096, 0x94ee81df 0, 215040, 215040, 2048, 4096, 0xba5d7b55
0, 217088, 217088, 2048, 4096, 0x398a98de 0, 217088, 217088, 2048, 4096, 0x78fcb938
0, 219136, 219136, 2048, 4096, 0x1267594a 0, 219136, 219136, 2048, 4096, 0x6691671c
0, 221184, 221184, 2048, 4096, 0x715adbaf 0, 221184, 221184, 2048, 4096, 0x44fadee7
0, 223232, 223232, 2048, 4096, 0x28ce1a20 0, 223232, 223232, 2048, 4096, 0xa42720d5
0, 225280, 225280, 2048, 4096, 0x4f8073d0 0, 225280, 225280, 2048, 4096, 0xc1165a91
0, 227328, 227328, 2048, 4096, 0x536846d3 0, 227328, 227328, 2048, 4096, 0x86aa3e3f
0, 229376, 229376, 2048, 4096, 0x7dc7defe 0, 229376, 229376, 2048, 4096, 0xab5ae57d
0, 231424, 231424, 2048, 4096, 0x08a28e2a 0, 231424, 231424, 2048, 4096, 0x291a91f3
0, 233472, 233472, 2048, 4096, 0xd717c5cd 0, 233472, 233472, 2048, 4096, 0xfdf0dcfc
0, 235520, 235520, 2048, 4096, 0x5d6e1efd 0, 235520, 235520, 2048, 4096, 0x1ef91f67
0, 237568, 237568, 2048, 4096, 0x4d0eea27 0, 237568, 237568, 2048, 4096, 0xc899efee
0, 239616, 239616, 2048, 4096, 0x70fff90c 0, 239616, 239616, 2048, 4096, 0x5ade15ac
0, 241664, 241664, 2048, 4096, 0xd5cc8207 0, 241664, 241664, 2048, 4096, 0x04516beb
0, 243712, 243712, 2048, 4096, 0xf87cae0e 0, 243712, 243712, 2048, 4096, 0xbf5ebbb9
0, 245760, 245760, 2048, 4096, 0x26814ab5 0, 245760, 245760, 2048, 4096, 0x4a235122
0, 247808, 247808, 2048, 4096, 0x9569fb8d 0, 247808, 247808, 2048, 4096, 0xd7a3f4a6
0, 249856, 249856, 2048, 4096, 0x7835122e 0, 249856, 249856, 2048, 4096, 0x5f900f20
0, 251904, 251904, 2048, 4096, 0xa38840dd 0, 251904, 251904, 2048, 4096, 0xa90b4365
0, 253952, 253952, 2048, 4096, 0xfc499ba3 0, 253952, 253952, 2048, 4096, 0x63149dc4
0, 256000, 256000, 2048, 4096, 0x0aa60cb0 0, 256000, 256000, 2048, 4096, 0xf12c1ee8
0, 258048, 258048, 2048, 4096, 0x530ef56e 0, 258048, 258048, 2048, 4096, 0x6d0fec8c
0, 260096, 260096, 2048, 4096, 0xead968db 0, 260096, 260096, 2048, 4096, 0x65e07850
0, 262144, 262144, 2048, 4096, 0x64484214 0, 262144, 262144, 2048, 4096, 0x16d951cc
0, 264192, 264192, 2048, 4096, 0xfd0cc89e 0, 264192, 264192, 2048, 4096, 0xd296d0c4
0, 266240, 266240, 2048, 4096, 0x0d452a5d 0, 266240, 266240, 2048, 4096, 0x619b2a53
0, 268288, 268288, 2048, 4096, 0x36ef8482 0, 268288, 268288, 2048, 4096, 0x316972d5
0, 270336, 270336, 2048, 4096, 0x462b641b 0, 270336, 270336, 2048, 4096, 0xcfd64e21
0, 272384, 272384, 2048, 4096, 0x2a5c1c0c 0, 272384, 272384, 2048, 4096, 0xcbcb10c6
0, 274432, 274432, 2048, 4096, 0x8837ff80 0, 274432, 274432, 2048, 4096, 0x20aeff7c
0, 276480, 276480, 2048, 4096, 0x27a3de22 0, 276480, 276480, 2048, 4096, 0xd205dabd
0, 278528, 278528, 2048, 4096, 0xf88d28c1 0, 278528, 278528, 2048, 4096, 0xac9d3001
0, 280576, 280576, 2048, 4096, 0xed85ea97 0, 280576, 280576, 2048, 4096, 0x6d53dfdd
0, 282624, 282624, 2048, 4096, 0x50c3e7db 0, 282624, 282624, 2048, 4096, 0xbb9fe15c
0, 284672, 284672, 2048, 4096, 0x82bcb480 0, 284672, 284672, 2048, 4096, 0x1852b88b
0, 286720, 286720, 2048, 4096, 0xc50ee536 0, 286720, 286720, 2048, 4096, 0xb0acec01
0, 288768, 288768, 2048, 4096, 0x086280ee 0, 288768, 288768, 2048, 4096, 0xb52a9342
0, 290816, 290816, 2048, 4096, 0x6f18f2b2 0, 290816, 290816, 2048, 4096, 0x7529faee
0, 292864, 292864, 2048, 4096, 0x1c7c0856 0, 292864, 292864, 2048, 4096, 0x150ff449
0, 294912, 294912, 2048, 4096, 0xc576268a 0, 294912, 294912, 2048, 4096, 0xa81d31d9
0, 296960, 296960, 2048, 4096, 0x7a9af56d 0, 296960, 296960, 2048, 4096, 0xbcb8084a
0, 299008, 299008, 2048, 4096, 0x6d058fc5 0, 299008, 299008, 2048, 4096, 0x07229514
0, 301056, 301056, 2048, 4096, 0x8fb1107b 0, 301056, 301056, 2048, 4096, 0xa85cfd88
0, 303104, 303104, 2048, 4096, 0x807588d1 0, 303104, 303104, 2048, 4096, 0x0aef9c27
0, 305152, 305152, 2048, 4096, 0x56178443 0, 305152, 305152, 2048, 4096, 0x8ec47b39
0, 307200, 307200, 2048, 4096, 0xf2460763 0, 307200, 307200, 2048, 4096, 0x910b0560
0, 309248, 309248, 2048, 4096, 0x284255f2 0, 309248, 309248, 2048, 4096, 0x99a8578e
0, 311296, 311296, 2048, 4096, 0xb29d17fb 0, 311296, 311296, 2048, 4096, 0xb3df1d84
0, 313344, 313344, 2048, 4096, 0x5e7e4633 0, 313344, 313344, 2048, 4096, 0x48e52559
0, 315392, 315392, 2048, 4096, 0x57704db1 0, 315392, 315392, 2048, 4096, 0xb25c4800
0, 317440, 317440, 2048, 4096, 0xd87dcc1d 0, 317440, 317440, 2048, 4096, 0x913bc8ce
0, 319488, 319488, 2048, 4096, 0x28d4bb93 0, 319488, 319488, 2048, 4096, 0xb736cc8c
0, 321536, 321536, 2048, 4096, 0x3a2e5c6c 0, 321536, 321536, 2048, 4096, 0x13c66646
0, 323584, 323584, 2048, 4096, 0xf3581656 0, 323584, 323584, 2048, 4096, 0x70a71221
0, 325632, 325632, 2048, 4096, 0x42f1942f 0, 325632, 325632, 2048, 4096, 0x3a50a08e
0, 327680, 327680, 2048, 4096, 0xe75c5092 0, 327680, 327680, 2048, 4096, 0xc0a037b0
0, 329728, 329728, 2048, 4096, 0x3fae7f6d 0, 329728, 329728, 2048, 4096, 0x9a789475
0, 331776, 331776, 2048, 4096, 0xf99ad73e 0, 331776, 331776, 2048, 4096, 0xc890ca16
0, 333824, 333824, 2048, 4096, 0x80564e3e 0, 333824, 333824, 2048, 4096, 0xa0d34bed
0, 335872, 335872, 2048, 4096, 0x8ff6ebe5 0, 335872, 335872, 2048, 4096, 0x1689fa60
0, 337920, 337920, 2048, 4096, 0x436d5e69 0, 337920, 337920, 2048, 4096, 0x5bac4c83
0, 339968, 339968, 684, 1368, 0xe0ebeda3 0, 339968, 339968, 684, 1368, 0x904be5e5

View File

@ -1 +1 @@
750269cc236541df28e15da5c7b0df7a 94e2f200d6e05b47cec4aa3e94571cf3