Commit 7f83db31 authored by Michael Niedermayer's avatar Michael Niedermayer

Merge remote-tracking branch 'qatar/master'

* qatar/master: (46 commits)
  mtv: Make sure audio_subsegments is not 0
  v4l2: use V4L2_FMT_FLAG_EMULATED only if it is defined
  avconv: add symbolic names for -vsync parameters
  flvdec: Fix compiler warning for uninitialized variables
  rtsp: Fix compiler warning for uninitialized variable
  ulti: convert to new bytestream API.
  swscale: Use standard multiple inclusion guards in ppc/ header files.
  Place some START_TIMER invocations in separate blocks.
  v4l2: list available formats
  v4l2: set the proper codec_tag
  v4l2: refactor device_open
  v4l2: simplify away io_method
  v4l2: cosmetics
  v4l2: uniform and format options
  v4l2: do not force interlaced mode
  avio: exit early in fill_buffer without read_packet
  vc1dec: fix invalid memory access for small video dimensions
  rv34: fix invalid memory access for small video dimensions
  rv34: joint coefficient decoding and dequantization
  avplay: Don't call avio_set_interrupt_cb(NULL)
  ...

Conflicts:
	Changelog
	avconv.c
	doc/APIchanges
	doc/indevs.texi
	libavcodec/adxenc.c
	libavcodec/dnxhdenc.c
	libavcodec/h264.c
	libavdevice/v4l2.c
	libavformat/flvdec.c
	libavformat/mtv.c
	libswscale/utils.c
Merged-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parents c4eec85a feb15cee
......@@ -145,7 +145,7 @@ easier to use. The changes are:
- pan audio filter
- IFF Amiga Continuous Bitmap (ACBM) decoder
- ass filter
- CRI ADX audio format demuxer
- CRI ADX audio format muxer and demuxer
- Playstation Portable PMP format demuxer
- Microsoft Windows ICO demuxer
- life source
......
......@@ -88,6 +88,11 @@
#include "libavutil/avassert.h"
#define VSYNC_AUTO -1
#define VSYNC_PASSTHROUGH 0
#define VSYNC_CFR 1
#define VSYNC_VFR 2
const char program_name[] = "avconv";
const int program_birth_year = 2000;
......@@ -127,7 +132,7 @@ static int do_hex_dump = 0;
static int do_pkt_dump = 0;
static int do_pass = 0;
static const char *pass_logfilename_prefix;
static int video_sync_method = -1;
static int video_sync_method = VSYNC_AUTO;
static int audio_sync_method = 0;
static float audio_drift_threshold = 0.1;
static int copy_ts = 0;
......@@ -1390,16 +1395,16 @@ static void do_video_out(AVFormatContext *s,
*frame_size = 0;
format_video_sync = video_sync_method;
if (format_video_sync < 0)
format_video_sync = (s->oformat->flags & AVFMT_NOTIMESTAMPS) ? 0 :
(s->oformat->flags & AVFMT_VARIABLE_FPS) ? 2 : 1;
if (format_video_sync == VSYNC_AUTO)
format_video_sync = (s->oformat->flags & AVFMT_NOTIMESTAMPS) ? VSYNC_PASSTHROUGH :
(s->oformat->flags & AVFMT_VARIABLE_FPS) ? VSYNC_VFR : VSYNC_CFR;
if (format_video_sync) {
if (format_video_sync != VSYNC_PASSTHROUGH) {
double vdelta = sync_ipts - ost->sync_opts;
// FIXME set to 0.5 after we fix some dts/pts bugs like in avidec.c
if (vdelta < -1.1)
nb_frames = 0;
else if (format_video_sync == 2) {
else if (format_video_sync == VSYNC_VFR) {
if (vdelta <= -0.6) {
nb_frames = 0;
} else if (vdelta > 0.6)
......@@ -4426,6 +4431,17 @@ static int opt_video_filters(OptionsContext *o, const char *opt, const char *arg
return parse_option(o, "filter:v", arg, options);
}
static int opt_vsync(const char *opt, const char *arg)
{
if (!av_strcasecmp(arg, "cfr")) video_sync_method = VSYNC_CFR;
else if (!av_strcasecmp(arg, "vfr")) video_sync_method = VSYNC_VFR;
else if (!av_strcasecmp(arg, "passthrough")) video_sync_method = VSYNC_PASSTHROUGH;
if (video_sync_method == VSYNC_AUTO)
video_sync_method = parse_number_or_die("vsync", arg, OPT_INT, VSYNC_AUTO, VSYNC_VFR);
return 0;
}
#define OFFSET(x) offsetof(OptionsContext, x)
static const OptionDef options[] = {
/* main options */
......@@ -4457,7 +4473,7 @@ static const OptionDef options[] = {
"when dumping packets, also dump the payload" },
{ "re", OPT_BOOL | OPT_EXPERT | OPT_OFFSET, {.off = OFFSET(rate_emu)}, "read input at native frame rate", "" },
{ "target", HAS_ARG | OPT_FUNC2, {(void*)opt_target}, "specify target file type (\"vcd\", \"svcd\", \"dvd\", \"dv\", \"dv50\", \"pal-vcd\", \"ntsc-svcd\", ...)", "type" },
{ "vsync", HAS_ARG | OPT_INT | OPT_EXPERT, {(void*)&video_sync_method}, "video sync method", "" },
{ "vsync", HAS_ARG | OPT_EXPERT, {(void*)opt_vsync}, "video sync method", "" },
{ "async", HAS_ARG | OPT_INT | OPT_EXPERT, {(void*)&audio_sync_method}, "audio sync method", "" },
{ "adrift_threshold", HAS_ARG | OPT_FLOAT | OPT_EXPERT, {(void*)&audio_drift_threshold}, "audio drift threshold", "threshold" },
{ "copyts", OPT_BOOL | OPT_EXPERT, {(void*)&copy_ts}, "copy timestamps" },
......
......@@ -1226,6 +1226,7 @@ HAVE_LIST="
struct_sockaddr_in6
struct_sockaddr_sa_len
struct_sockaddr_storage
struct_v4l2_frmivalenum_discrete
symver
symver_asm_label
symver_gnu_asm
......@@ -3174,6 +3175,8 @@ makeinfo --version > /dev/null 2>&1 && enable makeinfo || disable makeinfo
check_header linux/fb.h
check_header linux/videodev.h
check_header linux/videodev2.h
check_struct linux/videodev2.h "struct v4l2_frmivalenum" discrete
check_header sys/videoio.h
check_func_headers "windows.h vfw.h" capCreateCaptureWindow "$vfwcap_indev_extralibs"
......
......@@ -174,6 +174,10 @@ API changes, most recent first:
2011-08-14 - 323b930 - lavu 51.12.0
Add av_fifo_peek2(), deprecate av_fifo_peek().
2011-08-26 - lavu 51.9.0
- add41de..abc78a5 Do not include intfloat_readwrite.h,
mathematics.h, rational.h, pixfmt.h, or log.h from avutil.h.
2011-08-16 - 48f9e45 - lavf 53.8.0
Add avformat_query_codec().
......
......@@ -749,15 +749,15 @@ Thread count.
Video sync method.
@table @option
@item 0
@item passthrough
Each frame is passed with its timestamp from the demuxer to the muxer.
@item 1
@item cfr
Frames will be duplicated and dropped to achieve exactly the requested
constant framerate.
@item 2
@item vfr
Frames are passed through with their timestamp or dropped so as to
prevent 2 frames from having the same timestamp.
@item -1
@item auto
Chooses between 1 and 2 depending on muxer capabilities. This is the
default method.
@end table
......
......@@ -134,7 +134,7 @@ library:
@item Brute Force & Ignorance @tab @tab X
@tab Used in the game Flash Traffic: City of Angels.
@item BWF @tab X @tab X
@item CRI ADX @tab @tab X
@item CRI ADX @tab X @tab X
@tab Audio-only format used in console video games.
@item Discworld II BMV @tab @tab X
@item Interplay C93 @tab @tab X
......
......@@ -515,9 +515,9 @@ kind @file{/dev/video@var{N}}, where @var{N} is a number associated to
the device.
Video4Linux and Video4Linux2 devices only support a limited set of
@var{width}x@var{height} sizes and frame rates. You can check which are
@var{width}x@var{height} sizes and framerates. You can check which are
supported for example with the command @command{dov4l} for Video4Linux
devices and the command @command{v4l-info} for Video4Linux2 devices.
devices and using @command{-list_formats all} for Video4Linux2 devices.
If the size for the device is set to 0x0, the input device will
try to auto-detect the size to use.
......
......@@ -93,6 +93,11 @@
#include "libavutil/avassert.h"
#define VSYNC_AUTO -1
#define VSYNC_PASSTHROUGH 0
#define VSYNC_CFR 1
#define VSYNC_VFR 2
const char program_name[] = "ffmpeg";
const int program_birth_year = 2000;
......@@ -144,7 +149,7 @@ static int do_pkt_dump = 0;
static int do_psnr = 0;
static int do_pass = 0;
static const char *pass_logfilename_prefix;
static int video_sync_method = -1;
static int video_sync_method = VSYNC_AUTO;
static int audio_sync_method = 0;
static float audio_drift_threshold = 0.1;
static int copy_ts = 0;
......@@ -1433,15 +1438,15 @@ static void do_video_out(AVFormatContext *s,
*frame_size = 0;
format_video_sync = video_sync_method;
if (format_video_sync < 0)
format_video_sync = (s->oformat->flags & AVFMT_VARIABLE_FPS) ? ((s->oformat->flags & AVFMT_NOTIMESTAMPS) ? 0 : 2) : 1;
if (format_video_sync == VSYNC_AUTO)
format_video_sync = (s->oformat->flags & AVFMT_VARIABLE_FPS) ? ((s->oformat->flags & AVFMT_NOTIMESTAMPS) ? VSYNC_PASSTHROUGH : VSYNC_VFR) : 1;
if (format_video_sync) {
if (format_video_sync != VSYNC_PASSTHROUGH) {
double vdelta = sync_ipts - ost->sync_opts + duration;
// FIXME set to 0.5 after we fix some dts/pts bugs like in avidec.c
if (vdelta < -1.1)
nb_frames = 0;
else if (format_video_sync == 2) {
else if (format_video_sync == VSYNC_VFR) {
if (vdelta <= -0.6) {
nb_frames = 0;
} else if (vdelta > 0.6)
......@@ -4873,6 +4878,17 @@ static int opt_video_filters(OptionsContext *o, const char *opt, const char *arg
return parse_option(o, "filter:v", arg, options);
}
static int opt_vsync(const char *opt, const char *arg)
{
if (!av_strcasecmp(arg, "cfr")) video_sync_method = VSYNC_CFR;
else if (!av_strcasecmp(arg, "vfr")) video_sync_method = VSYNC_VFR;
else if (!av_strcasecmp(arg, "passthrough")) video_sync_method = VSYNC_PASSTHROUGH;
if (video_sync_method == VSYNC_AUTO)
video_sync_method = parse_number_or_die("vsync", arg, OPT_INT, VSYNC_AUTO, VSYNC_VFR);
return 0;
}
#define OFFSET(x) offsetof(OptionsContext, x)
static const OptionDef options[] = {
/* main options */
......@@ -4908,7 +4924,7 @@ static const OptionDef options[] = {
{ "loop_input", OPT_BOOL | OPT_EXPERT, {(void*)&loop_input}, "deprecated, use -loop" },
{ "loop_output", HAS_ARG | OPT_INT | OPT_EXPERT, {(void*)&loop_output}, "deprecated, use -loop", "" },
{ "target", HAS_ARG | OPT_FUNC2, {(void*)opt_target}, "specify target file type (\"vcd\", \"svcd\", \"dvd\", \"dv\", \"dv50\", \"pal-vcd\", \"ntsc-svcd\", ...)", "type" },
{ "vsync", HAS_ARG | OPT_INT | OPT_EXPERT, {(void*)&video_sync_method}, "video sync method", "" },
{ "vsync", HAS_ARG | OPT_EXPERT, {(void*)opt_vsync}, "video sync method", "" },
{ "async", HAS_ARG | OPT_INT | OPT_EXPERT, {(void*)&audio_sync_method}, "audio sync method", "" },
{ "adrift_threshold", HAS_ARG | OPT_FLOAT | OPT_EXPERT, {(void*)&audio_drift_threshold}, "audio drift threshold", "threshold" },
{ "copyts", OPT_BOOL | OPT_EXPERT, {(void*)&copy_ts}, "copy timestamps" },
......
......@@ -165,6 +165,13 @@ static int adx_decode_frame(AVCodecContext *avctx, void *data,
return buf - avpkt->data;
}
static void adx_decode_flush(AVCodecContext *avctx)
{
ADXContext *c = avctx->priv_data;
memset(c->prev, 0, sizeof(c->prev));
c->eof = 0;
}
AVCodec ff_adpcm_adx_decoder = {
.name = "adpcm_adx",
.type = AVMEDIA_TYPE_AUDIO,
......@@ -172,6 +179,7 @@ AVCodec ff_adpcm_adx_decoder = {
.priv_data_size = sizeof(ADXContext),
.init = adx_decode_init,
.decode = adx_decode_frame,
.flush = adx_decode_flush,
.capabilities = CODEC_CAP_DR1,
.long_name = NULL_IF_CONFIG_SMALL("SEGA CRI ADX ADPCM"),
};
......@@ -19,9 +19,9 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "libavutil/intreadwrite.h"
#include "avcodec.h"
#include "adx.h"
#include "bytestream.h"
#include "put_bits.h"
/**
......@@ -33,167 +33,135 @@
* adx2wav & wav2adx http://www.geocities.co.jp/Playtown/2004/
*/
/* 18 bytes <-> 32 samples */
static void adx_encode(ADXContext *c, unsigned char *adx, const short *wav,
ADXChannelState *prev)
static void adx_encode(ADXContext *c, uint8_t *adx, const int16_t *wav,
ADXChannelState *prev, int channels)
{
PutBitContext pb;
int scale;
int i;
int s0,s1,s2,d;
int max=0;
int min=0;
int data[32];
int i, j;
int s0, s1, s2, d;
int max = 0;
int min = 0;
int data[BLOCK_SAMPLES];
s1 = prev->s1;
s2 = prev->s2;
for(i=0;i<32;i++) {
for (i = 0, j = 0; j < 32; i += channels, j++) {
s0 = wav[i];
d = ((s0 << COEFF_BITS) - c->coeff[0] * s1 - c->coeff[1] * s2) >> COEFF_BITS;
data[i]=d;
if (max<d) max=d;
if (min>d) min=d;
data[j] = d;
if (max < d)
max = d;
if (min > d)
min = d;
s2 = s1;
s1 = s0;
}
prev->s1 = s1;
prev->s2 = s2;
/* -8..+7 */
if (max==0 && min==0) {
memset(adx,0,18);
if (max == 0 && min == 0) {
memset(adx, 0, BLOCK_SIZE);
return;
}
if (max/7>-min/8) scale = max/7;
else scale = -min/8;
if (max / 7 > -min / 8)
scale = max / 7;
else
scale = -min / 8;
if (scale==0) scale=1;
if (scale == 0)
scale = 1;
AV_WB16(adx, scale);
init_put_bits(&pb, adx + 2, 16);
for (i = 0; i < 32; i++)
put_sbits(&pb, 4, av_clip(data[i]/scale, -8, 7));
for (i = 0; i < BLOCK_SAMPLES; i++)
put_sbits(&pb, 4, av_clip(data[i] / scale, -8, 7));
flush_put_bits(&pb);
}
static int adx_encode_header(AVCodecContext *avctx,unsigned char *buf,size_t bufsize)
#define HEADER_SIZE 36
static int adx_encode_header(AVCodecContext *avctx, uint8_t *buf, int bufsize)
{
#if 0
struct {
uint32_t offset; /* 0x80000000 + sample start - 4 */
unsigned char unknown1[3]; /* 03 12 04 */
unsigned char channel; /* 1 or 2 */
uint32_t freq;
uint32_t size;
uint32_t unknown2; /* 01 f4 03 00 */
uint32_t unknown3; /* 00 00 00 00 */
uint32_t unknown4; /* 00 00 00 00 */
/* if loop
unknown3 00 15 00 01
unknown4 00 00 00 01
long loop_start_sample;
long loop_start_byte;
long loop_end_sample;
long loop_end_byte;
long
*/
} adxhdr; /* big endian */
/* offset-6 "(c)CRI" */
#endif
ADXContext *c = avctx->priv_data;
AV_WB32(buf+0x00,0x80000000|0x20);
AV_WB32(buf+0x04,0x03120400|avctx->channels);
AV_WB32(buf+0x08,avctx->sample_rate);
AV_WB32(buf+0x0c,0); /* FIXME: set after */
AV_WB16(buf + 0x10, c->cutoff);
AV_WB32(buf + 0x12, 0x03000000);
AV_WB32(buf + 0x16, 0x00000000);
AV_WB32(buf + 0x1a, 0x00000000);
memcpy (buf + 0x1e, "(c)CRI", 6);
return 0x20+4;
if (bufsize < HEADER_SIZE)
return AVERROR(EINVAL);
bytestream_put_be16(&buf, 0x8000); /* header signature */
bytestream_put_be16(&buf, HEADER_SIZE - 4); /* copyright offset */
bytestream_put_byte(&buf, 3); /* encoding */
bytestream_put_byte(&buf, BLOCK_SIZE); /* block size */
bytestream_put_byte(&buf, 4); /* sample size */
bytestream_put_byte(&buf, avctx->channels); /* channels */
bytestream_put_be32(&buf, avctx->sample_rate); /* sample rate */
bytestream_put_be32(&buf, 0); /* total sample count */
bytestream_put_be16(&buf, c->cutoff); /* cutoff frequency */
bytestream_put_byte(&buf, 3); /* version */
bytestream_put_byte(&buf, 0); /* flags */
bytestream_put_be32(&buf, 0); /* unknown */
bytestream_put_be32(&buf, 0); /* loop enabled */
bytestream_put_be16(&buf, 0); /* padding */
bytestream_put_buffer(&buf, "(c)CRI", 6); /* copyright signature */
return HEADER_SIZE;
}
static av_cold int adx_encode_init(AVCodecContext *avctx)
{
ADXContext *c = avctx->priv_data;
if (avctx->channels > 2)
return -1; /* only stereo or mono =) */
avctx->frame_size = 32;
avctx->coded_frame= avcodec_alloc_frame();
avctx->coded_frame->key_frame= 1;
if (avctx->channels > 2) {
av_log(avctx, AV_LOG_ERROR, "Invalid number of channels\n");
return AVERROR(EINVAL);
}
avctx->frame_size = BLOCK_SAMPLES;
// avctx->bit_rate = avctx->sample_rate*avctx->channels*18*8/32;
avctx->coded_frame = avcodec_alloc_frame();
/* the cutoff can be adjusted, but this seems to work pretty well */
c->cutoff = 500;
ff_adx_calculate_coeffs(c->cutoff, avctx->sample_rate, COEFF_BITS, c->coeff);
av_log(avctx, AV_LOG_DEBUG, "adx encode init\n");
return 0;
}
static av_cold int adx_encode_close(AVCodecContext *avctx)
{
av_freep(&avctx->coded_frame);
return 0;
}
static int adx_encode_frame(AVCodecContext *avctx,
uint8_t *frame, int buf_size, void *data)
static int adx_encode_frame(AVCodecContext *avctx, uint8_t *frame,
int buf_size, void *data)
{
ADXContext *c = avctx->priv_data;
const short *samples = data;
unsigned char *dst = frame;
int rest = avctx->frame_size;
/*
input data size =
ffmpeg.c: do_audio_out()
frame_bytes = enc->frame_size * 2 * enc->channels;
*/
ADXContext *c = avctx->priv_data;
const int16_t *samples = data;
uint8_t *dst = frame;
int ch;
// printf("sz=%d ",buf_size); fflush(stdout);
if (!c->header_parsed) {
int hdrsize = adx_encode_header(avctx,dst,buf_size);
dst+=hdrsize;
int hdrsize;
if ((hdrsize = adx_encode_header(avctx, dst, buf_size)) < 0) {
av_log(avctx, AV_LOG_ERROR, "output buffer is too small\n");
return AVERROR(EINVAL);
}
dst += hdrsize;
buf_size -= hdrsize;
c->header_parsed = 1;
}
if (buf_size < BLOCK_SIZE * avctx->channels) {
av_log(avctx, AV_LOG_ERROR, "output buffer is too small\n");
return AVERROR(EINVAL);
}
if (avctx->channels==1) {
while(rest>=32) {
adx_encode(c, dst, samples, c->prev);
dst+=18;
samples+=32;
rest-=32;
}
} else {
while(rest>=32*2) {
short tmpbuf[32*2];
int i;
for(i=0;i<32;i++) {
tmpbuf[i] = samples[i*2];
tmpbuf[i+32] = samples[i*2+1];
}
adx_encode(c, dst, tmpbuf, c->prev);
adx_encode(c, dst + 18, tmpbuf + 32, c->prev + 1);
dst+=18*2;
samples+=32*2;
rest-=32*2;
}
for (ch = 0; ch < avctx->channels; ch++) {
adx_encode(c, dst, samples + ch, &c->prev[ch], avctx->channels);
dst += BLOCK_SIZE;
}
return dst-frame;
return dst - frame;
}
AVCodec ff_adpcm_adx_encoder = {
......@@ -204,6 +172,7 @@ AVCodec ff_adpcm_adx_encoder = {
.init = adx_encode_init,
.encode = adx_encode_frame,
.close = adx_encode_close,
.sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_NONE},
.long_name = NULL_IF_CONFIG_SMALL("SEGA CRI ADX ADPCM"),
.sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16,
AV_SAMPLE_FMT_NONE },
.long_name = NULL_IF_CONFIG_SMALL("SEGA CRI ADX ADPCM"),
};
......@@ -25,12 +25,9 @@
void ff_rv34_inv_transform_neon(DCTELEM *block);
void ff_rv34_inv_transform_noround_neon(DCTELEM *block);
void ff_rv34_dequant4x4_neon(DCTELEM *block, int Qdc, int Q);
void ff_rv34dsp_init_neon(RV34DSPContext *c, DSPContext* dsp)
{
c->rv34_inv_transform_tab[0] = ff_rv34_inv_transform_neon;
c->rv34_inv_transform_tab[1] = ff_rv34_inv_transform_noround_neon;
c->rv34_dequant4x4 = ff_rv34_dequant4x4_neon;
}
......@@ -107,27 +107,3 @@ function ff_rv34_inv_transform_noround_neon, export=1
vst4.16 {d0[3], d1[3], d2[3], d3[3]}, [r2,:64], r1
bx lr
endfunc
function ff_rv34_dequant4x4_neon, export=1
mov r3, r0
mov r12, #16
vdup.16 q0, r2
vmov.16 d0[0], r1
vld1.16 {d2}, [r0,:64], r12
vld1.16 {d4}, [r0,:64], r12
vld1.16 {d6}, [r0,:64], r12
vld1.16 {d16}, [r0,:64], r12
vmull.s16 q1, d2, d0
vmull.s16 q2, d4, d1
vmull.s16 q3, d6, d1
vmull.s16 q8, d16, d1
vqrshrn.s32 d2, q1, #4
vqrshrn.s32 d4, q2, #4
vqrshrn.s32 d6, q3, #4
vqrshrn.s32 d16, q8, #4
vst1.16 {d2}, [r3,:64], r12
vst1.16 {d4}, [r3,:64], r12
vst1.16 {d6}, [r3,:64], r12
vst1.16 {d16}, [r3,:64], r12
bx lr
endfunc
......@@ -39,11 +39,15 @@ static av_always_inline void bytestream_put_ ##name(uint8_t **b, const type valu
write(*b, value);\
(*b) += bytes;\
}\
static av_always_inline type bytestream2_get_ ## name ## u(GetByteContext *g)\
{\
return bytestream_get_ ## name(&g->buffer);\
}\
static av_always_inline type bytestream2_get_ ## name(GetByteContext *g)\
{\
if (g->buffer_end - g->buffer < bytes)\
return 0;\
return bytestream_get_ ## name(&g->buffer);\
return bytestream2_get_ ## name ## u(g);\
}\
static av_always_inline type bytestream2_peek_ ## name(GetByteContext *g)\
{\
......
......@@ -109,10 +109,6 @@ void ff_init_cabac_encoder(CABACContext *c, uint8_t *buf, int buf_size){
c->low= 0;
c->range= 0x1FE;
c->outstanding_count= 0;
#ifdef STRICT_LIMITS
c->sym_count =0;
#endif
c->pb.bit_left++; //avoids firstBitFlag
}
......@@ -183,10 +179,6 @@ static void put_cabac(CABACContext *c, uint8_t * const state, int bit){
}
renorm_cabac_encoder(c);
#ifdef STRICT_LIMITS
c->symCount++;
#endif
}
/**
......@@ -208,10 +200,6 @@ static void put_cabac_bypass(CABACContext *c, int bit){
put_cabac_bit(c, 1);
c->low -= 0x400;
}
#ifdef STRICT_LIMITS
c->symCount++;
#endif
}
/**
......@@ -236,10 +224,6 @@ static int put_cabac_terminate(CABACContext *c, int bit){
flush_put_bits(&c->pb); //FIXME FIXME FIXME XXX wrong
}
#ifdef STRICT_LIMITS
c->symCount++;
#endif
return (put_bits_count(&c->pb)+7)>>3;
}
......@@ -365,21 +349,6 @@ START_TIMER
av_log(NULL, AV_LOG_ERROR, "CABAC failure at %d\n", i);
STOP_TIMER("get_cabac")
}
#if 0
for(i=0; i<SIZE; i++){
START_TIMER
if( r[i] != get_cabac_u(&c, state, (i&1) ? 6 : 7, 3, i&1) )
av_log(NULL, AV_LOG_ERROR, "CABAC unary (truncated) binarization failure at %d\n", i);
STOP_TIMER("get_cabac_u")
}
for(i=0; i<SIZE; i++){
START_TIMER
if( r[i] != get_cabac_ueg(&c, state, 3, 0, 1, 2))
av_log(NULL, AV_LOG_ERROR, "CABAC unary (truncated) binarization failure at %d\n", i);
STOP_TIMER("get_cabac_ueg")
}
#endif
if(!get_cabac_terminate(&c))
av_log(NULL, AV_LOG_ERROR, "where's the Terminator?\n");
......
......@@ -41,9 +41,6 @@ typedef struct CABACContext{
int low;
int range;
int outstanding_count;
#ifdef STRICT_LIMITS
int symCount;
#endif
const uint8_t *bytestream_start;
const uint8_t *bytestream;
const uint8_t *bytestream_end;
......@@ -216,62 +213,4 @@ static int av_unused get_cabac_terminate(CABACContext *c){
}
}
#if 0
/**
* Get (truncated) unary binarization.
*/
static int get_cabac_u(CABACContext *c, uint8_t * state, int max, int max_index, int truncated){
int i;
for(i=0; i<max; i++){
if(get_cabac(c, state)==0)
return i;
if(i< max_index) state++;
}
return truncated ? max : -1;
}
/**
* get unary exp golomb k-th order binarization.
*/
static int get_cabac_ueg(CABACContext *c, uint8_t * state, int max, int is_signed, int k, int max_index){
int i, v;
int m= 1<<k;
if(get_cabac(c, state)==0)
return 0;
if(0 < max_index) state++;
for(i=1; i<max; i++){
if(get_cabac(c, state)==0){
if(is_signed && get_cabac_bypass(c)){
return -i;
}else
return i;
}
if(i < max_index) state++;
}
while(get_cabac_bypass(c)){
i+= m;
m+= m;
}
v=0;
while(m>>=1){
v+= v + get_cabac_bypass(c);
}
i += v;
if(is_signed && get_cabac_bypass(c)){
return -i;
}else
return i;
}
#endif /* 0 */
#endif /* AVCODEC_CABAC_H */
......@@ -578,9 +578,8 @@ static int dnxhd_encode_thread(AVCodecContext *avctx, void *arg, int jobnr, int
for (i = 0; i < 8; i++) {
DCTELEM *block = ctx->blocks[i];
int last_index, overflow;
int n = dnxhd_switch_matrix(ctx, i);
last_index = ctx->m.dct_quantize(&ctx->m, block, 4&(2*i), qscale, &overflow);
int overflow, n = dnxhd_switch_matrix(ctx, i);
int last_index = ctx->m.dct_quantize(&ctx->m, block, 4&(2*i), qscale, &overflow);
//START_TIMER;
dnxhd_encode_block(ctx, block, last_index, n);
//STOP_TIMER("encode_block");
......
......@@ -4051,7 +4051,7 @@ static int decode_frame(AVCodecContext *avctx,
H264Context *h = avctx->priv_data;
MpegEncContext *s = &h->s;
AVFrame *pict = data;
int buf_index;
int buf_index = 0;
Picture *out;
int i, out_idx;
......@@ -4081,7 +4081,7 @@ static int decode_frame(AVCodecContext *avctx,
*pict= *(AVFrame*)out;
}
return buf_size;
return buf_index;
}
if(h->is_avc && buf_size >= 9 && buf[0]==1 && buf[2]==0 && (buf[4]&0xFC)==0xFC && (buf[5]&0x1F) && buf[8]==0x67){
int cnt= buf[5]&0x1f;
......@@ -4112,7 +4112,6 @@ not_extra:
if (!s->current_picture_ptr && h->nal_unit_type == NAL_END_SEQUENCE) {
av_assert0(buf_index <= buf_size);
buf_size = buf_index;
goto out;
}
......@@ -4193,9 +4192,7 @@ int main(void){
init_get_bits(&gb, temp, 8*SIZE);
for(i=0; i<COUNT; i++){
int j, s;
s= show_bits(&gb, 24);
int j, s = show_bits(&gb, 24);
{START_TIMER
j= get_ue_golomb(&gb);
......@@ -4218,9 +4215,7 @@ int main(void){
init_get_bits(&gb, temp, 8*SIZE);
for(i=0; i<COUNT; i++){
int j, s;
s= show_bits(&gb, 24);
int j, s = show_bits(&gb, 24);
{START_TIMER
j= get_se_golomb(&gb);
......
......@@ -760,7 +760,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size,
switch_buffers(ctx);
//START_TIMER;
//{ START_TIMER;
if (ctx->frame_type != FRAMETYPE_NULL) {
for (p = 0; p < 3; p++) {
......@@ -775,7 +775,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size,
}
}
//STOP_TIMER("decode_planes");
//STOP_TIMER("decode_planes"); }
if (ctx->frame.data[0])
avctx->release_buffer(avctx, &ctx->frame);
......
......@@ -83,7 +83,8 @@ typedef struct {
int abr; ///< flag to enable ABR
int pkt_frame_count; ///< frame count for the current packet
int lookahead; ///< encoder delay
int sample_count; ///< total sample count (used for pts)
int64_t next_pts; ///< next pts, in sample_rate time base
int pkt_sample_count; ///< sample count in the current packet
} LibSpeexEncContext;
static av_cold void print_enc_params(AVCodecContext *avctx,
......@@ -201,7 +202,7 @@ static av_cold int encode_init(AVCodecContext *avctx)
/* set encoding delay */
speex_encoder_ctl(s->enc_state, SPEEX_GET_LOOKAHEAD, &s->lookahead);
s->sample_count = -s->lookahead;
s->next_pts = -s->lookahead;
/* create header packet bytes from header struct */
/* note: libspeex allocates the memory for header_data, which is freed
......@@ -235,7 +236,6 @@ static int encode_frame(AVCodecContext *avctx, uint8_t *frame, int buf_size,
{
LibSpeexEncContext *s = avctx->priv_data;
int16_t *samples = data;
int sample_count = s->sample_count;
if (data) {
/* encode Speex frame */
......@@ -243,7 +243,7 @@ static int encode_frame(AVCodecContext *avctx, uint8_t *frame, int buf_size,
speex_encode_stereo_int(samples, s->header.frame_size, &s->bits);
speex_encode_int(s->enc_state, samples, &s->bits);
s->pkt_frame_count++;
s->sample_count += avctx->frame_size;
s->pkt_sample_count += avctx->frame_size;
} else {
/* handle end-of-stream */
if (!s->pkt_frame_count)
......@@ -259,8 +259,10 @@ static int encode_frame(AVCodecContext *avctx, uint8_t *frame, int buf_size,
if (s->pkt_frame_count == s->frames_per_packet) {
s->pkt_frame_count = 0;
avctx->coded_frame->pts =
av_rescale_q(sample_count, (AVRational){ 1, avctx->sample_rate },
av_rescale_q(s->next_pts, (AVRational){ 1, avctx->sample_rate },
avctx->time_base);
s->next_pts += s->pkt_sample_count;
s->pkt_sample_count = 0;
if (buf_size > speex_bits_nbytes(&s->bits)) {
int ret = speex_bits_write(&s->bits, frame, buf_size);
speex_bits_reset(&s->bits);
......
......@@ -212,7 +212,7 @@ static int rv34_decode_cbp(GetBitContext *gb, RV34VLC *vlc, int table)
/**
* Get one coefficient value from the bistream and store it.
*/
static inline void decode_coeff(DCTELEM *dst, int coef, int esc, GetBitContext *gb, VLC* vlc)
static inline void decode_coeff(DCTELEM *dst, int coef, int esc, GetBitContext *gb, VLC* vlc, int q)
{
if(coef){
if(coef == esc){
......@@ -225,14 +225,14 @@ static inline void decode_coeff(DCTELEM *dst, int coef, int esc, GetBitContext *
}
if(get_bits1(gb))
coef = -coef;
*dst = coef;
*dst = (coef*q + 8) >> 4;
}
}
/**
* Decode 2x2 subblock of coefficients.
*/
static inline void decode_subblock(DCTELEM *dst, int code, const int is_block2, GetBitContext *gb, VLC *vlc)
static inline void decode_subblock(DCTELEM *dst, int code, const int is_block2, GetBitContext *gb, VLC *vlc, int q)
{
int coeffs[4];
......@@ -240,15 +240,35 @@ static inline void decode_subblock(DCTELEM *dst, int code, const int is_block2,
coeffs[1] = modulo_three_table[code][1];
coeffs[2] = modulo_three_table[code][2];
coeffs[3] = modulo_three_table[code][3];
decode_coeff(dst , coeffs[0], 3, gb, vlc);
decode_coeff(dst , coeffs[0], 3, gb, vlc, q);
if(is_block2){
decode_coeff(dst+8, coeffs[1], 2, gb, vlc);
decode_coeff(dst+1, coeffs[2], 2, gb, vlc);
decode_coeff(dst+8, coeffs[1], 2, gb, vlc, q);
decode_coeff(dst+1, coeffs[2], 2, gb, vlc, q);
}else{
decode_coeff(dst+1, coeffs[1], 2, gb, vlc);
decode_coeff(dst+8, coeffs[2], 2, gb, vlc);
decode_coeff(dst+1, coeffs[1], 2, gb, vlc, q);
decode_coeff(dst+8, coeffs[2], 2, gb, vlc, q);
}
decode_coeff(dst+9, coeffs[3], 2, gb, vlc);
decode_coeff(dst+9, coeffs[3], 2, gb, vlc, q);
}
static inline void decode_subblock3(DCTELEM *dst, int code, const int is_block2, GetBitContext *gb, VLC *vlc,
int q_dc, int q_ac1, int q_ac2)
{
int coeffs[4];
coeffs[0] = modulo_three_table[code][0];
coeffs[1] = modulo_three_table[code][1];
coeffs[2] = modulo_three_table[code][2];
coeffs[3] = modulo_three_table[code][3];
decode_coeff(dst , coeffs[0], 3, gb, vlc, q_dc);
if(is_block2){
decode_coeff(dst+8, coeffs[1], 2, gb, vlc, q_ac1);
decode_coeff(dst+1, coeffs[2], 2, gb, vlc, q_ac1);
}else{
decode_coeff(dst+1, coeffs[1], 2, gb, vlc, q_ac1);
decode_coeff(dst+8, coeffs[2], 2, gb, vlc, q_ac1);
}
decode_coeff(dst+9, coeffs[3], 2, gb, vlc, q_ac2);
}
/**
......@@ -262,7 +282,7 @@ static inline void decode_subblock(DCTELEM *dst, int code, const int is_block2,
* o--o
*/
static inline void rv34_decode_block(DCTELEM *dst, GetBitContext *gb, RV34VLC *rvlc, int fc, int sc)
static inline void rv34_decode_block(DCTELEM *dst, GetBitContext *gb, RV34VLC *rvlc, int fc, int sc, int q_dc, int q_ac1, int q_ac2)
{
int code, pattern;
......@@ -271,39 +291,23 @@ static inline void rv34_decode_block(DCTELEM *dst, GetBitContext *gb, RV34VLC *r
pattern = code & 0x7;
code >>= 3;
decode_subblock(dst, code, 0, gb, &rvlc->coefficient);
decode_subblock3(dst, code, 0, gb, &rvlc->coefficient, q_dc, q_ac1, q_ac2);
if(pattern & 4){
code = get_vlc2(gb, rvlc->second_pattern[sc].table, 9, 2);
decode_subblock(dst + 2, code, 0, gb, &rvlc->coefficient);
decode_subblock(dst + 2, code, 0, gb, &rvlc->coefficient, q_ac2);
}
if(pattern & 2){ // Looks like coefficients 1 and 2 are swapped for this block
code = get_vlc2(gb, rvlc->second_pattern[sc].table, 9, 2);
decode_subblock(dst + 8*2, code, 1, gb, &rvlc->coefficient);
decode_subblock(dst + 8*2, code, 1, gb, &rvlc->coefficient, q_ac2);
}
if(pattern & 1){
code = get_vlc2(gb, rvlc->third_pattern[sc].table, 9, 2);
decode_subblock(dst + 8*2+2, code, 0, gb, &rvlc->coefficient);
decode_subblock(dst + 8*2+2, code, 0, gb, &rvlc->coefficient, q_ac2);
}
}
/**
* Dequantize 4x4 block of DC values for 16x16 macroblock.
* @todo optimize
*/
static inline void rv34_dequant4x4_16x16(DCTELEM *block, int Qdc, int Q)
{
int i;
for(i = 0; i < 3; i++)
block[rv34_dezigzag[i]] = (block[rv34_dezigzag[i]] * Qdc + 8) >> 4;
for(; i < 16; i++)
block[rv34_dezigzag[i]] = (block[rv34_dezigzag[i]] * Q + 8) >> 4;
}
/** @} */ //block functions
/**
* @name RV30/40 bitstream parsing
* @{
......@@ -676,8 +680,9 @@ static inline void rv34_mc(RV34DecContext *r, const int block_type,
srcY += src_y * s->linesize + src_x;
srcU += uvsrc_y * s->uvlinesize + uvsrc_x;
srcV += uvsrc_y * s->uvlinesize + uvsrc_x;
if( (unsigned)(src_x - !!lx*2) > s->h_edge_pos - !!lx*2 - (width <<3) - 4
|| (unsigned)(src_y - !!ly*2) > s->v_edge_pos - !!ly*2 - (height<<3) - 4){
if(s->h_edge_pos - (width << 3) < 6 || s->v_edge_pos - (height << 3) < 6 ||
(unsigned)(src_x - !!lx*2) > s->h_edge_pos - !!lx*2 - (width <<3) - 4 ||
(unsigned)(src_y - !!ly*2) > s->v_edge_pos - !!ly*2 - (height<<3) - 4) {
uint8_t *uvbuf = s->edge_emu_buffer + 22 * s->linesize;
srcY -= 2 + 2*s->linesize;
......@@ -1097,6 +1102,7 @@ static int rv34_decode_macroblock(RV34DecContext *r, int8_t *intra_types)
MpegEncContext *s = &r->s;
GetBitContext *gb = &s->gb;
int cbp, cbp2;
int q_dc, q_ac;
int i, blknum, blkoff;
LOCAL_ALIGNED_16(DCTELEM, block16, [64]);
int luma_dc_quant;
......@@ -1133,31 +1139,34 @@ static int rv34_decode_macroblock(RV34DecContext *r, int8_t *intra_types)
luma_dc_quant = r->block_type == RV34_MB_P_MIX16x16 ? r->luma_dc_quant_p[s->qscale] : r->luma_dc_quant_i[s->qscale];
if(r->is16){
q_dc = rv34_qscale_tab[luma_dc_quant];
q_ac = rv34_qscale_tab[s->qscale];
memset(block16, 0, 64 * sizeof(*block16));
rv34_decode_block(block16, gb, r->cur_vlcs, 3, 0);
rv34_dequant4x4_16x16(block16, rv34_qscale_tab[luma_dc_quant],rv34_qscale_tab[s->qscale]);
rv34_decode_block(block16, gb, r->cur_vlcs, 3, 0, q_dc, q_dc, q_ac);
r->rdsp.rv34_inv_transform_tab[1](block16);
}
q_ac = rv34_qscale_tab[s->qscale];
for(i = 0; i < 16; i++, cbp >>= 1){
if(!r->is16 && !(cbp & 1)) continue;
blknum = ((i & 2) >> 1) + ((i & 8) >> 2);
blkoff = ((i & 1) << 2) + ((i & 4) << 3);
if(cbp & 1)
rv34_decode_block(s->block[blknum] + blkoff, gb, r->cur_vlcs, r->luma_vlc, 0);
r->rdsp.rv34_dequant4x4(s->block[blknum] + blkoff, rv34_qscale_tab[s->qscale],rv34_qscale_tab[s->qscale]);
rv34_decode_block(s->block[blknum] + blkoff, gb,
r->cur_vlcs, r->luma_vlc, 0, q_ac, q_ac, q_ac);
if(r->is16) //FIXME: optimize
s->block[blknum][blkoff] = block16[(i & 3) | ((i & 0xC) << 1)];
r->rdsp.rv34_inv_transform_tab[0](s->block[blknum] + blkoff);
}
if(r->block_type == RV34_MB_P_MIX16x16)
r->cur_vlcs = choose_vlc_set(r->si.quant, r->si.vlc_set, 1);
q_dc = rv34_qscale_tab[rv34_chroma_quant[1][s->qscale]];
q_ac = rv34_qscale_tab[rv34_chroma_quant[0][s->qscale]];
for(; i < 24; i++, cbp >>= 1){
if(!(cbp & 1)) continue;
blknum = ((i & 4) >> 2) + 4;
blkoff = ((i & 1) << 2) + ((i & 2) << 4);
rv34_decode_block(s->block[blknum] + blkoff, gb, r->cur_vlcs, r->chroma_vlc, 1);
r->rdsp.rv34_dequant4x4(s->block[blknum] + blkoff, rv34_qscale_tab[rv34_chroma_quant[1][s->qscale]],rv34_qscale_tab[rv34_chroma_quant[0][s->qscale]]);
rv34_decode_block(s->block[blknum] + blkoff, gb, r->cur_vlcs, r->chroma_vlc, 1, q_dc, q_ac, q_ac);
r->rdsp.rv34_inv_transform_tab[0](s->block[blknum] + blkoff);
}
if (IS_INTRA(s->current_picture_ptr->f.mb_type[mb_pos]))
......
......@@ -100,16 +100,6 @@ static const uint16_t rv34_qscale_tab[32] = {
963, 1074, 1212, 1392, 1566, 1708, 1978, 2211
};
/**
* 4x4 dezigzag pattern
*/
static const uint8_t rv34_dezigzag[16] = {
0, 1, 8, 16,
9, 2, 3, 10,
17, 24, 25, 18,
11, 19, 26, 27
};
/**
* tables used to translate a quantizer value into a VLC set for decoding
* The first table is used for intraframes.
......
......@@ -100,26 +100,10 @@ static void rv34_inv_transform_noround_c(DCTELEM *block){
/** @} */ // transform
/**
* Dequantize ordinary 4x4 block.
*/
void ff_rv34_dequant4x4_neon(DCTELEM *block, int Qdc, int Q);
static void rv34_dequant4x4_c(DCTELEM *block, int Qdc, int Q)
{
int i, j;
block[0] = (block[0] * Qdc + 8) >> 4;
for (i = 0; i < 4; i++)
for (j = !i; j < 4; j++)
block[j + i*8] = (block[j + i*8] * Q + 8) >> 4;
}
av_cold void ff_rv34dsp_init(RV34DSPContext *c, DSPContext* dsp) {
c->rv34_inv_transform_tab[0] = rv34_inv_transform_c;
c->rv34_inv_transform_tab[1] = rv34_inv_transform_noround_c;
c->rv34_dequant4x4 = rv34_dequant4x4_c;
if (HAVE_NEON)
ff_rv34dsp_init_neon(c, dsp);
}
......@@ -56,7 +56,6 @@ typedef struct RV34DSPContext {
h264_chroma_mc_func avg_chroma_pixels_tab[3];
rv40_weight_func rv40_weight_pixels_tab[2];
rv34_inv_transform_func rv34_inv_transform_tab[2];
void (*rv34_dequant4x4)(DCTELEM *block, int Qdc, int Q);
rv40_weak_loop_filter_func rv40_weak_loop_filter[2];
rv40_strong_loop_filter_func rv40_strong_loop_filter[2];
rv40_loop_filter_strength_func rv40_loop_filter_strength[2];
......
......@@ -38,16 +38,9 @@ typedef struct UltimotionDecodeContext {
int width, height, blocks;
AVFrame frame;
const uint8_t *ulti_codebook;
GetByteContext gb;
} UltimotionDecodeContext;
#define CHECK_OVERREAD_SIZE(size) \
do { \
if (buf_end - buf < (size)) { \
av_log(avctx, AV_LOG_ERROR, "Insufficient data\n"); \
return AVERROR_INVALIDDATA; \
} \
} while(0)
static av_cold int ulti_decode_init(AVCodecContext *avctx)
{
UltimotionDecodeContext *s = avctx->priv_data;
......@@ -232,7 +225,6 @@ static int ulti_decode_frame(AVCodecContext *avctx,
int i;
int skip;
int tmp;
const uint8_t *buf_end = buf + buf_size;
s->frame.reference = 3;
s->frame.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE;
......@@ -241,18 +233,20 @@ static int ulti_decode_frame(AVCodecContext *avctx,
return -1;
}
bytestream2_init(&s->gb, buf, buf_size);
while(!done) {
int idx;
if(blocks >= s->blocks || y >= s->height)
break;//all blocks decoded
CHECK_OVERREAD_SIZE(1);
idx = *buf++;
if (bytestream2_get_bytes_left(&s->gb) < 1)
goto err;
idx = bytestream2_get_byteu(&s->gb);
if((idx & 0xF8) == 0x70) {
switch(idx) {
case 0x70: //change modifier
CHECK_OVERREAD_SIZE(1);
modifier = *buf++;
modifier = bytestream2_get_byte(&s->gb);
if(modifier>1)
av_log(avctx, AV_LOG_INFO, "warning: modifier must be 0 or 1, got %i\n", modifier);
break;
......@@ -266,8 +260,7 @@ static int ulti_decode_frame(AVCodecContext *avctx,
done = 1;
break;
case 0x74: //skip some blocks
CHECK_OVERREAD_SIZE(1);
skip = *buf++;
skip = bytestream2_get_byte(&s->gb);
if ((blocks + skip) >= s->blocks)
break;
blocks += skip;
......@@ -294,8 +287,7 @@ static int ulti_decode_frame(AVCodecContext *avctx,
} else {
cf = 0;
if (idx) {
CHECK_OVERREAD_SIZE(1);
chroma = *buf++;
chroma = bytestream2_get_byte(&s->gb);
}
}
for (i = 0; i < 4; i++) { // for every subblock
......@@ -303,15 +295,13 @@ static int ulti_decode_frame(AVCodecContext *avctx,
if(!code) //skip subblock
continue;
if(cf) {
CHECK_OVERREAD_SIZE(1);
chroma = *buf++;
chroma = bytestream2_get_byte(&s->gb);
}
tx = x + block_coords[i * 2];
ty = y + block_coords[(i * 2) + 1];
switch(code) {
case 1:
CHECK_OVERREAD_SIZE(1);
tmp = *buf++;
tmp = bytestream2_get_byte(&s->gb);
angle = angle_by_index[(tmp >> 6) & 0x3];
......@@ -331,8 +321,7 @@ static int ulti_decode_frame(AVCodecContext *avctx,
case 2:
if (modifier) { // unpack four luma samples
CHECK_OVERREAD_SIZE(3);
tmp = bytestream_get_be24(&buf);
tmp = bytestream2_get_be24(&s->gb);
Y[0] = (tmp >> 18) & 0x3F;
Y[1] = (tmp >> 12) & 0x3F;
......@@ -340,8 +329,7 @@ static int ulti_decode_frame(AVCodecContext *avctx,
Y[3] = tmp & 0x3F;
angle = 16;
} else { // retrieve luma samples from codebook
CHECK_OVERREAD_SIZE(2);
tmp = bytestream_get_be16(&buf);
tmp = bytestream2_get_be16(&s->gb);
angle = (tmp >> 12) & 0xF;
tmp &= 0xFFF;
......@@ -357,27 +345,27 @@ static int ulti_decode_frame(AVCodecContext *avctx,
if (modifier) { // all 16 luma samples
uint8_t Luma[16];
CHECK_OVERREAD_SIZE(12);
tmp = bytestream_get_be24(&buf);
if (bytestream2_get_bytes_left(&s->gb) < 12)
goto err;
tmp = bytestream2_get_be24u(&s->gb);
Luma[0] = (tmp >> 18) & 0x3F;
Luma[1] = (tmp >> 12) & 0x3F;
Luma[2] = (tmp >> 6) & 0x3F;
Luma[3] = tmp & 0x3F;
tmp = bytestream_get_be24(&buf);
tmp = bytestream2_get_be24u(&s->gb);
Luma[4] = (tmp >> 18) & 0x3F;
Luma[5] = (tmp >> 12) & 0x3F;
Luma[6] = (tmp >> 6) & 0x3F;
Luma[7] = tmp & 0x3F;
tmp = bytestream_get_be24(&buf);
tmp = bytestream2_get_be24u(&s->gb);
Luma[8] = (tmp >> 18) & 0x3F;
Luma[9] = (tmp >> 12) & 0x3F;
Luma[10] = (tmp >> 6) & 0x3F;
Luma[11] = tmp & 0x3F;
tmp = bytestream_get_be24(&buf);
tmp = bytestream2_get_be24u(&s->gb);
Luma[12] = (tmp >> 18) & 0x3F;
Luma[13] = (tmp >> 12) & 0x3F;
Luma[14] = (tmp >> 6) & 0x3F;
......@@ -385,22 +373,23 @@ static int ulti_decode_frame(AVCodecContext *avctx,
ulti_convert_yuv(&s->frame, tx, ty, Luma, chroma);
} else {
CHECK_OVERREAD_SIZE(4);
tmp = *buf++;
if (bytestream2_get_bytes_left(&s->gb) < 4)
goto err;
tmp = bytestream2_get_byteu(&s->gb);
if(tmp & 0x80) {
angle = (tmp >> 4) & 0x7;
tmp = (tmp << 8) + *buf++;
tmp = (tmp << 8) + bytestream2_get_byteu(&s->gb);
Y[0] = (tmp >> 6) & 0x3F;
Y[1] = tmp & 0x3F;
Y[2] = (*buf++) & 0x3F;
Y[3] = (*buf++) & 0x3F;
Y[2] = bytestream2_get_byteu(&s->gb) & 0x3F;
Y[3] = bytestream2_get_byteu(&s->gb) & 0x3F;
ulti_grad(&s->frame, tx, ty, Y, chroma, angle); //draw block
} else { // some patterns
int f0, f1;
f0 = *buf++;
f0 = bytestream2_get_byteu(&s->gb);
f1 = tmp;
Y[0] = (*buf++) & 0x3F;
Y[1] = (*buf++) & 0x3F;
Y[0] = bytestream2_get_byteu(&s->gb) & 0x3F;
Y[1] = bytestream2_get_byteu(&s->gb) & 0x3F;
ulti_pattern(&s->frame, tx, ty, f1, f0, Y[0], Y[1], chroma);
}
}
......@@ -422,6 +411,11 @@ static int ulti_decode_frame(AVCodecContext *avctx,
*(AVFrame*)data= s->frame;
return buf_size;
err:
av_log(avctx, AV_LOG_ERROR,
"Insufficient data\n");
return AVERROR_INVALIDDATA;
}
AVCodec ff_ulti_decoder = {
......
......@@ -568,6 +568,7 @@ static void vc1_mc_1mv(VC1Context *v, int dir)
}
if (v->rangeredfrm || (v->mv_mode == MV_PMODE_INTENSITY_COMP)
|| s->h_edge_pos < 22 || v_edge_pos < 22
|| (unsigned)(src_x - s->mspel) > s->h_edge_pos - (mx&3) - 16 - s->mspel * 3
|| (unsigned)(src_y - s->mspel) > v_edge_pos - (my&3) - 16 - s->mspel * 3) {
uint8_t *uvbuf = s->edge_emu_buffer + 19 * s->linesize;
......@@ -799,6 +800,7 @@ static void vc1_mc_4mv_luma(VC1Context *v, int n, int dir)
if (fieldmv && (src_y & 1) && src_y < 4)
src_y--;
if (v->rangeredfrm || (v->mv_mode == MV_PMODE_INTENSITY_COMP)
|| s->h_edge_pos < 13 || v_edge_pos < 23
|| (unsigned)(src_x - s->mspel) > s->h_edge_pos - (mx & 3) - 8 - s->mspel * 2
|| (unsigned)(src_y - (s->mspel << fieldmv)) > v_edge_pos - (my & 3) - ((8 + s->mspel * 2) << fieldmv)) {
srcY -= s->mspel * (1 + (s->linesize << fieldmv));
......@@ -998,6 +1000,7 @@ static void vc1_mc_4mv_chroma(VC1Context *v, int dir)
}
if (v->rangeredfrm || (v->mv_mode == MV_PMODE_INTENSITY_COMP)
|| s->h_edge_pos < 18 || v_edge_pos < 18
|| (unsigned)uvsrc_x > (s->h_edge_pos >> 1) - 9
|| (unsigned)uvsrc_y > (v_edge_pos >> 1) - 9) {
s->dsp.emulated_edge_mc(s->edge_emu_buffer , srcU, s->uvlinesize,
......@@ -1102,6 +1105,7 @@ static void vc1_mc_4mv_chroma4(VC1Context *v)
if (fieldmv && (uvsrc_y & 1) && uvsrc_y < 2)
uvsrc_y--;
if ((v->mv_mode == MV_PMODE_INTENSITY_COMP)
|| s->h_edge_pos < 10 || v_edge_pos < (5 << fieldmv)
|| (unsigned)uvsrc_x > (s->h_edge_pos >> 1) - 5
|| (unsigned)uvsrc_y > v_edge_pos - (5 << fieldmv)) {
s->dsp.emulated_edge_mc(s->edge_emu_buffer, srcU, s->uvlinesize,
......@@ -2006,7 +2010,7 @@ static void vc1_interp_mc(VC1Context *v)
srcV = s->edge_emu_buffer + 18 * s->linesize;
}
if (v->rangeredfrm
if (v->rangeredfrm || s->h_edge_pos < 22 || v_edge_pos < 22
|| (unsigned)(src_x - s->mspel) > s->h_edge_pos - (mx & 3) - 16 - s->mspel * 3
|| (unsigned)(src_y - s->mspel) > v_edge_pos - (my & 3) - 16 - s->mspel * 3) {
uint8_t *uvbuf = s->edge_emu_buffer + 19 * s->linesize;
......
This diff is collapsed.
......@@ -26,6 +26,7 @@ OBJS-$(CONFIG_AC3_MUXER) += rawenc.o
OBJS-$(CONFIG_ACT_DEMUXER) += act.o
OBJS-$(CONFIG_ADF_DEMUXER) += bintext.o sauce.o
OBJS-$(CONFIG_ADX_DEMUXER) += adxdec.o
OBJS-$(CONFIG_ADX_MUXER) += rawenc.o
OBJS-$(CONFIG_ADTS_MUXER) += adtsenc.o
OBJS-$(CONFIG_AEA_DEMUXER) += aea.o pcm.o
OBJS-$(CONFIG_AIFF_DEMUXER) += aiffdec.o riff.o pcm.o isom.o
......
......@@ -109,4 +109,5 @@ AVInputFormat ff_adx_demuxer = {
.read_packet = adx_read_packet,
.extensions = "adx",
.value = CODEC_ID_ADPCM_ADX,
.flags = AVFMT_GENERIC_INDEX,
};
......@@ -54,7 +54,7 @@ void av_register_all(void)
REGISTER_DEMUXER (ACT, act);
REGISTER_DEMUXER (ADF, adf);
REGISTER_MUXER (ADTS, adts);
REGISTER_DEMUXER (ADX, adx);
REGISTER_MUXDEMUX (ADX, adx);
REGISTER_DEMUXER (AEA, aea);
REGISTER_MUXDEMUX (AIFF, aiff);
REGISTER_MUXDEMUX (AMR, amr);
......
......@@ -574,6 +574,10 @@ static void fill_buffer(AVIOContext *s)
int len= s->buffer_size - (dst - s->buffer);
int max_buffer_size = s->max_packet_size ? s->max_packet_size : IO_BUFFER_SIZE;
/* can't fill the buffer without read_packet, just set EOF if appropiate */
if (!s->read_packet && s->buf_ptr >= s->buf_end)
s->eof_reached = 1;
/* no need to do anything if EOF already reached */
if (s->eof_reached)
return;
......
......@@ -112,10 +112,12 @@ static int mtv_read_header(AVFormatContext *s, AVFormatParameters *ap)
avio_skip(pb, 4);
audio_subsegments = avio_rl16(pb);
if(!audio_subsegments){
av_log(s, AV_LOG_ERROR, "audio_subsegments is 0\n");
return AVERROR(EINVAL);
if (audio_subsegments == 0) {
av_log_ask_for_sample(s, "MTV files without audio are not supported\n");
return AVERROR_INVALIDDATA;
}
mtv->full_segment_size =
audio_subsegments * (MTV_AUDIO_PADDING_SIZE + MTV_ASUBCHUNK_DATA_SIZE) +
mtv->img_segment_size;
......
......@@ -45,6 +45,18 @@ AVOutputFormat ff_ac3_muxer = {
};
#endif
#if CONFIG_ADX_MUXER
AVOutputFormat ff_adx_muxer = {
.name = "adx",
.long_name = NULL_IF_CONFIG_SMALL("CRI ADX"),
.extensions = "adx",
.audio_codec = CODEC_ID_ADPCM_ADX,
.video_codec = CODEC_ID_NONE,
.write_packet = ff_raw_write_packet,
.flags = AVFMT_NOTIMESTAMPS,
};
#endif
#if CONFIG_DIRAC_MUXER
AVOutputFormat ff_dirac_muxer = {
.name = "dirac",
......
......@@ -2470,7 +2470,7 @@ static av_always_inline void RENAME(do_a_deblock)(uint8_t *src, int step, int st
int64_t dc_mask, eq_mask, both_masks;
int64_t sums[10*8*2];
src+= step*3; // src points to begin of the 8x8 Block
//START_TIMER
//{ START_TIMER
__asm__ volatile(
"movq %0, %%mm7 \n\t"
"movq %1, %%mm6 \n\t"
......@@ -2995,7 +2995,8 @@ static av_always_inline void RENAME(do_a_deblock)(uint8_t *src, int step, int st
STOP_TIMER("step16")
}else{
STOP_TIMER("stepX")
}*/
}
} */
}
#endif //HAVE_MMX
......
......@@ -19,7 +19,8 @@ OBJS-$(HAVE_MMX) += x86/rgb2rgb.o \
x86/swscale_mmx.o \
x86/yuv2rgb_mmx.o
OBJS-$(HAVE_VIS) += sparc/yuv2rgb_vis.o
OBJS-$(HAVE_YASM) += x86/scale.o
MMX-OBJS-$(HAVE_YASM) += x86/output.o \
x86/scale.o
$(SUBDIR)x86/swscale_mmx.o: CFLAGS += $(NOREDZONE_FLAGS)
......
......@@ -21,8 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef PPC_YUV2RGB_ALTIVEC_H
#define PPC_YUV2RGB_ALTIVEC_H 1
#ifndef SWSCALE_PPC_YUV2RGB_ALTIVEC_H
#define SWSCALE_PPC_YUV2RGB_ALTIVEC_H
#define YUV2PACKEDX_HEADER(suffix) \
void ff_yuv2 ## suffix ## _X_altivec(SwsContext *c, const int16_t *lumFilter, \
......@@ -39,4 +39,4 @@ YUV2PACKEDX_HEADER(rgba);
YUV2PACKEDX_HEADER(rgb24);
YUV2PACKEDX_HEADER(bgr24);
#endif /* PPC_YUV2RGB_ALTIVEC_H */
#endif /* SWSCALE_PPC_YUV2RGB_ALTIVEC_H */
......@@ -18,39 +18,6 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
supported Input formats: YV12, I420/IYUV, YUY2, UYVY, BGR32, BGR32_1, BGR24, BGR16, BGR15, RGB32, RGB32_1, RGB24, Y8/Y800, YVU9/IF09, PAL8
supported output formats: YV12, I420/IYUV, YUY2, UYVY, {BGR,RGB}{1,4,8,15,16,24,32}, Y8/Y800, YVU9/IF09
{BGR,RGB}{1,4,8,15,16} support dithering
unscaled special converters (YV12=I420=IYUV, Y800=Y8)
YV12 -> {BGR,RGB}{1,4,8,12,15,16,24,32}
x -> x
YUV9 -> YV12
YUV9/YV12 -> Y800
Y800 -> YUV9/YV12
BGR24 -> BGR32 & RGB24 -> RGB32
BGR32 -> BGR24 & RGB32 -> RGB24
BGR15 -> BGR16
*/
/*
tested special converters (most are tested actually, but I did not write it down ...)
YV12 -> BGR12/BGR16
YV12 -> YV12
BGR15 -> BGR16
BGR16 -> BGR16
YVU9 -> YV12
untested special converters
YV12/I420 -> BGR15/BGR24/BGR32 (it is the yuv2rgb stuff, so it should be OK)
YV12/I420 -> YV12/I420
YUY2/BGR15/BGR24/BGR32/RGB24/RGB32 -> same format
BGR24 -> BGR32 & RGB24 -> RGB32
BGR32 -> BGR24 & RGB32 -> RGB24
BGR24 -> YV12
*/
#include <inttypes.h>
#include <string.h>
#include <math.h>
......@@ -2371,36 +2338,6 @@ find_c_packed_planar_out_funcs(SwsContext *c,
} else {
YUV_PACKED:
switch (dstFormat) {
case PIX_FMT_GRAY16BE:
*yuv2packed1 = yuv2gray16BE_1_c;
*yuv2packed2 = yuv2gray16BE_2_c;
*yuv2packedX = yuv2gray16BE_X_c;
break;
case PIX_FMT_GRAY16LE:
*yuv2packed1 = yuv2gray16LE_1_c;
*yuv2packed2 = yuv2gray16LE_2_c;
*yuv2packedX = yuv2gray16LE_X_c;
break;
case PIX_FMT_MONOWHITE:
*yuv2packed1 = yuv2monowhite_1_c;
*yuv2packed2 = yuv2monowhite_2_c;
*yuv2packedX = yuv2monowhite_X_c;
break;
case PIX_FMT_MONOBLACK:
*yuv2packed1 = yuv2monoblack_1_c;
*yuv2packed2 = yuv2monoblack_2_c;
*yuv2packedX = yuv2monoblack_X_c;
break;
case PIX_FMT_YUYV422:
*yuv2packed1 = yuv2yuyv422_1_c;
*yuv2packed2 = yuv2yuyv422_2_c;
*yuv2packedX = yuv2yuyv422_X_c;
break;
case PIX_FMT_UYVY422:
*yuv2packed1 = yuv2uyvy422_1_c;
*yuv2packed2 = yuv2uyvy422_2_c;
*yuv2packedX = yuv2uyvy422_X_c;
break;
case PIX_FMT_RGB48LE:
*yuv2packed1 = yuv2rgb48le_1_c;
*yuv2packed2 = yuv2rgb48le_2_c;
......@@ -2517,6 +2454,38 @@ find_c_packed_planar_out_funcs(SwsContext *c,
break;
}
}
switch (dstFormat) {
case PIX_FMT_GRAY16BE:
*yuv2packed1 = yuv2gray16BE_1_c;
*yuv2packed2 = yuv2gray16BE_2_c;
*yuv2packedX = yuv2gray16BE_X_c;
break;
case PIX_FMT_GRAY16LE:
*yuv2packed1 = yuv2gray16LE_1_c;
*yuv2packed2 = yuv2gray16LE_2_c;
*yuv2packedX = yuv2gray16LE_X_c;
break;
case PIX_FMT_MONOWHITE:
*yuv2packed1 = yuv2monowhite_1_c;
*yuv2packed2 = yuv2monowhite_2_c;
*yuv2packedX = yuv2monowhite_X_c;
break;
case PIX_FMT_MONOBLACK:
*yuv2packed1 = yuv2monoblack_1_c;
*yuv2packed2 = yuv2monoblack_2_c;
*yuv2packedX = yuv2monoblack_X_c;
break;
case PIX_FMT_YUYV422:
*yuv2packed1 = yuv2yuyv422_1_c;
*yuv2packed2 = yuv2yuyv422_2_c;
*yuv2packedX = yuv2yuyv422_X_c;
break;
case PIX_FMT_UYVY422:
*yuv2packed1 = yuv2uyvy422_1_c;
*yuv2packed2 = yuv2uyvy422_2_c;
*yuv2packedX = yuv2uyvy422_X_c;
break;
}
}
#define DEBUG_SWSCALE_BUFFERS 0
......
This diff is collapsed.
This diff is collapsed.
......@@ -369,6 +369,11 @@ do_audio_encoding g726.wav "-b:a 32k -ac 1 -ar 8000 -acodec g726"
do_audio_decoding
fi
if [ -n "$do_adpcm_adx" ] ; then
do_audio_encoding adpcm_adx.adx "-acodec adpcm_adx"
do_audio_decoding
fi
if [ -n "$do_adpcm_ima_wav" ] ; then
do_audio_encoding adpcm_ima.wav "-acodec adpcm_ima_wav"
do_audio_decoding
......
0a30509d9296b857e134b762b76dbc31 *./tests/data/acodec/adpcm_adx.adx
297720 ./tests/data/acodec/adpcm_adx.adx
2dbc601ed5259f4d74dc48ccd8da7eaf *./tests/data/adpcm_adx.acodec.out.wav
stddev: 6989.46 PSNR: 19.44 MAXDIFF:65398 bytes: 1058432/ 1058400
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment