Compare commits

..

5 Commits

Author SHA1 Message Date
Michael Niedermayer c0b47d1914 Merge remote-tracking branch 'qatar/master'
* qatar/master:
  movenc: Don't write the 'wave' atom or its child 'enda' for lpcm audio.
  imc: some cosmetics
  rtmp: Pass the proper return code in rtmp_handshake
  rtmp: Check return codes of net IO operations

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2012-05-25 21:06:14 +02:00
Alex Converse ed7bdd8647 movenc: Don't write the 'wave' atom or its child 'enda' for lpcm audio.
It's left over from stsd v0. QuickTime 7 no longer writes 'wave' or 'enda'
when 'lpcm' is the audio tag.
2012-05-25 11:24:43 -07:00
Kostya Shishkov d073f122ea imc: some cosmetics 2012-05-25 20:18:02 +02:00
Samuel Pitoiset 177bcc9593 rtmp: Pass the proper return code in rtmp_handshake
Signed-off-by: Martin Storsjö <martin@martin.st>
2012-05-24 22:16:46 +03:00
Samuel Pitoiset bba287fdac rtmp: Check return codes of net IO operations
Signed-off-by: Martin Storsjö <martin@martin.st>
2012-05-24 22:16:46 +03:00
94 changed files with 495 additions and 700 deletions
+2 -13
View File
@@ -3,19 +3,8 @@ releases are sorted from youngest to oldest.
version next:
version 0.11.2:
- Several bugs and crashes have been fixed as well as build problems
with recent mingw64
version 0.11:
Fixes:CVE-2012-2772, CVE-2012-2774, CVE-2012-2775, CVE-2012-2776, CVE-2012-2777,
CVE-2012-2779, CVE-2012-2782, CVE-2012-2783, CVE-2012-2784, CVE-2012-2785,
CVE-2012-2786, CVE-2012-2787, CVE-2012-2788, CVE-2012-2789, CVE-2012-2790,
CVE-2012-2791, CVE-2012-2792, CVE-2012-2793, CVE-2012-2794, CVE-2012-2795,
CVE-2012-2796, CVE-2012-2797, CVE-2012-2798, CVE-2012-2799, CVE-2012-2800,
CVE-2012-2801, CVE-2012-2802, CVE-2012-2803, CVE-2012-2804,
- Fixes CVE-2012-2771 ... 2805
- v408 Quicktime and Microsoft AYUV Uncompressed 4:4:4:4 encoder and decoder
- setfield filter
- CDXL demuxer and decoder
@@ -44,7 +33,7 @@ Fixes:CVE-2012-2772, CVE-2012-2774, CVE-2012-2775, CVE-2012-2776, CVE-2012-2777,
- MicroDVD decoder
- Avid Meridien (AVUI) encoder and decoder
- accept + prefix to -pix_fmt option to disable automatic conversions.
- complete audio filtering in libavfilter and ffmpeg
- audio filters support in libavfilter and avconv
- add fps filter
- audio split filter
- vorbis parser
+1 -1
View File
@@ -31,7 +31,7 @@ PROJECT_NAME = FFmpeg
# This could be handy for archiving the generated documentation or
# if some version control system is used.
PROJECT_NUMBER = 0.11.2
PROJECT_NUMBER =
# With the PROJECT_LOGO tag one can specify an logo or icon that is included
# in the documentation. The maximum height of the logo should not exceed 55
+1 -1
View File
@@ -1 +1 @@
0.11.2
0.10.2.git
-1
View File
@@ -1 +0,0 @@
0.11.2
Vendored
+6 -13
View File
@@ -112,7 +112,7 @@ Component options:
--disable-swscale disable libswscale build
--disable-postproc disable libpostproc build
--disable-avfilter disable video filter support [no]
--enable-avresample enable libavresample build [no]
--disable-avresample disable libavresample build [no]
--disable-pthreads disable pthreads [auto]
--disable-w32threads disable Win32 threads [auto]
--disable-os2threads disable OS/2 threads [auto]
@@ -1173,7 +1173,6 @@ HAVE_LIST="
dlfcn_h
dlopen
dos_paths
dxva_h
ebp_available
ebx_available
exp2
@@ -1218,6 +1217,7 @@ HAVE_LIST="
memalign
mkstemp
mmap
netinet_sctp_h
PeekNamedPipe
poll_h
posix_memalign
@@ -1237,7 +1237,6 @@ HAVE_LIST="
struct_addrinfo
struct_ipv6_mreq
struct_rusage_ru_maxrss
struct_sctp_event_subscribe
struct_sockaddr_in6
struct_sockaddr_sa_len
struct_sockaddr_storage
@@ -1666,7 +1665,7 @@ mmst_protocol_deps="network"
rtmp_protocol_deps="!librtmp_protocol"
rtmp_protocol_select="tcp_protocol"
rtp_protocol_select="udp_protocol"
sctp_protocol_deps="network struct_sctp_event_subscribe"
sctp_protocol_deps="network netinet_sctp_h"
tcp_protocol_deps="network"
tls_protocol_deps_any="openssl gnutls"
tls_protocol_select="tcp_protocol"
@@ -1677,13 +1676,11 @@ aconvert_filter_deps="swresample"
amovie_filter_deps="avcodec avformat"
aresample_filter_deps="swresample"
ass_filter_deps="libass"
asyncts_filter_deps="avresample"
blackframe_filter_deps="gpl"
boxblur_filter_deps="gpl"
colormatrix_filter_deps="gpl"
cropdetect_filter_deps="gpl"
delogo_filter_deps="gpl"
deshake_filter_deps="avcodec"
drawtext_filter_deps="libfreetype"
frei0r_filter_deps="frei0r dlopen"
frei0r_filter_extralibs='$ldl'
@@ -1881,6 +1878,7 @@ enable avcodec
enable avdevice
enable avfilter
enable avformat
enable avresample
enable avutil
enable postproc
enable stripping
@@ -2854,10 +2852,6 @@ die_license_disabled() {
enabled $1 || { enabled $2 && die "$2 is $1 and --enable-$1 is not specified."; }
}
die_license_disabled_gpl() {
enabled $1 || { enabled $2 && die "$2 is incompatible with the gpl and --enable-$1 is not specified."; }
}
die_license_disabled gpl libcdio
die_license_disabled gpl libutvideo
die_license_disabled gpl libx264
@@ -2867,7 +2861,7 @@ die_license_disabled gpl x11grab
die_license_disabled nonfree libaacplus
die_license_disabled nonfree libfaac
enabled gpl && die_license_disabled_gpl nonfree openssl
die_license_disabled nonfree openssl
die_license_disabled version3 libopencore_amrnb
die_license_disabled version3 libopencore_amrwb
@@ -3071,7 +3065,7 @@ if enabled network; then
check_type netinet/in.h "struct sockaddr_in6"
check_type "sys/types.h sys/socket.h" "struct sockaddr_storage"
check_struct "sys/types.h sys/socket.h" "struct sockaddr" sa_len
check_type netinet/sctp.h "struct sctp_event_subscribe"
check_header netinet/sctp.h
# Prefer arpa/inet.h over winsock2
if check_header arpa/inet.h ; then
check_func closesocket
@@ -3126,7 +3120,6 @@ check_func_headers windows.h VirtualAlloc
check_func_headers glob.h glob
check_header dlfcn.h
check_header dxva.h
check_header dxva2api.h -D_WIN32_WINNT=0x0600
check_header libcrystalhd/libcrystalhd_if.h
check_header malloc.h
+1 -1
View File
@@ -35,7 +35,7 @@ GENTEXI = format codec
GENTEXI := $(GENTEXI:%=doc/avoptions_%.texi)
$(GENTEXI): TAG = GENTEXI
$(GENTEXI): doc/avoptions_%.texi: doc/print_options$(HOSTEXESUF)
$(GENTEXI): doc/avoptions_%.texi: doc/print_options
$(M)doc/print_options $* > $@
doc/%.html: TAG = HTML
+1 -1
View File
@@ -1,7 +1,7 @@
Release Notes
=============
* 0.11 "Happiness" May, 2012
* 0.10 "Freedom" January, 2012
General notes
-4
View File
@@ -340,10 +340,6 @@ prefix is ``ffmpeg2pass''. The complete file name will be
@file{PREFIX-N.log}, where N is a number specific to the output
stream
Note that this option is overwritten by a local option of the same name
when using @code{-vcodec libx264}. That option maps to the x264 option stats
which has a different syntax.
@item -vlang @var{code}
Set the ISO 639 language code (3 letters) of the current video stream.
+2 -5
View File
@@ -1456,11 +1456,8 @@ static void term_init(void)
#if HAVE_TERMIOS_H
if(!run_as_daemon){
struct termios tty;
int istty = 1;
#if HAVE_ISATTY
istty = isatty(0) && isatty(2);
#endif
if (istty && tcgetattr (0, &tty) == 0) {
if (tcgetattr (0, &tty) == 0) {
oldtty = tty;
restore_tty = 1;
atexit(term_exit);
+38 -77
View File
@@ -232,7 +232,6 @@ typedef struct VideoState {
#endif
int refresh;
int last_video_stream, last_audio_stream, last_subtitle_stream;
} VideoState;
typedef struct AllocEventProps {
@@ -304,12 +303,13 @@ void av_noreturn exit_program(int ret)
exit(ret);
}
static int packet_queue_put_private(PacketQueue *q, AVPacket *pkt)
static int packet_queue_put(PacketQueue *q, AVPacket *pkt)
{
AVPacketList *pkt1;
if (q->abort_request)
return -1;
/* duplicate the packet */
if (pkt != &flush_pkt && av_dup_packet(pkt) < 0)
return -1;
pkt1 = av_malloc(sizeof(AVPacketList));
if (!pkt1)
@@ -317,7 +317,11 @@ static int packet_queue_put_private(PacketQueue *q, AVPacket *pkt)
pkt1->pkt = *pkt;
pkt1->next = NULL;
SDL_LockMutex(q->mutex);
if (!q->last_pkt)
q->first_pkt = pkt1;
else
q->last_pkt->next = pkt1;
@@ -326,25 +330,9 @@ static int packet_queue_put_private(PacketQueue *q, AVPacket *pkt)
q->size += pkt1->pkt.size + sizeof(*pkt1);
/* XXX: should duplicate packet data in DV case */
SDL_CondSignal(q->cond);
return 0;
}
static int packet_queue_put(PacketQueue *q, AVPacket *pkt)
{
int ret;
/* duplicate the packet */
if (pkt != &flush_pkt && av_dup_packet(pkt) < 0)
return -1;
SDL_LockMutex(q->mutex);
ret = packet_queue_put_private(q, pkt);
SDL_UnlockMutex(q->mutex);
if (pkt != &flush_pkt && ret < 0)
av_free_packet(pkt);
return ret;
return 0;
}
/* packet queue handling */
@@ -353,7 +341,7 @@ static void packet_queue_init(PacketQueue *q)
memset(q, 0, sizeof(PacketQueue));
q->mutex = SDL_CreateMutex();
q->cond = SDL_CreateCond();
q->abort_request = 1;
packet_queue_put(q, &flush_pkt);
}
static void packet_queue_flush(PacketQueue *q)
@@ -373,7 +361,7 @@ static void packet_queue_flush(PacketQueue *q)
SDL_UnlockMutex(q->mutex);
}
static void packet_queue_destroy(PacketQueue *q)
static void packet_queue_end(PacketQueue *q)
{
packet_queue_flush(q);
SDL_DestroyMutex(q->mutex);
@@ -391,14 +379,6 @@ static void packet_queue_abort(PacketQueue *q)
SDL_UnlockMutex(q->mutex);
}
static void packet_queue_start(PacketQueue *q)
{
SDL_LockMutex(q->mutex);
q->abort_request = 0;
packet_queue_put_private(q, &flush_pkt);
SDL_UnlockMutex(q->mutex);
}
/* return < 0 if aborted, 0 if no packet and > 0 if packet. */
static int packet_queue_get(PacketQueue *q, AVPacket *pkt, int block)
{
@@ -897,9 +877,6 @@ static void stream_close(VideoState *is)
is->abort_request = 1;
SDL_WaitThread(is->read_tid, NULL);
SDL_WaitThread(is->refresh_tid, NULL);
packet_queue_destroy(&is->videoq);
packet_queue_destroy(&is->audioq);
packet_queue_destroy(&is->subtitleq);
/* free all pictures */
for (i = 0; i < VIDEO_PICTURE_QUEUE_SIZE; i++) {
@@ -1839,13 +1816,8 @@ static int video_thread(void *arg)
int last_w = is->video_st->codec->width;
int last_h = is->video_st->codec->height;
if ((ret = configure_video_filters(graph, is, vfilters)) < 0) {
SDL_Event event;
event.type = FF_QUIT_EVENT;
event.user.data1 = is;
SDL_PushEvent(&event);
if ((ret = configure_video_filters(graph, is, vfilters)) < 0)
goto the_end;
}
filt_out = is->out_video_filter;
#endif
@@ -1921,7 +1893,6 @@ static int video_thread(void *arg)
stream_toggle_pause(is);
}
the_end:
avcodec_flush_buffers(is->video_st->codec);
#if CONFIG_AVFILTER
av_freep(&vfilters);
avfilter_graph_free(&graph);
@@ -2269,9 +2240,9 @@ static int stream_component_open(VideoState *is, int stream_index)
opts = filter_codec_opts(codec_opts, codec, ic, ic->streams[stream_index]);
switch(avctx->codec_type){
case AVMEDIA_TYPE_AUDIO : is->last_audio_stream = stream_index; if(audio_codec_name ) codec= avcodec_find_decoder_by_name( audio_codec_name); break;
case AVMEDIA_TYPE_SUBTITLE: is->last_subtitle_stream = stream_index; if(subtitle_codec_name) codec= avcodec_find_decoder_by_name(subtitle_codec_name); break;
case AVMEDIA_TYPE_VIDEO : is->last_video_stream = stream_index; if(video_codec_name ) codec= avcodec_find_decoder_by_name( video_codec_name); break;
case AVMEDIA_TYPE_AUDIO : if(audio_codec_name ) codec= avcodec_find_decoder_by_name( audio_codec_name); break;
case AVMEDIA_TYPE_SUBTITLE: if(subtitle_codec_name) codec= avcodec_find_decoder_by_name(subtitle_codec_name); break;
case AVMEDIA_TYPE_VIDEO : if(video_codec_name ) codec= avcodec_find_decoder_by_name( video_codec_name); break;
}
if (!codec)
return -1;
@@ -2372,20 +2343,20 @@ static int stream_component_open(VideoState *is, int stream_index)
is->audio_diff_threshold = 2.0 * SDL_AUDIO_BUFFER_SIZE / wanted_spec.freq;
memset(&is->audio_pkt, 0, sizeof(is->audio_pkt));
packet_queue_start(&is->audioq);
packet_queue_init(&is->audioq);
SDL_PauseAudio(0);
break;
case AVMEDIA_TYPE_VIDEO:
is->video_stream = stream_index;
is->video_st = ic->streams[stream_index];
packet_queue_start(&is->videoq);
packet_queue_init(&is->videoq);
is->video_tid = SDL_CreateThread(video_thread, is);
break;
case AVMEDIA_TYPE_SUBTITLE:
is->subtitle_stream = stream_index;
is->subtitle_st = ic->streams[stream_index];
packet_queue_start(&is->subtitleq);
packet_queue_init(&is->subtitleq);
is->subtitle_tid = SDL_CreateThread(subtitle_thread, is);
break;
@@ -2410,7 +2381,7 @@ static void stream_component_close(VideoState *is, int stream_index)
SDL_CloseAudio();
packet_queue_flush(&is->audioq);
packet_queue_end(&is->audioq);
av_free_packet(&is->audio_pkt);
if (is->swr_ctx)
swr_free(&is->swr_ctx);
@@ -2436,7 +2407,7 @@ static void stream_component_close(VideoState *is, int stream_index)
SDL_WaitThread(is->video_tid, NULL);
packet_queue_flush(&is->videoq);
packet_queue_end(&is->videoq);
break;
case AVMEDIA_TYPE_SUBTITLE:
packet_queue_abort(&is->subtitleq);
@@ -2451,7 +2422,7 @@ static void stream_component_close(VideoState *is, int stream_index)
SDL_WaitThread(is->subtitle_tid, NULL);
packet_queue_flush(&is->subtitleq);
packet_queue_end(&is->subtitleq);
break;
default:
break;
@@ -2498,9 +2469,9 @@ static int read_thread(void *arg)
int orig_nb_streams;
memset(st_index, -1, sizeof(st_index));
is->last_video_stream = is->video_stream = -1;
is->last_audio_stream = is->audio_stream = -1;
is->last_subtitle_stream = is->subtitle_stream = -1;
is->video_stream = -1;
is->audio_stream = -1;
is->subtitle_stream = -1;
ic = avformat_alloc_context();
ic->interrupt_callback.callback = decode_interrupt_cb;
@@ -2654,9 +2625,9 @@ static int read_thread(void *arg)
/* if the queue are full, no need to read more */
if ( is->audioq.size + is->videoq.size + is->subtitleq.size > MAX_QUEUE_SIZE
|| ( (is->audioq .nb_packets > MIN_FRAMES || is->audio_stream < 0 || is->audioq.abort_request)
&& (is->videoq .nb_packets > MIN_FRAMES || is->video_stream < 0 || is->videoq.abort_request)
&& (is->subtitleq.nb_packets > MIN_FRAMES || is->subtitle_stream < 0 || is->subtitleq.abort_request))) {
|| ( (is->audioq .nb_packets > MIN_FRAMES || is->audio_stream < 0)
&& (is->videoq .nb_packets > MIN_FRAMES || is->video_stream < 0)
&& (is->subtitleq.nb_packets > MIN_FRAMES || is->subtitle_stream < 0))) {
/* wait 10 ms */
SDL_Delay(10);
continue;
@@ -2761,10 +2732,6 @@ static VideoState *stream_open(const char *filename, AVInputFormat *iformat)
is->subpq_mutex = SDL_CreateMutex();
is->subpq_cond = SDL_CreateCond();
packet_queue_init(&is->videoq);
packet_queue_init(&is->audioq);
packet_queue_init(&is->subtitleq);
is->av_sync_type = av_sync_type;
is->read_tid = SDL_CreateThread(read_thread, is);
if (!is->read_tid) {
@@ -2778,19 +2745,16 @@ static void stream_cycle_channel(VideoState *is, int codec_type)
{
AVFormatContext *ic = is->ic;
int start_index, stream_index;
int old_index;
AVStream *st;
if (codec_type == AVMEDIA_TYPE_VIDEO) {
start_index = is->last_video_stream;
old_index = is->video_stream;
} else if (codec_type == AVMEDIA_TYPE_AUDIO) {
start_index = is->last_audio_stream;
old_index = is->audio_stream;
} else {
start_index = is->last_subtitle_stream;
old_index = is->subtitle_stream;
}
if (codec_type == AVMEDIA_TYPE_VIDEO)
start_index = is->video_stream;
else if (codec_type == AVMEDIA_TYPE_AUDIO)
start_index = is->audio_stream;
else
start_index = is->subtitle_stream;
if (start_index < (codec_type == AVMEDIA_TYPE_SUBTITLE ? -1 : 0))
return;
stream_index = start_index;
for (;;) {
if (++stream_index >= is->ic->nb_streams)
@@ -2798,12 +2762,9 @@ static void stream_cycle_channel(VideoState *is, int codec_type)
if (codec_type == AVMEDIA_TYPE_SUBTITLE)
{
stream_index = -1;
is->last_subtitle_stream = -1;
goto the_end;
}
if (start_index == -1)
return;
stream_index = 0;
} else
stream_index = 0;
}
if (stream_index == start_index)
return;
@@ -2825,7 +2786,7 @@ static void stream_cycle_channel(VideoState *is, int codec_type)
}
}
the_end:
stream_component_close(is, old_index);
stream_component_close(is, start_index);
stream_component_open(is, stream_index);
}
+1 -1
View File
@@ -47,7 +47,7 @@ typedef struct EightSvxContext {
/* buffer used to store the whole audio decoded/interleaved chunk,
* which is sent with the first packet */
uint8_t *samples;
int64_t samples_size;
size_t samples_size;
int samples_idx;
} EightSvxContext;
+2 -3
View File
@@ -188,7 +188,7 @@ OBJS-$(CONFIG_FRAPS_DECODER) += fraps.o
OBJS-$(CONFIG_FRWU_DECODER) += frwu.o
OBJS-$(CONFIG_G723_1_DECODER) += g723_1.o acelp_vectors.o \
celp_filters.o celp_math.o
OBJS-$(CONFIG_G723_1_ENCODER) += g723_1.o acelp_vectors.o celp_math.o
OBJS-$(CONFIG_G723_1_ENCODER) += g723_1.o
OBJS-$(CONFIG_G729_DECODER) += g729dec.o lsp.o celp_math.o acelp_filters.o acelp_pitch_delay.o acelp_vectors.o g729postfilter.o
OBJS-$(CONFIG_GIF_DECODER) += gifdec.o lzw.o
OBJS-$(CONFIG_GIF_ENCODER) += gif.o lzwenc.o
@@ -347,7 +347,7 @@ OBJS-$(CONFIG_PNG_DECODER) += png.o pngdec.o pngdsp.o
OBJS-$(CONFIG_PNG_ENCODER) += png.o pngenc.o
OBJS-$(CONFIG_PPM_DECODER) += pnmdec.o pnm.o
OBJS-$(CONFIG_PPM_ENCODER) += pnmenc.o pnm.o
OBJS-$(CONFIG_PRORES_DECODER) += proresdec2.o proresdsp.o
OBJS-$(CONFIG_PRORES_DECODER) += proresdec2.o
OBJS-$(CONFIG_PRORES_LGPL_DECODER) += proresdec_lgpl.o proresdsp.o proresdata.o
OBJS-$(CONFIG_PRORES_ENCODER) += proresenc_anatoliy.o
OBJS-$(CONFIG_PRORES_ANATOLIY_ENCODER) += proresenc_anatoliy.o
@@ -626,7 +626,6 @@ OBJS-$(CONFIG_MATROSKA_DEMUXER) += mpeg4audio.o mpegaudiodata.o
OBJS-$(CONFIG_MATROSKA_MUXER) += xiph.o mpeg4audio.o \
flacdec.o flacdata.o flac.o \
mpegaudiodata.o vorbis_data.o
OBJS-$(CONFIG_MP2_MUXER) += mpegaudiodata.o mpegaudiodecheader.o
OBJS-$(CONFIG_MP3_MUXER) += mpegaudiodata.o mpegaudiodecheader.o
OBJS-$(CONFIG_MOV_DEMUXER) += mpeg4audio.o mpegaudiodata.o ac3tab.o timecode.o
OBJS-$(CONFIG_MOV_MUXER) += mpeg4audio.o mpegaudiodata.o
+1 -1
View File
@@ -878,7 +878,7 @@ static void search_for_quantizers_faac(AVCodecContext *avctx, AACEncContext *s,
} else {
for (w = 0; w < 8; w++) {
const float *coeffs = sce->coeffs + w*128;
curband = start = 0;
start = 0;
for (i = 0; i < 128; i++) {
if (i - start >= sce->ics.swb_sizes[curband]) {
start += sce->ics.swb_sizes[curband];
-3
View File
@@ -487,7 +487,6 @@ static ChannelElement *get_che(AACContext *ac, int type, int elem_id)
return NULL;
ac->oc[1].m4ac.chan_config = 2;
ac->oc[1].m4ac.ps = 0;
}
// And vice-versa
if (!ac->tags_mapped && type == TYPE_SCE && ac->oc[1].m4ac.chan_config == 2) {
@@ -505,8 +504,6 @@ static ChannelElement *get_che(AACContext *ac, int type, int elem_id)
return NULL;
ac->oc[1].m4ac.chan_config = 1;
if (ac->oc[1].m4ac.sbr)
ac->oc[1].m4ac.ps = -1;
}
// For indexed channel configurations map the channels solely based on position.
switch (ac->oc[1].m4ac.chan_config) {
+4 -5
View File
@@ -66,7 +66,7 @@ static int aasc_decode_frame(AVCodecContext *avctx,
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
AascContext *s = avctx->priv_data;
int compr, i, stride, psize;
int compr, i, stride;
s->frame.reference = 3;
s->frame.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE;
@@ -78,7 +78,6 @@ static int aasc_decode_frame(AVCodecContext *avctx,
compr = AV_RL32(buf);
buf += 4;
buf_size -= 4;
psize = avctx->bits_per_coded_sample / 8;
switch (avctx->codec_tag) {
case MKTAG('A', 'A', 'S', '4'):
bytestream2_init(&s->gb, buf - 4, buf_size + 4);
@@ -87,13 +86,13 @@ static int aasc_decode_frame(AVCodecContext *avctx,
case MKTAG('A', 'A', 'S', 'C'):
switch(compr){
case 0:
stride = (avctx->width * psize + psize) & ~psize;
stride = (avctx->width * 3 + 3) & ~3;
for(i = avctx->height - 1; i >= 0; i--){
if(avctx->width * psize > buf_size){
if(avctx->width*3 > buf_size){
av_log(avctx, AV_LOG_ERROR, "Next line is beyond buffer bounds\n");
break;
}
memcpy(s->frame.data[0] + i*s->frame.linesize[0], buf, avctx->width * psize);
memcpy(s->frame.data[0] + i*s->frame.linesize[0], buf, avctx->width*3);
buf += stride;
buf_size -= stride;
}
+2 -2
View File
@@ -48,8 +48,8 @@ static int avui_decode_frame(AVCodecContext *avctx, void *data,
if (pic->data[0])
avctx->release_buffer(avctx, pic);
if (avctx->extradata_size >= 24 &&
!memcmp(&avctx->extradata[4], "APRGAPRG0001", 12))
if (!memcmp(&avctx->extradata[4], "APRGAPRG0001", 12) &&
avctx->extradata_size >= 24)
interlaced = avctx->extradata[19] != 1;
if (avctx->height == 486) {
skip = 10;
-1
View File
@@ -107,7 +107,6 @@ AVCodec ff_avui_encoder = {
.init = avui_encode_init,
.encode2 = avui_encode_frame,
.close = avui_encode_close,
.capabilities = CODEC_CAP_EXPERIMENTAL,
.pix_fmts = (const enum PixelFormat[]){ PIX_FMT_UYVY422, PIX_FMT_NONE },
.long_name = NULL_IF_CONFIG_SMALL("Avid Meridien Uncompressed"),
};
-5
View File
@@ -1128,11 +1128,6 @@ static int bink_decode_plane(BinkContext *c, GetBitContext *gb, int plane_idx,
xoff = get_value(c, BINK_SRC_X_OFF);
yoff = get_value(c, BINK_SRC_Y_OFF);
ref = prev + xoff + yoff * stride;
if (ref < ref_start || ref > ref_end) {
av_log(c->avctx, AV_LOG_ERROR, "Copy out of bounds @%d, %d\n",
bx*8 + xoff, by*8 + yoff);
return -1;
}
c->dsp.put_pixels_tab[1][0](dst, ref, stride, 8);
memset(dctblock, 0, sizeof(*dctblock) * 64);
dctblock[0] = get_value(c, BINK_SRC_INTER_DC);
+3 -3
View File
@@ -91,9 +91,9 @@ static av_cold int decode_init(AVCodecContext *avctx)
frame_len_bits = 11;
}
if (avctx->channels < 1 || avctx->channels > MAX_CHANNELS) {
av_log(avctx, AV_LOG_ERROR, "invalid number of channels: %d\n", avctx->channels);
return AVERROR_INVALIDDATA;
if (avctx->channels > MAX_CHANNELS) {
av_log(avctx, AV_LOG_ERROR, "too many channels: %d\n", avctx->channels);
return -1;
}
s->version_b = avctx->extradata && avctx->extradata[3] == 'b';
+3 -12
View File
@@ -21,7 +21,6 @@
#include "avcodec.h"
#include "bytestream.h"
#include "libavutil/avassert.h"
enum BMVFlags{
BMV_NOP = 0,
@@ -53,7 +52,7 @@ typedef struct BMVDecContext {
static int decode_bmv_frame(const uint8_t *source, int src_len, uint8_t *frame, int frame_off)
{
unsigned val, saved_val = 0;
int val, saved_val = 0;
int tmplen = src_len;
const uint8_t *src, *source_end = source + src_len;
uint8_t *frame_end = frame + SCREEN_WIDE * SCREEN_HIGH;
@@ -99,8 +98,6 @@ static int decode_bmv_frame(const uint8_t *source, int src_len, uint8_t *frame,
}
if (!(val & 0xC)) {
for (;;) {
if(shift>22)
return -1;
if (!read_two_nibbles) {
if (src < source || src >= source_end)
return -1;
@@ -134,7 +131,6 @@ static int decode_bmv_frame(const uint8_t *source, int src_len, uint8_t *frame,
}
advance_mode = val & 1;
len = (val >> 1) - 1;
av_assert0(len>0);
mode += 1 + advance_mode;
if (mode >= 4)
mode -= 3;
@@ -143,7 +139,7 @@ static int decode_bmv_frame(const uint8_t *source, int src_len, uint8_t *frame,
switch (mode) {
case 1:
if (forward) {
if (dst - frame + SCREEN_WIDE < -frame_off ||
if (dst - frame + SCREEN_WIDE < frame_off ||
frame_end - dst < frame_off + len)
return -1;
for (i = 0; i < len; i++)
@@ -151,7 +147,7 @@ static int decode_bmv_frame(const uint8_t *source, int src_len, uint8_t *frame,
dst += len;
} else {
dst -= len;
if (dst - frame + SCREEN_WIDE < -frame_off ||
if (dst - frame + SCREEN_WIDE < frame_off ||
frame_end - dst < frame_off + len)
return -1;
for (i = len - 1; i >= 0; i--)
@@ -268,11 +264,6 @@ static av_cold int decode_init(AVCodecContext *avctx)
c->avctx = avctx;
avctx->pix_fmt = PIX_FMT_PAL8;
if (avctx->width != SCREEN_WIDE || avctx->height != SCREEN_HIGH) {
av_log(avctx, AV_LOG_ERROR, "Invalid dimension %dx%d\n", avctx->width, avctx->height);
return AVERROR_INVALIDDATA;
}
c->pic.reference = 1;
if (avctx->get_buffer(avctx, &c->pic) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
-4
View File
@@ -280,10 +280,6 @@ static int cdg_decode_frame(AVCodecContext *avctx,
av_log(avctx, AV_LOG_ERROR, "buffer too small for decoder\n");
return AVERROR(EINVAL);
}
if (buf_size > CDG_HEADER_SIZE + CDG_DATA_SIZE) {
av_log(avctx, AV_LOG_ERROR, "buffer too big for decoder\n");
return AVERROR(EINVAL);
}
ret = avctx->reget_buffer(avctx, &cc->frame);
if (ret) {
-7
View File
@@ -25,14 +25,7 @@
#define _WIN32_WINNT 0x0600
#define COBJMACROS
#include "config.h"
#include "dxva2.h"
#if HAVE_DXVA_H
#include <dxva.h>
#endif
#include "avcodec.h"
#include "mpegvideo.h"
+2 -2
View File
@@ -48,7 +48,7 @@ typedef struct Escape124Context {
CodeBook codebooks[3];
} Escape124Context;
static int can_safely_read(GetBitContext* gb, uint64_t bits) {
static int can_safely_read(GetBitContext* gb, int bits) {
return get_bits_left(gb) >= bits;
}
@@ -90,7 +90,7 @@ static CodeBook unpack_codebook(GetBitContext* gb, unsigned depth,
unsigned i, j;
CodeBook cb = { 0 };
if (!can_safely_read(gb, size * 34L))
if (!can_safely_read(gb, size * 34))
return cb;
if (size >= INT_MAX / sizeof(MacroBlock))
+12 -26
View File
@@ -47,7 +47,7 @@ typedef struct EXRContext {
AVFrame picture;
int compr;
int bits_per_color_id;
int8_t channel_offsets[4]; // 0 = red, 1 = green, 2 = blue and 3 = alpha
int8_t channel_offsets[3]; // 0 = red, 1 = green and 2 = blue
} EXRContext;
/**
@@ -170,7 +170,6 @@ static int decode_frame(AVCodecContext *avctx,
s->channel_offsets[0] = -1;
s->channel_offsets[1] = -1;
s->channel_offsets[2] = -1;
s->channel_offsets[3] = -1;
s->bits_per_color_id = -1;
if (buf_end - buf < 10) {
@@ -210,8 +209,6 @@ static int decode_frame(AVCodecContext *avctx,
channel_index = 1;
if (!strcmp(buf, "B"))
channel_index = 2;
if (!strcmp(buf, "A"))
channel_index = 3;
while (bytestream_get_byte(&buf) && buf < channel_list_end)
continue; /* skip */
@@ -305,9 +302,9 @@ static int decode_frame(AVCodecContext *avctx,
if (!variable_buffer_data_size)
return -1;
s->compr = *buf;
switch (s->compr) {
switch (*buf) {
case EXR_RAW:
s->compr = *buf;
break;
case EXR_RLE:
case EXR_ZIP1:
@@ -315,7 +312,7 @@ static int decode_frame(AVCodecContext *avctx,
case EXR_PIZ:
case EXR_B44:
default:
av_log(avctx, AV_LOG_ERROR, "Compression type %d is not supported\n", s->compr);
av_log(avctx, AV_LOG_ERROR, "This type of compression is not supported\n");
return -1;
}
@@ -357,10 +354,7 @@ static int decode_frame(AVCodecContext *avctx,
switch (s->bits_per_color_id) {
case 2: // 32-bit
case 1: // 16-bit
if (s->channel_offsets[3] >= 0)
avctx->pix_fmt = PIX_FMT_RGBA64;
else
avctx->pix_fmt = PIX_FMT_RGB48;
avctx->pix_fmt = PIX_FMT_RGB48;
break;
// 8-bit
case 0:
@@ -396,7 +390,7 @@ static int decode_frame(AVCodecContext *avctx,
// Zero out the start if ymin is not 0
for (y = 0; y < ymin; y++) {
memset(ptr, 0, avctx->width * 2 * av_pix_fmt_descriptors[avctx->pix_fmt].nb_components);
memset(ptr, 0, avctx->width * 6);
ptr += stride;
}
@@ -411,27 +405,21 @@ static int decode_frame(AVCodecContext *avctx,
if (line_offset > avpkt->size - xdelta * current_channel_offset) {
// Line offset is probably wrong and not inside the buffer
av_log(avctx, AV_LOG_WARNING, "Line offset for line %d is out of reach setting it to black\n", y);
memset(ptr_x, 0, avctx->width * 2 * av_pix_fmt_descriptors[avctx->pix_fmt].nb_components);
memset(ptr_x, 0, avctx->width * 6);
} else {
const uint8_t *red_channel_buffer = avpkt->data + line_offset + xdelta * s->channel_offsets[0];
const uint8_t *green_channel_buffer = avpkt->data + line_offset + xdelta * s->channel_offsets[1];
const uint8_t *blue_channel_buffer = avpkt->data + line_offset + xdelta * s->channel_offsets[2];
const uint8_t *alpha_channel_buffer = 0;
if (s->channel_offsets[3] >= 0)
alpha_channel_buffer = avpkt->data + line_offset + xdelta * s->channel_offsets[3];
// Zero out the start if xmin is not 0
memset(ptr_x, 0, xmin * 2 * av_pix_fmt_descriptors[avctx->pix_fmt].nb_components);
ptr_x += xmin * av_pix_fmt_descriptors[avctx->pix_fmt].nb_components;
memset(ptr_x, 0, xmin * 6);
ptr_x += xmin * 3;
if (s->bits_per_color_id == 2) {
// 32-bit
for (x = 0; x < xdelta; x++) {
*ptr_x++ = exr_flt2uint(bytestream_get_le32(&red_channel_buffer));
*ptr_x++ = exr_flt2uint(bytestream_get_le32(&green_channel_buffer));
*ptr_x++ = exr_flt2uint(bytestream_get_le32(&blue_channel_buffer));
if (alpha_channel_buffer)
*ptr_x++ = exr_flt2uint(bytestream_get_le32(&alpha_channel_buffer));
}
} else {
// 16-bit
@@ -439,14 +427,12 @@ static int decode_frame(AVCodecContext *avctx,
*ptr_x++ = exr_halflt2uint(bytestream_get_le16(&red_channel_buffer));
*ptr_x++ = exr_halflt2uint(bytestream_get_le16(&green_channel_buffer));
*ptr_x++ = exr_halflt2uint(bytestream_get_le16(&blue_channel_buffer));
if (alpha_channel_buffer)
*ptr_x++ = exr_halflt2uint(bytestream_get_le16(&alpha_channel_buffer));
}
}
// Zero out the end if xmax+1 is not w
memset(ptr_x, 0, (avctx->width - (xmax + 1)) * 2 * av_pix_fmt_descriptors[avctx->pix_fmt].nb_components);
ptr_x += (avctx->width - (xmax + 1)) * av_pix_fmt_descriptors[avctx->pix_fmt].nb_components;
memset(ptr_x, 0, (avctx->width - (xmax + 1)) * 6);
ptr_x += (avctx->width - (xmax + 1)) * 3;
}
// Move to next line
@@ -456,7 +442,7 @@ static int decode_frame(AVCodecContext *avctx,
// Zero out the end if ymax+1 is not h
for (y = ymax + 1; y < avctx->height; y++) {
memset(ptr, 0, avctx->width * 2 * av_pix_fmt_descriptors[avctx->pix_fmt].nb_components);
memset(ptr, 0, avctx->width * 6);
ptr += stride;
}
+1 -1
View File
@@ -228,7 +228,7 @@ static int decode_group3_2d_line(AVCodecContext *avctx, GetBitContext *gb,
mode = !mode;
}
//sync line pointers
while(offs < width && run_off <= offs){
while(run_off <= offs){
run_off += *ref++;
run_off += *ref++;
}
+5 -13
View File
@@ -1651,9 +1651,9 @@ static int read_quant_table(RangeCoder *c, int16_t *quant_table, int scale){
memset(state, 128, sizeof(state));
for(v=0; i<128 ; v++){
unsigned len= get_symbol(c, state, 0) + 1;
int len= get_symbol(c, state, 0) + 1;
if(len > 128 - i) return -1;
if(len + i > 128) return -1;
while(len--){
quant_table[i] = scale*v;
@@ -1697,10 +1697,8 @@ static int read_extra_header(FFV1Context *f){
ff_build_rac_states(c, 0.05*(1LL<<32), 256-8);
f->version= get_symbol(c, state, 0);
if(f->version > 2) {
c->bytestream_end -= 4;
if(f->version > 2)
f->minor_version= get_symbol(c, state, 0);
}
f->ac= f->avctx->coder_type= get_symbol(c, state, 0);
if(f->ac>1){
for(i=1; i<256; i++){
@@ -1769,12 +1767,7 @@ static int read_header(FFV1Context *f){
memset(state, 128, sizeof(state));
if(f->version < 2){
unsigned v= get_symbol(c, state, 0);
if(v >= 2){
av_log(f->avctx, AV_LOG_ERROR, "invalid version %d in ver01 header\n", v);
return AVERROR_INVALIDDATA;
}
f->version = v;
f->version= get_symbol(c, state, 0);
f->ac= f->avctx->coder_type= get_symbol(c, state, 0);
if(f->ac>1){
for(i=1; i<256; i++){
@@ -1991,8 +1984,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac
}
if(avctx->debug&FF_DEBUG_PICT_INFO)
av_log(avctx, AV_LOG_DEBUG, "ver:%d keyframe:%d coder:%d ec:%d slices:%d\n",
f->version, p->key_frame, f->ac, f->ec, f->slice_count);
av_log(avctx, AV_LOG_ERROR, "keyframe:%d coder:%d\n", p->key_frame, f->ac);
buf_p= buf + buf_size;
for(i=f->slice_count-1; i>=0; i--){
+6 -6
View File
@@ -161,17 +161,17 @@ static int decode_frame(AVCodecContext *avctx,
unsigned needed_size = avctx->width*avctx->height*3;
if (version == 0) needed_size /= 2;
needed_size += header_size;
/* bit 31 means same as previous pic */
if (header & (1U<<31)) {
*data_size = 0;
return buf_size;
}
if (buf_size != needed_size) {
if (buf_size != needed_size && buf_size != header_size) {
av_log(avctx, AV_LOG_ERROR,
"Invalid frame length %d (should be %d)\n",
buf_size, needed_size);
return -1;
}
/* bit 31 means same as previous pic */
if (header & (1U<<31)) {
*data_size = 0;
return buf_size;
}
} else {
/* skip frame */
if (buf_size == 8) {
-5
View File
@@ -145,11 +145,6 @@ static av_cold int gif_encode_init(AVCodecContext *avctx)
{
GIFContext *s = avctx->priv_data;
if (avctx->width > 65535 || avctx->height > 65535) {
av_log(avctx, AV_LOG_ERROR, "GIF does not support resolutions above 65535x65535\n");
return -1;
}
avctx->coded_frame = &s->picture;
s->lzw = av_mallocz(ff_lzw_encode_state_size);
if (!s->lzw)
+14 -19
View File
@@ -1615,7 +1615,7 @@ static void decode_postinit(H264Context *h, int setup_finished)
|| (h->last_pocs[MAX_DELAYED_PIC_COUNT-2] > INT_MIN && h->last_pocs[MAX_DELAYED_PIC_COUNT-1] - h->last_pocs[MAX_DELAYED_PIC_COUNT-2] > 2))
out_of_order = FFMAX(out_of_order, 1);
if(s->avctx->has_b_frames < out_of_order && !h->sps.bitstream_restriction_flag){
av_log(s->avctx, AV_LOG_VERBOSE, "Increasing reorder buffer to %d\n", out_of_order);
av_log(s->avctx, AV_LOG_WARNING, "Increasing reorder buffer to %d\n", out_of_order);
s->avctx->has_b_frames = out_of_order;
s->low_delay = 0;
}
@@ -2719,19 +2719,19 @@ static void init_scan_tables(H264Context *h)
#undef T
}
if (h->sps.transform_bypass) { // FIXME same ugly
memcpy(h->zigzag_scan_q0 , zigzag_scan , sizeof(h->zigzag_scan_q0 ));
memcpy(h->zigzag_scan8x8_q0 , ff_zigzag_direct , sizeof(h->zigzag_scan8x8_q0 ));
memcpy(h->zigzag_scan8x8_cavlc_q0 , zigzag_scan8x8_cavlc , sizeof(h->zigzag_scan8x8_cavlc_q0));
memcpy(h->field_scan_q0 , field_scan , sizeof(h->field_scan_q0 ));
memcpy(h->field_scan8x8_q0 , field_scan8x8 , sizeof(h->field_scan8x8_q0 ));
memcpy(h->field_scan8x8_cavlc_q0 , field_scan8x8_cavlc , sizeof(h->field_scan8x8_cavlc_q0 ));
h->zigzag_scan_q0 = zigzag_scan;
h->zigzag_scan8x8_q0 = ff_zigzag_direct;
h->zigzag_scan8x8_cavlc_q0 = zigzag_scan8x8_cavlc;
h->field_scan_q0 = field_scan;
h->field_scan8x8_q0 = field_scan8x8;
h->field_scan8x8_cavlc_q0 = field_scan8x8_cavlc;
} else {
memcpy(h->zigzag_scan_q0 , h->zigzag_scan , sizeof(h->zigzag_scan_q0 ));
memcpy(h->zigzag_scan8x8_q0 , h->zigzag_scan8x8 , sizeof(h->zigzag_scan8x8_q0 ));
memcpy(h->zigzag_scan8x8_cavlc_q0 , h->zigzag_scan8x8_cavlc , sizeof(h->zigzag_scan8x8_cavlc_q0));
memcpy(h->field_scan_q0 , h->field_scan , sizeof(h->field_scan_q0 ));
memcpy(h->field_scan8x8_q0 , h->field_scan8x8 , sizeof(h->field_scan8x8_q0 ));
memcpy(h->field_scan8x8_cavlc_q0 , h->field_scan8x8_cavlc , sizeof(h->field_scan8x8_cavlc_q0 ));
h->zigzag_scan_q0 = h->zigzag_scan;
h->zigzag_scan8x8_q0 = h->zigzag_scan8x8;
h->zigzag_scan8x8_cavlc_q0 = h->zigzag_scan8x8_cavlc;
h->field_scan_q0 = h->field_scan;
h->field_scan8x8_q0 = h->field_scan8x8;
h->field_scan8x8_cavlc_q0 = h->field_scan8x8_cavlc;
}
}
@@ -4032,9 +4032,7 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg)
loop_filter(h, lf_x_start, s->mb_x + 1);
return 0;
}
if (h->cabac.bytestream > h->cabac.bytestream_end + 2 )
av_log(h->s.avctx, AV_LOG_DEBUG, "bytestream overread %td\n", h->cabac.bytestream_end - h->cabac.bytestream);
if (ret < 0 || h->cabac.bytestream > h->cabac.bytestream_end + 4) {
if (ret < 0 || h->cabac.bytestream > h->cabac.bytestream_end + 2) {
av_log(h->s.avctx, AV_LOG_ERROR,
"error while decoding MB %d %d, bytestream (%td)\n",
s->mb_x, s->mb_y,
@@ -4401,9 +4399,6 @@ again:
init_get_bits(&hx->inter_gb, ptr, bit_length);
hx->inter_gb_ptr = &hx->inter_gb;
av_log(h->s.avctx, AV_LOG_ERROR, "Partitioned H.264 support is incomplete\n");
return AVERROR_PATCHWELCOME;
if (hx->redundant_pic_count == 0 &&
hx->intra_gb_ptr &&
hx->s.data_partitioning &&
+6 -6
View File
@@ -421,12 +421,12 @@ typedef struct H264Context {
uint8_t field_scan[16];
uint8_t field_scan8x8[64];
uint8_t field_scan8x8_cavlc[64];
uint8_t zigzag_scan_q0[16];
uint8_t zigzag_scan8x8_q0[64];
uint8_t zigzag_scan8x8_cavlc_q0[64];
uint8_t field_scan_q0[16];
uint8_t field_scan8x8_q0[64];
uint8_t field_scan8x8_cavlc_q0[64];
const uint8_t *zigzag_scan_q0;
const uint8_t *zigzag_scan8x8_q0;
const uint8_t *zigzag_scan8x8_cavlc_q0;
const uint8_t *field_scan_q0;
const uint8_t *field_scan8x8_q0;
const uint8_t *field_scan8x8_cavlc_q0;
int x264_build;
+1 -2
View File
@@ -513,7 +513,7 @@ static int decode_residual(H264Context *h, GetBitContext *gb, DCTELEM *block, in
else
level_code= prefix + get_bits(gb, 4); //part
}else{
level_code= 30;
level_code= 30 + get_bits(gb, prefix-3); //part
if(prefix>=16){
if(prefix > 25+3){
av_log(h->s.avctx, AV_LOG_ERROR, "Invalid level prefix\n");
@@ -521,7 +521,6 @@ static int decode_residual(H264Context *h, GetBitContext *gb, DCTELEM *block, in
}
level_code += (1<<(prefix-3))-4096;
}
level_code += get_bits(gb, prefix-3); //part
}
if(trailing_ones < 3) level_code += 2;
+5 -5
View File
@@ -52,14 +52,14 @@ static const uint8_t golomb_to_inter_cbp[48] = {
17, 18, 20, 24, 19, 21, 26, 28, 23, 27, 29, 30, 22, 25, 38, 41
};
static const uint8_t zigzag_scan[16+1] = {
static const uint8_t zigzag_scan[16] = {
0 + 0 * 4, 1 + 0 * 4, 0 + 1 * 4, 0 + 2 * 4,
1 + 1 * 4, 2 + 0 * 4, 3 + 0 * 4, 2 + 1 * 4,
1 + 2 * 4, 0 + 3 * 4, 1 + 3 * 4, 2 + 2 * 4,
3 + 1 * 4, 3 + 2 * 4, 2 + 3 * 4, 3 + 3 * 4,
};
static const uint8_t field_scan[16+1] = {
static const uint8_t field_scan[16] = {
0 + 0 * 4, 0 + 1 * 4, 1 + 0 * 4, 0 + 2 * 4,
0 + 3 * 4, 1 + 1 * 4, 1 + 2 * 4, 1 + 3 * 4,
2 + 0 * 4, 2 + 1 * 4, 2 + 2 * 4, 2 + 3 * 4,
@@ -93,7 +93,7 @@ static const uint8_t chroma422_dc_scan[8] = {
};
// zigzag_scan8x8_cavlc[i] = zigzag_scan8x8[(i/4) + 16*(i%4)]
static const uint8_t zigzag_scan8x8_cavlc[64+1] = {
static const uint8_t zigzag_scan8x8_cavlc[64] = {
0 + 0 * 8, 1 + 1 * 8, 1 + 2 * 8, 2 + 2 * 8,
4 + 1 * 8, 0 + 5 * 8, 3 + 3 * 8, 7 + 0 * 8,
3 + 4 * 8, 1 + 7 * 8, 5 + 3 * 8, 6 + 3 * 8,
@@ -112,7 +112,7 @@ static const uint8_t zigzag_scan8x8_cavlc[64+1] = {
5 + 5 * 8, 6 + 5 * 8, 6 + 6 * 8, 7 + 7 * 8,
};
static const uint8_t field_scan8x8[64+1] = {
static const uint8_t field_scan8x8[64] = {
0 + 0 * 8, 0 + 1 * 8, 0 + 2 * 8, 1 + 0 * 8,
1 + 1 * 8, 0 + 3 * 8, 0 + 4 * 8, 1 + 2 * 8,
2 + 0 * 8, 1 + 3 * 8, 0 + 5 * 8, 0 + 6 * 8,
@@ -131,7 +131,7 @@ static const uint8_t field_scan8x8[64+1] = {
7 + 4 * 8, 7 + 5 * 8, 7 + 6 * 8, 7 + 7 * 8,
};
static const uint8_t field_scan8x8_cavlc[64+1] = {
static const uint8_t field_scan8x8_cavlc[64] = {
0 + 0 * 8, 1 + 1 * 8, 2 + 0 * 8, 0 + 7 * 8,
2 + 2 * 8, 2 + 3 * 8, 2 + 4 * 8, 3 + 3 * 8,
3 + 4 * 8, 4 + 3 * 8, 4 + 4 * 8, 5 + 3 * 8,
+4 -13
View File
@@ -191,13 +191,7 @@ static int extract_header(AVCodecContext *const avctx,
const uint8_t *buf;
unsigned buf_size;
IffContext *s = avctx->priv_data;
int palette_size;
if (avctx->extradata_size < 2) {
av_log(avctx, AV_LOG_ERROR, "not enough extradata\n");
return AVERROR_INVALIDDATA;
}
palette_size = avctx->extradata_size - AV_RB16(avctx->extradata);
int palette_size = avctx->extradata_size - AV_RB16(avctx->extradata);
if (avpkt) {
int image_size;
@@ -213,6 +207,8 @@ static int extract_header(AVCodecContext *const avctx,
return AVERROR_INVALIDDATA;
}
} else {
if (avctx->extradata_size < 2)
return AVERROR_INVALIDDATA;
buf = avctx->extradata;
buf_size = bytestream_get_be16(&buf);
if (buf_size <= 1 || palette_size < 0) {
@@ -316,12 +312,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
int err;
if (avctx->bits_per_coded_sample <= 8) {
int palette_size;
if (avctx->extradata_size >= 2)
palette_size = avctx->extradata_size - AV_RB16(avctx->extradata);
else
palette_size = 0;
int palette_size = avctx->extradata_size - AV_RB16(avctx->extradata);
avctx->pix_fmt = (avctx->bits_per_coded_sample < 8) ||
(avctx->extradata_size >= 2 && palette_size) ? PIX_FMT_PAL8 : PIX_FMT_GRAY8;
} else if (avctx->bits_per_coded_sample <= 32) {
+204 -181
View File
@@ -89,7 +89,7 @@ typedef struct {
DSPContext dsp;
FFTContext fft;
DECLARE_ALIGNED(32, FFTComplex, samples)[COEFFS/2];
DECLARE_ALIGNED(32, FFTComplex, samples)[COEFFS / 2];
float *out_samples;
} IMCContext;
@@ -99,11 +99,12 @@ static VLC huffman_vlc[4][4];
static const int vlc_offsets[17] = {
0, 640, 1156, 1732, 2308, 2852, 3396, 3924,
4452, 5220, 5860, 6628, 7268, 7908, 8424, 8936, VLC_TABLES_SIZE};
4452, 5220, 5860, 6628, 7268, 7908, 8424, 8936, VLC_TABLES_SIZE
};
static VLC_TYPE vlc_tables[VLC_TABLES_SIZE][2];
static av_cold int imc_decode_init(AVCodecContext * avctx)
static av_cold int imc_decode_init(AVCodecContext *avctx)
{
int i, j, ret;
IMCContext *q = avctx->priv_data;
@@ -116,27 +117,24 @@ static av_cold int imc_decode_init(AVCodecContext * avctx)
q->decoder_reset = 1;
for(i = 0; i < BANDS; i++)
for (i = 0; i < BANDS; i++)
q->old_floor[i] = 1.0;
/* Build mdct window, a simple sine window normalized with sqrt(2) */
ff_sine_window_init(q->mdct_sine_window, COEFFS);
for(i = 0; i < COEFFS; i++)
for (i = 0; i < COEFFS; i++)
q->mdct_sine_window[i] *= sqrt(2.0);
for(i = 0; i < COEFFS/2; i++){
for (i = 0; i < COEFFS / 2; i++) {
q->post_cos[i] = (1.0f / 32768) * cos(i / 256.0 * M_PI);
q->post_sin[i] = (1.0f / 32768) * sin(i / 256.0 * M_PI);
r1 = sin((i * 4.0 + 1.0) / 1024.0 * M_PI);
r2 = cos((i * 4.0 + 1.0) / 1024.0 * M_PI);
if (i & 0x1)
{
if (i & 0x1) {
q->pre_coef1[i] = (r1 + r2) * sqrt(2.0);
q->pre_coef2[i] = -(r1 - r2) * sqrt(2.0);
}
else
{
} else {
q->pre_coef1[i] = -(r1 + r2) * sqrt(2.0);
q->pre_coef2[i] = (r1 - r2) * sqrt(2.0);
}
@@ -146,13 +144,12 @@ static av_cold int imc_decode_init(AVCodecContext * avctx)
/* Generate a square root table */
for(i = 0; i < 30; i++) {
for (i = 0; i < 30; i++)
q->sqrt_tab[i] = sqrt(i);
}
/* initialize the VLC tables */
for(i = 0; i < 4 ; i++) {
for(j = 0; j < 4; j++) {
for (i = 0; i < 4 ; i++) {
for (j = 0; j < 4; j++) {
huffman_vlc[i][j].table = &vlc_tables[vlc_offsets[i * 4 + j]];
huffman_vlc[i][j].table_allocated = vlc_offsets[i * 4 + j + 1] - vlc_offsets[i * 4 + j];
init_vlc(&huffman_vlc[i][j], 9, imc_huffman_sizes[i],
@@ -160,7 +157,7 @@ static av_cold int imc_decode_init(AVCodecContext * avctx)
imc_huffman_bits[i][j], 2, 2, INIT_VLC_USE_NEW_STATIC);
}
}
q->one_div_log2 = 1/log(2);
q->one_div_log2 = 1 / log(2);
if ((ret = ff_fft_init(&q->fft, 7, 1))) {
av_log(avctx, AV_LOG_INFO, "FFT init failed\n");
@@ -176,8 +173,9 @@ static av_cold int imc_decode_init(AVCodecContext * avctx)
return 0;
}
static void imc_calculate_coeffs(IMCContext* q, float* flcoeffs1, float* flcoeffs2, int* bandWidthT,
float* flcoeffs3, float* flcoeffs5)
static void imc_calculate_coeffs(IMCContext *q, float *flcoeffs1,
float *flcoeffs2, int *bandWidthT,
float *flcoeffs3, float *flcoeffs5)
{
float workT1[BANDS];
float workT2[BANDS];
@@ -186,13 +184,13 @@ static void imc_calculate_coeffs(IMCContext* q, float* flcoeffs1, float* flcoeff
float accum = 0.0;
int i, cnt2;
for(i = 0; i < BANDS; i++) {
for (i = 0; i < BANDS; i++) {
flcoeffs5[i] = workT2[i] = 0.0;
if (bandWidthT[i]){
if (bandWidthT[i]) {
workT1[i] = flcoeffs1[i] * flcoeffs1[i];
flcoeffs3[i] = 2.0 * flcoeffs2[i];
} else {
workT1[i] = 0.0;
workT1[i] = 0.0;
flcoeffs3[i] = -30000.0;
}
workT3[i] = bandWidthT[i] * workT1[i] * 0.01;
@@ -200,37 +198,38 @@ static void imc_calculate_coeffs(IMCContext* q, float* flcoeffs1, float* flcoeff
workT3[i] = 0.0;
}
for(i = 0; i < BANDS; i++) {
for(cnt2 = i; cnt2 < cyclTab[i]; cnt2++)
for (i = 0; i < BANDS; i++) {
for (cnt2 = i; cnt2 < cyclTab[i]; cnt2++)
flcoeffs5[cnt2] = flcoeffs5[cnt2] + workT3[i];
workT2[cnt2-1] = workT2[cnt2-1] + workT3[i];
workT2[cnt2 - 1] = workT2[cnt2 - 1] + workT3[i];
}
for(i = 1; i < BANDS; i++) {
accum = (workT2[i-1] + accum) * imc_weights1[i-1];
for (i = 1; i < BANDS; i++) {
accum = (workT2[i - 1] + accum) * imc_weights1[i - 1];
flcoeffs5[i] += accum;
}
for(i = 0; i < BANDS; i++)
for (i = 0; i < BANDS; i++)
workT2[i] = 0.0;
for(i = 0; i < BANDS; i++) {
for(cnt2 = i-1; cnt2 > cyclTab2[i]; cnt2--)
for (i = 0; i < BANDS; i++) {
for (cnt2 = i - 1; cnt2 > cyclTab2[i]; cnt2--)
flcoeffs5[cnt2] += workT3[i];
workT2[cnt2+1] += workT3[i];
}
accum = 0.0;
for(i = BANDS-2; i >= 0; i--) {
for (i = BANDS-2; i >= 0; i--) {
accum = (workT2[i+1] + accum) * imc_weights2[i];
flcoeffs5[i] += accum;
//there is missing code here, but it seems to never be triggered
// there is missing code here, but it seems to never be triggered
}
}
static void imc_read_level_coeffs(IMCContext* q, int stream_format_code, int* levlCoeffs)
static void imc_read_level_coeffs(IMCContext *q, int stream_format_code,
int *levlCoeffs)
{
int i;
VLC *hufftab[4];
@@ -245,41 +244,42 @@ static void imc_read_level_coeffs(IMCContext* q, int stream_format_code, int* le
hufftab[3] = &huffman_vlc[s][3];
cb_sel = imc_cb_select[s];
if(stream_format_code & 4)
if (stream_format_code & 4)
start = 1;
if(start)
if (start)
levlCoeffs[0] = get_bits(&q->gb, 7);
for(i = start; i < BANDS; i++){
levlCoeffs[i] = get_vlc2(&q->gb, hufftab[cb_sel[i]]->table, hufftab[cb_sel[i]]->bits, 2);
if(levlCoeffs[i] == 17)
for (i = start; i < BANDS; i++) {
levlCoeffs[i] = get_vlc2(&q->gb, hufftab[cb_sel[i]]->table,
hufftab[cb_sel[i]]->bits, 2);
if (levlCoeffs[i] == 17)
levlCoeffs[i] += get_bits(&q->gb, 4);
}
}
static void imc_decode_level_coefficients(IMCContext* q, int* levlCoeffBuf, float* flcoeffs1,
float* flcoeffs2)
static void imc_decode_level_coefficients(IMCContext *q, int *levlCoeffBuf,
float *flcoeffs1, float *flcoeffs2)
{
int i, level;
float tmp, tmp2;
//maybe some frequency division thingy
// maybe some frequency division thingy
flcoeffs1[0] = 20000.0 / pow (2, levlCoeffBuf[0] * 0.18945); // 0.18945 = log2(10) * 0.05703125
flcoeffs2[0] = log(flcoeffs1[0])/log(2);
tmp = flcoeffs1[0];
flcoeffs2[0] = log(flcoeffs1[0]) / log(2);
tmp = flcoeffs1[0];
tmp2 = flcoeffs2[0];
for(i = 1; i < BANDS; i++) {
for (i = 1; i < BANDS; i++) {
level = levlCoeffBuf[i];
if (level == 16) {
flcoeffs1[i] = 1.0;
flcoeffs2[i] = 0.0;
} else {
if (level < 17)
level -=7;
level -= 7;
else if (level <= 24)
level -=32;
level -= 32;
else
level -=16;
level -= 16;
tmp *= imc_exp_tab[15 + level];
tmp2 += 0.83048 * level; // 0.83048 = log2(10) * 0.25
@@ -290,17 +290,20 @@ static void imc_decode_level_coefficients(IMCContext* q, int* levlCoeffBuf, floa
}
static void imc_decode_level_coefficients2(IMCContext* q, int* levlCoeffBuf, float* old_floor, float* flcoeffs1,
float* flcoeffs2) {
static void imc_decode_level_coefficients2(IMCContext *q, int *levlCoeffBuf,
float *old_floor, float *flcoeffs1,
float *flcoeffs2)
{
int i;
//FIXME maybe flag_buf = noise coding and flcoeffs1 = new scale factors
// and flcoeffs2 old scale factors
// might be incomplete due to a missing table that is in the binary code
for(i = 0; i < BANDS; i++) {
/* FIXME maybe flag_buf = noise coding and flcoeffs1 = new scale factors
* and flcoeffs2 old scale factors
* might be incomplete due to a missing table that is in the binary code
*/
for (i = 0; i < BANDS; i++) {
flcoeffs1[i] = 0;
if(levlCoeffBuf[i] < 16) {
if (levlCoeffBuf[i] < 16) {
flcoeffs1[i] = imc_exp_tab2[levlCoeffBuf[i]] * old_floor[i];
flcoeffs2[i] = (levlCoeffBuf[i]-7) * 0.83048 + flcoeffs2[i]; // 0.83048 = log2(10) * 0.25
flcoeffs2[i] = (levlCoeffBuf[i] - 7) * 0.83048 + flcoeffs2[i]; // 0.83048 = log2(10) * 0.25
} else {
flcoeffs1[i] = old_floor[i];
}
@@ -310,7 +313,9 @@ static void imc_decode_level_coefficients2(IMCContext* q, int* levlCoeffBuf, flo
/**
* Perform bit allocation depending on bits available
*/
static int bit_allocation (IMCContext* q, int stream_format_code, int freebits, int flag) {
static int bit_allocation(IMCContext *q, int stream_format_code, int freebits,
int flag)
{
int i, j;
const float limit = -1.e20;
float highest = 0.0;
@@ -327,31 +332,30 @@ static int bit_allocation (IMCContext* q, int stream_format_code, int freebits,
int flg;
int found_indx = 0;
for(i = 0; i < BANDS; i++)
for (i = 0; i < BANDS; i++)
highest = FFMAX(highest, q->flcoeffs1[i]);
for(i = 0; i < BANDS-1; i++) {
q->flcoeffs4[i] = q->flcoeffs3[i] - log(q->flcoeffs5[i])/log(2);
}
for (i = 0; i < BANDS - 1; i++)
q->flcoeffs4[i] = q->flcoeffs3[i] - log(q->flcoeffs5[i]) / log(2);
q->flcoeffs4[BANDS - 1] = limit;
highest = highest * 0.25;
for(i = 0; i < BANDS; i++) {
for (i = 0; i < BANDS; i++) {
indx = -1;
if ((band_tab[i+1] - band_tab[i]) == q->bandWidthT[i])
if ((band_tab[i + 1] - band_tab[i]) == q->bandWidthT[i])
indx = 0;
if ((band_tab[i+1] - band_tab[i]) > q->bandWidthT[i])
if ((band_tab[i + 1] - band_tab[i]) > q->bandWidthT[i])
indx = 1;
if (((band_tab[i+1] - band_tab[i])/2) >= q->bandWidthT[i])
if (((band_tab[i + 1] - band_tab[i]) / 2) >= q->bandWidthT[i])
indx = 2;
if (indx == -1)
return AVERROR_INVALIDDATA;
q->flcoeffs4[i] = q->flcoeffs4[i] + xTab[(indx*2 + (q->flcoeffs1[i] < highest)) * 2 + flag];
q->flcoeffs4[i] += xTab[(indx * 2 + (q->flcoeffs1[i] < highest)) * 2 + flag];
}
if (stream_format_code & 0x2) {
@@ -361,22 +365,23 @@ static int bit_allocation (IMCContext* q, int stream_format_code, int freebits,
q->flcoeffs4[3] = limit;
}
for(i = (stream_format_code & 0x2)?4:0; i < BANDS-1; i++) {
iacc += q->bandWidthT[i];
for (i = (stream_format_code & 0x2) ? 4 : 0; i < BANDS - 1; i++) {
iacc += q->bandWidthT[i];
summa += q->bandWidthT[i] * q->flcoeffs4[i];
}
q->bandWidthT[BANDS-1] = 0;
q->bandWidthT[BANDS - 1] = 0;
summa = (summa * 0.5 - freebits) / iacc;
for(i = 0; i < BANDS/2; i++) {
for (i = 0; i < BANDS / 2; i++) {
rres = summer - freebits;
if((rres >= -8) && (rres <= 8)) break;
if ((rres >= -8) && (rres <= 8))
break;
summer = 0;
iacc = 0;
iacc = 0;
for(j = (stream_format_code & 0x2)?4:0; j < BANDS; j++) {
for (j = (stream_format_code & 0x2) ? 4 : 0; j < BANDS; j++) {
cwlen = av_clipf(((q->flcoeffs4[j] * 0.5) - summa + 0.5), 0, 6);
q->bitsBandT[j] = cwlen;
@@ -392,32 +397,33 @@ static int bit_allocation (IMCContext* q, int stream_format_code, int freebits,
t2 = -1;
if (i == 0)
flg = t2;
if(flg != t2)
if (flg != t2)
t1++;
summa = (float)(summer - freebits) / ((t1 + 1) * iacc) + summa;
}
for(i = (stream_format_code & 0x2)?4:0; i < BANDS; i++) {
for(j = band_tab[i]; j < band_tab[i+1]; j++)
for (i = (stream_format_code & 0x2) ? 4 : 0; i < BANDS; i++) {
for (j = band_tab[i]; j < band_tab[i + 1]; j++)
q->CWlengthT[j] = q->bitsBandT[i];
}
if (freebits > summer) {
for(i = 0; i < BANDS; i++) {
workT[i] = (q->bitsBandT[i] == 6) ? -1.e20 : (q->bitsBandT[i] * -2 + q->flcoeffs4[i] - 0.415);
for (i = 0; i < BANDS; i++) {
workT[i] = (q->bitsBandT[i] == 6) ? -1.e20
: (q->bitsBandT[i] * -2 + q->flcoeffs4[i] - 0.415);
}
highest = 0.0;
do{
do {
if (highest <= -1.e20)
break;
found_indx = 0;
highest = -1.e20;
for(i = 0; i < BANDS; i++) {
for (i = 0; i < BANDS; i++) {
if (workT[i] > highest) {
highest = workT[i];
found_indx = i;
@@ -426,19 +432,20 @@ static int bit_allocation (IMCContext* q, int stream_format_code, int freebits,
if (highest > -1.e20) {
workT[found_indx] -= 2.0;
if (++(q->bitsBandT[found_indx]) == 6)
if (++q->bitsBandT[found_indx] == 6)
workT[found_indx] = -1.e20;
for(j = band_tab[found_indx]; j < band_tab[found_indx+1] && (freebits > summer); j++){
for (j = band_tab[found_indx]; j < band_tab[found_indx + 1] && (freebits > summer); j++) {
q->CWlengthT[j]++;
summer++;
}
}
}while (freebits > summer);
} while (freebits > summer);
}
if (freebits < summer) {
for(i = 0; i < BANDS; i++) {
workT[i] = q->bitsBandT[i] ? (q->bitsBandT[i] * -2 + q->flcoeffs4[i] + 1.585) : 1.e20;
for (i = 0; i < BANDS; i++) {
workT[i] = q->bitsBandT[i] ? (q->bitsBandT[i] * -2 + q->flcoeffs4[i] + 1.585)
: 1.e20;
}
if (stream_format_code & 0x2) {
workT[0] = 1.e20;
@@ -446,23 +453,24 @@ static int bit_allocation (IMCContext* q, int stream_format_code, int freebits,
workT[2] = 1.e20;
workT[3] = 1.e20;
}
while (freebits < summer){
lowest = 1.e10;
while (freebits < summer) {
lowest = 1.e10;
low_indx = 0;
for(i = 0; i < BANDS; i++) {
for (i = 0; i < BANDS; i++) {
if (workT[i] < lowest) {
lowest = workT[i];
lowest = workT[i];
low_indx = i;
}
}
//if(lowest >= 1.e10) break;
// if (lowest >= 1.e10)
// break;
workT[low_indx] = lowest + 2.0;
if (!(--q->bitsBandT[low_indx]))
if (!--q->bitsBandT[low_indx])
workT[low_indx] = 1.e20;
for(j = band_tab[low_indx]; j < band_tab[low_indx+1] && (freebits < summer); j++){
if(q->CWlengthT[j] > 0){
for (j = band_tab[low_indx]; j < band_tab[low_indx+1] && (freebits < summer); j++) {
if (q->CWlengthT[j] > 0) {
q->CWlengthT[j]--;
summer--;
}
@@ -472,49 +480,51 @@ static int bit_allocation (IMCContext* q, int stream_format_code, int freebits,
return 0;
}
static void imc_get_skip_coeff(IMCContext* q) {
static void imc_get_skip_coeff(IMCContext *q)
{
int i, j;
memset(q->skipFlagBits, 0, sizeof(q->skipFlagBits));
memset(q->skipFlagBits, 0, sizeof(q->skipFlagBits));
memset(q->skipFlagCount, 0, sizeof(q->skipFlagCount));
for(i = 0; i < BANDS; i++) {
for (i = 0; i < BANDS; i++) {
if (!q->bandFlagsBuf[i] || !q->bandWidthT[i])
continue;
if (!q->skipFlagRaw[i]) {
q->skipFlagBits[i] = band_tab[i+1] - band_tab[i];
q->skipFlagBits[i] = band_tab[i + 1] - band_tab[i];
for(j = band_tab[i]; j < band_tab[i+1]; j++) {
if ((q->skipFlags[j] = get_bits1(&q->gb)))
for (j = band_tab[i]; j < band_tab[i + 1]; j++) {
q->skipFlags[j] = get_bits1(&q->gb);
if (q->skipFlags[j])
q->skipFlagCount[i]++;
}
} else {
for(j = band_tab[i]; j < (band_tab[i+1]-1); j += 2) {
if(!get_bits1(&q->gb)){//0
for (j = band_tab[i]; j < band_tab[i + 1] - 1; j += 2) {
if (!get_bits1(&q->gb)) { // 0
q->skipFlagBits[i]++;
q->skipFlags[j]=1;
q->skipFlags[j+1]=1;
q->skipFlags[j] = 1;
q->skipFlags[j + 1] = 1;
q->skipFlagCount[i] += 2;
}else{
if(get_bits1(&q->gb)){//11
q->skipFlagBits[i] +=2;
q->skipFlags[j]=0;
q->skipFlags[j+1]=1;
} else {
if (get_bits1(&q->gb)) { // 11
q->skipFlagBits[i] += 2;
q->skipFlags[j] = 0;
q->skipFlags[j + 1] = 1;
q->skipFlagCount[i]++;
}else{
q->skipFlagBits[i] +=3;
q->skipFlags[j+1]=0;
if(!get_bits1(&q->gb)){//100
q->skipFlags[j]=1;
} else {
q->skipFlagBits[i] += 3;
q->skipFlags[j + 1] = 0;
if (!get_bits1(&q->gb)) { // 100
q->skipFlags[j] = 1;
q->skipFlagCount[i]++;
}else{//101
q->skipFlags[j]=0;
} else { // 101
q->skipFlags[j] = 0;
}
}
}
}
if (j < band_tab[i+1]) {
if (j < band_tab[i + 1]) {
q->skipFlagBits[i]++;
if ((q->skipFlags[j] = get_bits1(&q->gb)))
q->skipFlagCount[i]++;
@@ -526,24 +536,26 @@ static void imc_get_skip_coeff(IMCContext* q) {
/**
* Increase highest' band coefficient sizes as some bits won't be used
*/
static void imc_adjust_bit_allocation (IMCContext* q, int summer) {
static void imc_adjust_bit_allocation(IMCContext *q, int summer)
{
float workT[32];
int corrected = 0;
int i, j;
float highest = 0;
int found_indx=0;
float highest = 0;
int found_indx = 0;
for(i = 0; i < BANDS; i++) {
workT[i] = (q->bitsBandT[i] == 6) ? -1.e20 : (q->bitsBandT[i] * -2 + q->flcoeffs4[i] - 0.415);
for (i = 0; i < BANDS; i++) {
workT[i] = (q->bitsBandT[i] == 6) ? -1.e20
: (q->bitsBandT[i] * -2 + q->flcoeffs4[i] - 0.415);
}
while (corrected < summer) {
if(highest <= -1.e20)
if (highest <= -1.e20)
break;
highest = -1.e20;
for(i = 0; i < BANDS; i++) {
for (i = 0; i < BANDS; i++) {
if (workT[i] > highest) {
highest = workT[i];
found_indx = i;
@@ -555,7 +567,7 @@ static void imc_adjust_bit_allocation (IMCContext* q, int summer) {
if (++(q->bitsBandT[found_indx]) == 6)
workT[found_indx] = -1.e20;
for(j = band_tab[found_indx]; j < band_tab[found_indx+1] && (corrected < summer); j++) {
for (j = band_tab[found_indx]; j < band_tab[found_indx+1] && (corrected < summer); j++) {
if (!q->skipFlags[j] && (q->CWlengthT[j] < 6)) {
q->CWlengthT[j]++;
corrected++;
@@ -565,61 +577,65 @@ static void imc_adjust_bit_allocation (IMCContext* q, int summer) {
}
}
static void imc_imdct256(IMCContext *q) {
static void imc_imdct256(IMCContext *q)
{
int i;
float re, im;
/* prerotation */
for(i=0; i < COEFFS/2; i++){
q->samples[i].re = -(q->pre_coef1[i] * q->CWdecoded[COEFFS-1-i*2]) -
(q->pre_coef2[i] * q->CWdecoded[i*2]);
q->samples[i].im = (q->pre_coef2[i] * q->CWdecoded[COEFFS-1-i*2]) -
(q->pre_coef1[i] * q->CWdecoded[i*2]);
for (i = 0; i < COEFFS / 2; i++) {
q->samples[i].re = -(q->pre_coef1[i] * q->CWdecoded[COEFFS - 1 - i * 2]) -
(q->pre_coef2[i] * q->CWdecoded[i * 2]);
q->samples[i].im = (q->pre_coef2[i] * q->CWdecoded[COEFFS - 1 - i * 2]) -
(q->pre_coef1[i] * q->CWdecoded[i * 2]);
}
/* FFT */
q->fft.fft_permute(&q->fft, q->samples);
q->fft.fft_calc (&q->fft, q->samples);
q->fft.fft_calc(&q->fft, q->samples);
/* postrotation, window and reorder */
for(i = 0; i < COEFFS/2; i++){
re = (q->samples[i].re * q->post_cos[i]) + (-q->samples[i].im * q->post_sin[i]);
im = (-q->samples[i].im * q->post_cos[i]) - (q->samples[i].re * q->post_sin[i]);
q->out_samples[i*2] = (q->mdct_sine_window[COEFFS-1-i*2] * q->last_fft_im[i]) + (q->mdct_sine_window[i*2] * re);
q->out_samples[COEFFS-1-i*2] = (q->mdct_sine_window[i*2] * q->last_fft_im[i]) - (q->mdct_sine_window[COEFFS-1-i*2] * re);
for (i = 0; i < COEFFS / 2; i++) {
re = ( q->samples[i].re * q->post_cos[i]) + (-q->samples[i].im * q->post_sin[i]);
im = (-q->samples[i].im * q->post_cos[i]) - ( q->samples[i].re * q->post_sin[i]);
q->out_samples[i * 2] = (q->mdct_sine_window[COEFFS - 1 - i * 2] * q->last_fft_im[i])
+ (q->mdct_sine_window[i * 2] * re);
q->out_samples[COEFFS - 1 - i * 2] = (q->mdct_sine_window[i * 2] * q->last_fft_im[i])
- (q->mdct_sine_window[COEFFS - 1 - i * 2] * re);
q->last_fft_im[i] = im;
}
}
static int inverse_quant_coeff (IMCContext* q, int stream_format_code) {
static int inverse_quant_coeff(IMCContext *q, int stream_format_code)
{
int i, j;
int middle_value, cw_len, max_size;
const float* quantizer;
const float *quantizer;
for(i = 0; i < BANDS; i++) {
for(j = band_tab[i]; j < band_tab[i+1]; j++) {
for (i = 0; i < BANDS; i++) {
for (j = band_tab[i]; j < band_tab[i + 1]; j++) {
q->CWdecoded[j] = 0;
cw_len = q->CWlengthT[j];
if (cw_len <= 0 || q->skipFlags[j])
continue;
max_size = 1 << cw_len;
max_size = 1 << cw_len;
middle_value = max_size >> 1;
if (q->codewords[j] >= max_size || q->codewords[j] < 0)
return AVERROR_INVALIDDATA;
if (cw_len >= 4){
if (cw_len >= 4) {
quantizer = imc_quantizer2[(stream_format_code & 2) >> 1];
if (q->codewords[j] >= middle_value)
q->CWdecoded[j] = quantizer[q->codewords[j] - 8] * q->flcoeffs6[i];
q->CWdecoded[j] = quantizer[q->codewords[j] - 8] * q->flcoeffs6[i];
else
q->CWdecoded[j] = -quantizer[max_size - q->codewords[j] - 8 - 1] * q->flcoeffs6[i];
}else{
quantizer = imc_quantizer1[((stream_format_code & 2) >> 1) | (q->bandFlagsBuf[i] << 1)];
if (q->codewords[j] >= middle_value)
q->CWdecoded[j] = quantizer[q->codewords[j] - 1] * q->flcoeffs6[i];
q->CWdecoded[j] = quantizer[q->codewords[j] - 1] * q->flcoeffs6[i];
else
q->CWdecoded[j] = -quantizer[max_size - 2 - q->codewords[j]] * q->flcoeffs6[i];
}
@@ -629,22 +645,24 @@ static int inverse_quant_coeff (IMCContext* q, int stream_format_code) {
}
static int imc_get_coeffs (IMCContext* q) {
static int imc_get_coeffs(IMCContext *q)
{
int i, j, cw_len, cw;
for(i = 0; i < BANDS; i++) {
if(!q->sumLenArr[i]) continue;
for (i = 0; i < BANDS; i++) {
if (!q->sumLenArr[i])
continue;
if (q->bandFlagsBuf[i] || q->bandWidthT[i]) {
for(j = band_tab[i]; j < band_tab[i+1]; j++) {
for (j = band_tab[i]; j < band_tab[i + 1]; j++) {
cw_len = q->CWlengthT[j];
cw = 0;
if (get_bits_count(&q->gb) + cw_len > 512){
//av_log(NULL,0,"Band %i coeff %i cw_len %i\n",i,j,cw_len);
if (get_bits_count(&q->gb) + cw_len > 512) {
// av_log(NULL, 0, "Band %i coeff %i cw_len %i\n", i, j, cw_len);
return AVERROR_INVALIDDATA;
}
if(cw_len && (!q->bandFlagsBuf[i] || !q->skipFlags[j]))
if (cw_len && (!q->bandFlagsBuf[i] || !q->skipFlags[j]))
cw = get_bits(&q->gb, cw_len);
q->codewords[j] = cw;
@@ -654,7 +672,7 @@ static int imc_get_coeffs (IMCContext* q) {
return 0;
}
static int imc_decode_frame(AVCodecContext * avctx, void *data,
static int imc_decode_frame(AVCodecContext *avctx, void *data,
int *got_frame_ptr, AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
@@ -680,7 +698,7 @@ static int imc_decode_frame(AVCodecContext * avctx, void *data,
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return ret;
}
q->out_samples = (float *)q->frame.data[0];
q->out_samples = (float*)q->frame.data[0];
q->dsp.bswap16_buf(buf16, (const uint16_t*)buf, IMC_BLOCK_SIZE / 2);
@@ -695,7 +713,7 @@ static int imc_decode_frame(AVCodecContext * avctx, void *data,
}
stream_format_code = get_bits(&q->gb, 3);
if(stream_format_code & 1){
if (stream_format_code & 1) {
av_log(avctx, AV_LOG_ERROR, "Stream code format %X is not supported\n", stream_format_code);
return AVERROR_INVALIDDATA;
}
@@ -705,10 +723,12 @@ static int imc_decode_frame(AVCodecContext * avctx, void *data,
if (stream_format_code & 0x04)
q->decoder_reset = 1;
if(q->decoder_reset) {
if (q->decoder_reset) {
memset(q->out_samples, 0, sizeof(q->out_samples));
for(i = 0; i < BANDS; i++)q->old_floor[i] = 1.0;
for(i = 0; i < COEFFS; i++)q->CWdecoded[i] = 0;
for (i = 0; i < BANDS; i++)
q->old_floor[i] = 1.0;
for (i = 0; i < COEFFS; i++)
q->CWdecoded[i] = 0;
q->decoder_reset = 0;
}
@@ -716,22 +736,24 @@ static int imc_decode_frame(AVCodecContext * avctx, void *data,
imc_read_level_coeffs(q, stream_format_code, q->levlCoeffBuf);
if (stream_format_code & 0x4)
imc_decode_level_coefficients(q, q->levlCoeffBuf, q->flcoeffs1, q->flcoeffs2);
imc_decode_level_coefficients(q, q->levlCoeffBuf,
q->flcoeffs1, q->flcoeffs2);
else
imc_decode_level_coefficients2(q, q->levlCoeffBuf, q->old_floor, q->flcoeffs1, q->flcoeffs2);
imc_decode_level_coefficients2(q, q->levlCoeffBuf, q->old_floor,
q->flcoeffs1, q->flcoeffs2);
memcpy(q->old_floor, q->flcoeffs1, 32 * sizeof(float));
counter = 0;
for (i=0 ; i<BANDS ; i++) {
for (i = 0; i < BANDS; i++) {
if (q->levlCoeffBuf[i] == 16) {
q->bandWidthT[i] = 0;
counter++;
} else
q->bandWidthT[i] = band_tab[i+1] - band_tab[i];
q->bandWidthT[i] = band_tab[i + 1] - band_tab[i];
}
memset(q->bandFlagsBuf, 0, BANDS * sizeof(int));
for(i = 0; i < BANDS-1; i++) {
for (i = 0; i < BANDS - 1; i++) {
if (q->bandWidthT[i])
q->bandFlagsBuf[i] = get_bits1(&q->gb);
}
@@ -747,78 +769,79 @@ static int imc_decode_frame(AVCodecContext * avctx, void *data,
q->CWlengthT[0] = 5;
q->CWlengthT[1] = 5;
q->CWlengthT[2] = 5;
for(i = 1; i < 4; i++){
for (i = 1; i < 4; i++) {
bits = (q->levlCoeffBuf[i] == 16) ? 0 : 5;
q->bitsBandT[i] = bits;
for(j = band_tab[i]; j < band_tab[i+1]; j++) {
for (j = band_tab[i]; j < band_tab[i + 1]; j++) {
q->CWlengthT[j] = bits;
bitscount += bits;
bitscount += bits;
}
}
}
if((ret = bit_allocation (q, stream_format_code,
512 - bitscount - get_bits_count(&q->gb), flag)) < 0) {
if ((ret = bit_allocation(q, stream_format_code,
512 - bitscount - get_bits_count(&q->gb),
flag)) < 0) {
av_log(avctx, AV_LOG_ERROR, "Bit allocations failed\n");
q->decoder_reset = 1;
return ret;
}
for(i = 0; i < BANDS; i++) {
q->sumLenArr[i] = 0;
for (i = 0; i < BANDS; i++) {
q->sumLenArr[i] = 0;
q->skipFlagRaw[i] = 0;
for(j = band_tab[i]; j < band_tab[i+1]; j++)
for (j = band_tab[i]; j < band_tab[i + 1]; j++)
q->sumLenArr[i] += q->CWlengthT[j];
if (q->bandFlagsBuf[i])
if( (((band_tab[i+1] - band_tab[i]) * 1.5) > q->sumLenArr[i]) && (q->sumLenArr[i] > 0))
if ((((band_tab[i + 1] - band_tab[i]) * 1.5) > q->sumLenArr[i]) && (q->sumLenArr[i] > 0))
q->skipFlagRaw[i] = 1;
}
imc_get_skip_coeff(q);
for(i = 0; i < BANDS; i++) {
for (i = 0; i < BANDS; i++) {
q->flcoeffs6[i] = q->flcoeffs1[i];
/* band has flag set and at least one coded coefficient */
if (q->bandFlagsBuf[i] && (band_tab[i+1] - band_tab[i]) != q->skipFlagCount[i]){
q->flcoeffs6[i] *= q->sqrt_tab[band_tab[i+1] - band_tab[i]] /
q->sqrt_tab[(band_tab[i+1] - band_tab[i] - q->skipFlagCount[i])];
if (q->bandFlagsBuf[i] && (band_tab[i + 1] - band_tab[i]) != q->skipFlagCount[i]) {
q->flcoeffs6[i] *= q->sqrt_tab[ band_tab[i + 1] - band_tab[i]] /
q->sqrt_tab[(band_tab[i + 1] - band_tab[i] - q->skipFlagCount[i])];
}
}
/* calculate bits left, bits needed and adjust bit allocation */
bits = summer = 0;
for(i = 0; i < BANDS; i++) {
for (i = 0; i < BANDS; i++) {
if (q->bandFlagsBuf[i]) {
for(j = band_tab[i]; j < band_tab[i+1]; j++) {
if(q->skipFlags[j]) {
for (j = band_tab[i]; j < band_tab[i + 1]; j++) {
if (q->skipFlags[j]) {
summer += q->CWlengthT[j];
q->CWlengthT[j] = 0;
}
}
bits += q->skipFlagBits[i];
bits += q->skipFlagBits[i];
summer -= q->skipFlagBits[i];
}
}
imc_adjust_bit_allocation(q, summer);
for(i = 0; i < BANDS; i++) {
for (i = 0; i < BANDS; i++) {
q->sumLenArr[i] = 0;
for(j = band_tab[i]; j < band_tab[i+1]; j++)
for (j = band_tab[i]; j < band_tab[i + 1]; j++)
if (!q->skipFlags[j])
q->sumLenArr[i] += q->CWlengthT[j];
}
memset(q->codewords, 0, sizeof(q->codewords));
if(imc_get_coeffs(q) < 0) {
if (imc_get_coeffs(q) < 0) {
av_log(avctx, AV_LOG_ERROR, "Read coefficients failed\n");
q->decoder_reset = 1;
return AVERROR_INVALIDDATA;
}
if(inverse_quant_coeff(q, stream_format_code) < 0) {
if (inverse_quant_coeff(q, stream_format_code) < 0) {
av_log(avctx, AV_LOG_ERROR, "Inverse quantization of coefficients failed\n");
q->decoder_reset = 1;
return AVERROR_INVALIDDATA;
-4
View File
@@ -199,10 +199,6 @@ static int decode_gop_header(IVI45DecContext *ctx, AVCodecContext *avctx)
}
if (band->blk_size == 8) {
if(quant_mat >= 5){
av_log(avctx, AV_LOG_ERROR, "quant_mat %d too large!\n", quant_mat);
return -1;
}
band->intra_base = &ivi5_base_quant_8x8_intra[quant_mat][0];
band->inter_base = &ivi5_base_quant_8x8_inter[quant_mat][0];
band->intra_scale = &ivi5_scale_quant_8x8_intra[quant_mat][0];
+1 -1
View File
@@ -77,7 +77,7 @@ int ff_intel_h263_decode_picture_header(MpegEncContext *s)
}
if(get_bits(&s->gb, 2))
av_log(s->avctx, AV_LOG_ERROR, "Bad value for reserved field\n");
s->loop_filter = get_bits1(&s->gb) * !s->avctx->lowres;
s->loop_filter = get_bits1(&s->gb);
if(get_bits1(&s->gb))
av_log(s->avctx, AV_LOG_ERROR, "Bad value for reserved field\n");
if(get_bits1(&s->gb))
-2
View File
@@ -963,8 +963,6 @@ int ff_h263_decode_picture_header(MpegEncContext *s)
s->h263_aic = get_bits1(&s->gb); /* Advanced Intra Coding (AIC) */
s->loop_filter= get_bits1(&s->gb);
s->unrestricted_mv = s->umvplus || s->obmc || s->loop_filter;
if(s->avctx->lowres)
s->loop_filter = 0;
s->h263_slice_structured= get_bits1(&s->gb);
if (get_bits1(&s->gb) != 0) {
-4
View File
@@ -143,10 +143,6 @@ static int decode_frame(AVCodecContext *avctx,
buf += 5;
if (video_size) {
if(video_size < 0) {
av_log(avctx, AV_LOG_ERROR, "video size %d invalid\n", video_size);
return AVERROR_INVALIDDATA;
}
if (avctx->reget_buffer(avctx, &s->frame) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return -1;
+1 -2
View File
@@ -304,8 +304,7 @@ AVCodec ff_libmp3lame_encoder = {
AV_SAMPLE_FMT_NONE },
.supported_samplerates = libmp3lame_sample_rates,
.channel_layouts = (const uint64_t[]) { AV_CH_LAYOUT_MONO,
AV_CH_LAYOUT_STEREO,
0},
AV_CH_LAYOUT_STEREO },
.long_name = NULL_IF_CONFIG_SMALL("libmp3lame MP3 (MPEG audio layer 3)"),
.priv_class = &libmp3lame_class,
.defaults = libmp3lame_defaults,
+1 -1
View File
@@ -231,7 +231,7 @@ static av_cold int mace_decode_init(AVCodecContext * avctx)
{
MACEContext *ctx = avctx->priv_data;
if (avctx->channels > 2 || avctx->channels <= 0)
if (avctx->channels > 2)
return -1;
avctx->sample_fmt = AV_SAMPLE_FMT_S16;
-5
View File
@@ -55,11 +55,6 @@ static av_cold int mp_decode_init(AVCodecContext *avctx)
int w4 = (avctx->width + 3) & ~3;
int h4 = (avctx->height + 3) & ~3;
if(avctx->extradata_size < 2){
av_log(avctx, AV_LOG_ERROR, "extradata too small\n");
return AVERROR_INVALIDDATA;
}
motionpixels_tableinit();
mp->avctx = avctx;
ff_dsputil_init(&mp->dsp, avctx);
+1 -3
View File
@@ -228,7 +228,7 @@ static int mpc7_decode_frame(AVCodecContext * avctx, void *data,
buf_size -= 4;
/* get output buffer */
c->frame.nb_samples = MPC_FRAME_SIZE;
c->frame.nb_samples = last_frame ? c->lastframelen : MPC_FRAME_SIZE;
if ((ret = avctx->get_buffer(avctx, &c->frame)) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return ret;
@@ -298,8 +298,6 @@ static int mpc7_decode_frame(AVCodecContext * avctx, void *data,
idx_to_quant(c, &gb, bands[i].res[ch], c->Q[ch] + off);
ff_mpc_dequantize_and_synth(c, mb, c->frame.data[0], 2);
if(last_frame)
c->frame.nb_samples = c->lastframelen;
bits_used = get_bits_count(&gb);
bits_avail = buf_size * 8;
+3 -5
View File
@@ -140,8 +140,7 @@ static av_cold int mpc8_decode_init(AVCodecContext * avctx)
c->frames = 1 << (get_bits(&gb, 3) * 2);
avctx->sample_fmt = AV_SAMPLE_FMT_S16;
avctx->channel_layout = (channels==2) ? AV_CH_LAYOUT_STEREO : AV_CH_LAYOUT_MONO;
avctx->channels = channels;
avctx->channel_layout = (avctx->channels==2) ? AV_CH_LAYOUT_STEREO : AV_CH_LAYOUT_MONO;
if(vlc_initialized) return 0;
av_log(avctx, AV_LOG_DEBUG, "Initing VLC\n");
@@ -275,7 +274,7 @@ static int mpc8_decode_frame(AVCodecContext * avctx, void *data,
maxband = c->last_max_band + get_vlc2(gb, band_vlc.table, MPC8_BANDS_BITS, 2);
if(maxband > 32) maxband -= 33;
}
if(maxband > c->maxbands + 1) {
if(maxband >= BANDS) {
av_log(avctx, AV_LOG_ERROR, "maxband %d too large\n",maxband);
return AVERROR_INVALIDDATA;
}
@@ -412,8 +411,7 @@ static int mpc8_decode_frame(AVCodecContext * avctx, void *data,
}
}
ff_mpc_dequantize_and_synth(c, maxband - 1, c->frame.data[0],
avctx->channels);
ff_mpc_dequantize_and_synth(c, maxband, c->frame.data[0], avctx->channels);
c->cur_frame++;
-4
View File
@@ -2050,10 +2050,6 @@ static int decode_vop_header(MpegEncContext *s, GetBitContext *gb){
if(s->pict_type == AV_PICTURE_TYPE_B)
skip_bits_long(gb, s->cplx_estimation_trash_b);
if(get_bits_left(gb) < 3) {
av_log(s->avctx, AV_LOG_ERROR, "Header truncated\n");
return -1;
}
s->intra_dc_threshold= ff_mpeg4_dc_threshold[ get_bits(gb, 3) ];
if(!s->progressive_sequence){
s->top_field_first= get_bits1(gb);
-1
View File
@@ -53,7 +53,6 @@ static int mpegaudio_parse(AVCodecParserContext *s1,
int inc= FFMIN(buf_size - i, s->frame_size);
i += inc;
s->frame_size -= inc;
state = 0;
if(!s->frame_size){
next= i;
+2 -2
View File
@@ -1436,7 +1436,7 @@ static void draw_line(uint8_t *buf, int sx, int sy, int ex, int ey,
y = (x * f) >> 16;
fr = (x * f) & 0xFFFF;
buf[y * stride + x] += (color * (0x10000 - fr)) >> 16;
if(fr) buf[(y + 1) * stride + x] += (color * fr ) >> 16;
buf[(y + 1) * stride + x] += (color * fr ) >> 16;
}
} else {
if (sy > ey) {
@@ -1453,7 +1453,7 @@ static void draw_line(uint8_t *buf, int sx, int sy, int ex, int ey,
x = (y*f) >> 16;
fr = (y*f) & 0xFFFF;
buf[y * stride + x] += (color * (0x10000 - fr)) >> 16;
if(fr) buf[y * stride + x + 1] += (color * fr ) >> 16;
buf[y * stride + x + 1] += (color * fr ) >> 16;
}
}
}
-2
View File
@@ -45,8 +45,6 @@ static int png_parse(AVCodecParserContext *s, AVCodecContext *avctx,
int next = END_NOT_FOUND;
int i = 0;
s->pict_type = AV_PICTURE_TYPE_NONE;
*poutbuf_size = 0;
if (buf_size == 0)
return 0;
+4 -4
View File
@@ -29,7 +29,7 @@
#define CLIP_AND_BIAS(x) (av_clip((x) + BIAS, CLIP_MIN, CLIP_MAX))
#if CONFIG_PRORES_DECODER | CONFIG_PRORES_LGPL_DECODER
#if CONFIG_PRORES_DECODER
/**
* Add bias value, clamp and output pixels of a slice
*/
@@ -53,7 +53,7 @@ static void prores_idct_put_c(uint16_t *out, int linesize, DCTELEM *block, const
}
#endif
#if CONFIG_PRORES_KOSTYA_ENCODER
#if CONFIG_PRORES_ENCODER
static void prores_fdct_c(const uint16_t *src, int linesize, DCTELEM *block)
{
int x, y;
@@ -70,7 +70,7 @@ static void prores_fdct_c(const uint16_t *src, int linesize, DCTELEM *block)
void ff_proresdsp_init(ProresDSPContext *dsp, AVCodecContext *avctx)
{
#if CONFIG_PRORES_DECODER | CONFIG_PRORES_LGPL_DECODER
#if CONFIG_PRORES_DECODER
dsp->idct_put = prores_idct_put_c;
dsp->idct_permutation_type = FF_NO_IDCT_PERM;
@@ -79,7 +79,7 @@ void ff_proresdsp_init(ProresDSPContext *dsp, AVCodecContext *avctx)
ff_init_scantable_permutation(dsp->idct_permutation,
dsp->idct_permutation_type);
#endif
#if CONFIG_PRORES_KOSTYA_ENCODER
#if CONFIG_PRORES_ENCODER
dsp->fdct = prores_fdct_c;
dsp->dct_permutation_type = FF_NO_IDCT_PERM;
ff_init_scantable_permutation(dsp->dct_permutation,
+2 -8
View File
@@ -79,7 +79,6 @@ typedef struct ThreadContext {
pthread_cond_t current_job_cond;
pthread_mutex_t current_job_lock;
int current_job;
unsigned int current_execute;
int done;
} ThreadContext;
@@ -204,7 +203,6 @@ static void* attribute_align_arg worker(void *v)
AVCodecContext *avctx = v;
ThreadContext *c = avctx->thread_opaque;
int our_job = c->job_count;
int last_execute = 0;
int thread_count = avctx->thread_count;
int self_id;
@@ -215,9 +213,7 @@ static void* attribute_align_arg worker(void *v)
if (c->current_job == thread_count + c->job_count)
pthread_cond_signal(&c->last_job_cond);
while (last_execute == c->current_execute && !c->done)
pthread_cond_wait(&c->current_job_cond, &c->current_job_lock);
last_execute = c->current_execute;
pthread_cond_wait(&c->current_job_cond, &c->current_job_lock);
our_job = self_id;
if (c->done) {
@@ -237,8 +233,7 @@ static void* attribute_align_arg worker(void *v)
static av_always_inline void avcodec_thread_park_workers(ThreadContext *c, int thread_count)
{
while (c->current_job != thread_count + c->job_count)
pthread_cond_wait(&c->last_job_cond, &c->current_job_lock);
pthread_cond_wait(&c->last_job_cond, &c->current_job_lock);
pthread_mutex_unlock(&c->current_job_lock);
}
@@ -287,7 +282,6 @@ static int avcodec_thread_execute(AVCodecContext *avctx, action_func* func, void
c->rets = &dummy_ret;
c->rets_count = 1;
}
c->current_execute++;
pthread_cond_broadcast(&c->current_job_cond);
avcodec_thread_park_workers(c, avctx->thread_count);
+1 -2
View File
@@ -1363,8 +1363,7 @@ static void qdm2_fft_decode_tones (QDM2Context *q, int duration, GetBitContext *
if (q->superblocktype_2_3) {
while ((n = qdm2_get_vlc(gb, &vlc_tab_fft_tone_offset[local_int_8], 1, 2)) < 2) {
if (get_bits_left(gb)<0) {
if(local_int_4 < q->group_size)
av_log(0, AV_LOG_ERROR, "overread in qdm2_fft_decode_tones()\n");
av_log(0, AV_LOG_ERROR, "overread in qdm2_fft_decode_tones()\n");
return;
}
offset = 1;
+1 -2
View File
@@ -41,8 +41,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size,
int h, w;
AVFrame *pic = avctx->coded_frame;
const uint32_t *src = (const uint32_t *)avpkt->data;
int aligned_width = FFALIGN(avctx->width,
avctx->codec_id == CODEC_ID_R10K ? 1 : 64);
int aligned_width = FFALIGN(avctx->width, 64);
uint8_t *dst_line;
if (pic->data[0])
+1 -2
View File
@@ -38,8 +38,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
const AVFrame *pic, int *got_packet)
{
int i, j, ret;
int aligned_width = FFALIGN(avctx->width,
avctx->codec_id == CODEC_ID_R10K ? 1 : 64);
int aligned_width = FFALIGN(avctx->width, 64);
int pad = (aligned_width - avctx->width) * 4;
uint8_t *src_line;
uint8_t *dst;
+1 -1
View File
@@ -349,7 +349,7 @@ static int rv20_decode_picture_header(RVDecContext *rv)
}
if(RV_GET_MINOR_VER(rv->sub_id) >= 2)
s->loop_filter = get_bits1(&s->gb) && !s->avctx->lowres;
s->loop_filter = get_bits1(&s->gb);
if(RV_GET_MINOR_VER(rv->sub_id) <= 1)
seq = get_bits(&s->gb, 8) << 7;
-5
View File
@@ -36,11 +36,6 @@ static av_cold int encode_init(AVCodecContext *avctx)
{
SgiContext *s = avctx->priv_data;
if (avctx->width > 65535 || avctx->height > 65535) {
av_log(avctx, AV_LOG_ERROR, "SGI does not support resolutions above 65535x65535\n");
return -1;
}
avcodec_get_frame_defaults(&s->picture);
avctx->coded_frame = &s->picture;
+1 -1
View File
@@ -72,7 +72,7 @@ static int sp5x_decode_frame(AVCodecContext *avctx,
for (i = 2; i < buf_size-2 && j < buf_size+1024-2; i++)
recoded[j++] = buf[i];
else
for (i = 14; i < buf_size && j < buf_size+1024-3; i++)
for (i = 14; i < buf_size && j < buf_size+1024-2; i++)
{
recoded[j++] = buf[i];
if (buf[i] == 0xff)
-16
View File
@@ -512,10 +512,6 @@ hres,vres,i,i%vres (0 < i < 4)
}
#define APPLY_C_PREDICTOR() \
if(index > 1023){\
av_log(s->avctx, AV_LOG_ERROR, " index %d went out of bounds\n", index); \
return; \
}\
predictor_pair = s->c_predictor_table[index]; \
horiz_pred += (predictor_pair >> 1); \
if (predictor_pair & 1) { \
@@ -533,10 +529,6 @@ hres,vres,i,i%vres (0 < i < 4)
index++;
#define APPLY_C_PREDICTOR_24() \
if(index > 1023){\
av_log(s->avctx, AV_LOG_ERROR, " index %d went out of bounds\n", index); \
return; \
}\
predictor_pair = s->c_predictor_table[index]; \
horiz_pred += (predictor_pair >> 1); \
if (predictor_pair & 1) { \
@@ -555,10 +547,6 @@ hres,vres,i,i%vres (0 < i < 4)
#define APPLY_Y_PREDICTOR() \
if(index > 1023){\
av_log(s->avctx, AV_LOG_ERROR, " index %d went out of bounds\n", index); \
return; \
}\
predictor_pair = s->y_predictor_table[index]; \
horiz_pred += (predictor_pair >> 1); \
if (predictor_pair & 1) { \
@@ -576,10 +564,6 @@ hres,vres,i,i%vres (0 < i < 4)
index++;
#define APPLY_Y_PREDICTOR_24() \
if(index > 1023){\
av_log(s->avctx, AV_LOG_ERROR, " index %d went out of bounds\n", index); \
return; \
}\
predictor_pair = s->y_predictor_table[index]; \
horiz_pred += (predictor_pair >> 1); \
if (predictor_pair & 1) { \
+1 -5
View File
@@ -789,7 +789,7 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, AVCodec *codec, AVD
if (codec->capabilities & CODEC_CAP_EXPERIMENTAL)
if (avctx->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL) {
av_log(avctx, AV_LOG_ERROR, "Codec is experimental but experimental codecs are not enabled, try -strict -2\n");
av_log(avctx, AV_LOG_ERROR, "Codec is experimental but experimental codecs are not enabled, see -strict -2\n");
ret = -1;
goto free_and_end;
}
@@ -2194,12 +2194,8 @@ int av_get_audio_frame_duration(AVCodecContext *avctx, int frame_bytes)
/* calc from frame_bytes, channels, and bits_per_coded_sample */
switch (avctx->codec_id) {
case CODEC_ID_PCM_DVD:
if(bps<4)
return 0;
return 2 * (frame_bytes / ((bps * 2 / 8) * ch));
case CODEC_ID_PCM_BLURAY:
if(bps<4)
return 0;
return frame_bytes / ((FFALIGN(ch, 2) * bps) / 8);
case CODEC_ID_S302M:
return 2 * (frame_bytes / ((bps + 4) / 4)) / ch;
+2
View File
@@ -85,6 +85,8 @@ static int encode_init(AVCodecContext * avctx){
(avctx->sample_rate * 8);
s->block_align = FFMIN(s->block_align, MAX_CODED_SUPERFRAME_SIZE);
avctx->block_align = s->block_align;
avctx->bit_rate = avctx->block_align * 8LL * avctx->sample_rate /
s->frame_len;
//av_log(NULL, AV_LOG_ERROR, "%d %d %d %d\n", s->block_align, avctx->bit_rate, s->frame_len, avctx->sample_rate);
avctx->frame_size = avctx->delay = s->frame_len;
-5
View File
@@ -70,11 +70,6 @@ static int decode_frame(AVCodecContext *avctx,
int prev_y = 0, prev_u = 0, prev_v = 0;
uint8_t *rbuf;
if(buf_size<=8) {
av_log(avctx, AV_LOG_ERROR, "buf_size %d is too small\n", buf_size);
return AVERROR_INVALIDDATA;
}
rbuf = av_malloc(buf_size + FF_INPUT_BUFFER_PADDING_SIZE);
if(!rbuf){
av_log(avctx, AV_LOG_ERROR, "Cannot allocate temporary buffer\n");
-4
View File
@@ -517,10 +517,6 @@ static int xan_decode_frame(AVCodecContext *avctx,
int i;
tag = bytestream_get_le32(&buf);
size = bytestream_get_be32(&buf);
if(size < 0) {
av_log(avctx, AV_LOG_ERROR, "Invalid tag size %d\n", size);
return AVERROR_INVALIDDATA;
}
size = FFMIN(size, buf_end - buf);
switch (tag) {
case PALT_TAG:
-14
View File
@@ -89,11 +89,6 @@ static av_cold int yop_decode_init(AVCodecContext *avctx)
return -1;
}
if (!avctx->extradata) {
av_log(avctx, AV_LOG_ERROR, "extradata missing\n");
return AVERROR_INVALIDDATA;
}
avctx->pix_fmt = PIX_FMT_PAL8;
avcodec_get_frame_defaults(&s->frame);
@@ -204,11 +199,6 @@ static int yop_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
if (s->frame.data[0])
avctx->release_buffer(avctx, &s->frame);
if (avpkt->size < 4 + 3*s->num_pal_colors) {
av_log(avctx, AV_LOG_ERROR, "packet of size %d too small\n", avpkt->size);
return AVERROR_INVALIDDATA;
}
ret = avctx->get_buffer(avctx, &s->frame);
if (ret < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
@@ -224,10 +214,6 @@ static int yop_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
s->low_nibble = NULL;
is_odd_frame = avpkt->data[0];
if(is_odd_frame>1){
av_log(avctx, AV_LOG_ERROR, "frame is too odd %d\n", is_odd_frame);
return AVERROR_INVALIDDATA;
}
firstcolor = s->first_color[is_odd_frame];
palette = (uint32_t *)s->frame.data[1];
+24 -23
View File
@@ -37,7 +37,6 @@ typedef struct {
double ratio;
struct SwrContext *swr;
int64_t next_pts;
int req_fullfilled;
} AResampleContext;
static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque)
@@ -174,21 +173,6 @@ static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamplesref
AVFilterLink *const outlink = inlink->dst->outputs[0];
AVFilterBufferRef *outsamplesref = ff_get_audio_buffer(outlink, AV_PERM_WRITE, n_out);
avfilter_copy_buffer_ref_props(outsamplesref, insamplesref);
outsamplesref->format = outlink->format;
outsamplesref->audio->channel_layout = outlink->channel_layout;
outsamplesref->audio->sample_rate = outlink->sample_rate;
if(insamplesref->pts != AV_NOPTS_VALUE) {
int64_t inpts = av_rescale(insamplesref->pts, inlink->time_base.num * (int64_t)outlink->sample_rate * inlink->sample_rate, inlink->time_base.den);
int64_t outpts= swr_next_pts(aresample->swr, inpts);
aresample->next_pts =
outsamplesref->pts = (outpts + inlink->sample_rate/2) / inlink->sample_rate;
} else {
outsamplesref->pts = AV_NOPTS_VALUE;
}
n_out = swr_convert(aresample->swr, outsamplesref->extended_data, n_out,
(void *)insamplesref->extended_data, n_in);
if (n_out <= 0) {
@@ -197,11 +181,33 @@ static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamplesref
return;
}
avfilter_copy_buffer_ref_props(outsamplesref, insamplesref);
outsamplesref->audio->sample_rate = outlink->sample_rate;
outsamplesref->audio->nb_samples = n_out;
#if 0
if(insamplesref->pts != AV_NOPTS_VALUE) {
aresample->next_pts =
outsamplesref->pts = av_rescale_q(insamplesref->pts, inlink->time_base, outlink->time_base)
- swr_get_delay(aresample->swr, outlink->time_base.den);
av_assert0(outlink->time_base.num == 1);
} else{
outsamplesref->pts = AV_NOPTS_VALUE; //aresample->next_pts;
}
if(aresample->next_pts != AV_NOPTS_VALUE)
aresample->next_pts += av_rescale_q(n_out, (AVRational){1 ,outlink->sample_rate}, outlink->time_base);
#else
if(insamplesref->pts != AV_NOPTS_VALUE) {
int64_t inpts = av_rescale(insamplesref->pts, inlink->time_base.num * (int64_t)outlink->sample_rate * inlink->sample_rate, inlink->time_base.den);
int64_t outpts= swr_next_pts(aresample->swr, inpts);
aresample->next_pts =
outsamplesref->pts = (outpts + inlink->sample_rate/2) / inlink->sample_rate;
} else {
outsamplesref->pts = AV_NOPTS_VALUE;
}
#endif
ff_filter_samples(outlink, outsamplesref);
aresample->req_fullfilled= 1;
avfilter_unref_buffer(insamplesref);
}
@@ -210,12 +216,7 @@ static int request_frame(AVFilterLink *outlink)
AVFilterContext *ctx = outlink->src;
AResampleContext *aresample = ctx->priv;
AVFilterLink *const inlink = outlink->src->inputs[0];
int ret;
aresample->req_fullfilled = 0;
do{
ret = avfilter_request_frame(ctx->inputs[0]);
}while(!aresample->req_fullfilled && ret>=0);
int ret = avfilter_request_frame(ctx->inputs[0]);
if (ret == AVERROR_EOF) {
AVFilterBufferRef *outsamplesref;
+1 -1
View File
@@ -204,7 +204,7 @@ void ff_filter_samples(AVFilterLink *link, AVFilterBufferRef *samplesref)
link->cur_buf->audio->sample_rate = samplesref->audio->sample_rate;
/* Copy actual data into new samples buffer */
for (i = 0; i < 8 && samplesref->data[i]; i++)
for (i = 0; samplesref->data[i] && i < 8; i++)
memcpy(link->cur_buf->data[i], samplesref->data[i], samplesref->linesize[0]);
for (i = 0; i < planes; i++)
memcpy(link->cur_buf->extended_data[i], samplesref->extended_data[i], samplesref->linesize[0]);
+5 -8
View File
@@ -59,13 +59,10 @@ int avfilter_fill_frame_from_audio_buffer_ref(AVFrame *frame,
return AVERROR(EINVAL);
memcpy(frame->data, samplesref->data, sizeof(frame->data));
memcpy(frame->linesize, samplesref->linesize, sizeof(frame->linesize));
av_frame_set_pkt_pos(frame, samplesref->pos);
frame->format = samplesref->format;
frame->nb_samples = samplesref->audio->nb_samples;
frame->pts = samplesref->pts;
frame->sample_rate = samplesref->audio->sample_rate;
frame->channel_layout = samplesref->audio->channel_layout;
frame->pkt_pos = samplesref->pos;
frame->format = samplesref->format;
frame->nb_samples = samplesref->audio->nb_samples;
frame->pts = samplesref->pts;
return 0;
}
@@ -78,7 +75,7 @@ int avfilter_fill_frame_from_video_buffer_ref(AVFrame *frame,
memcpy(frame->data, picref->data, sizeof(frame->data));
memcpy(frame->linesize, picref->linesize, sizeof(frame->linesize));
av_frame_set_pkt_pos(frame, picref->pos);
frame->pkt_pos = picref->pos;
frame->interlaced_frame = picref->video->interlaced;
frame->top_field_first = picref->video->top_field_first;
frame->key_frame = picref->video->key_frame;
+1 -1
View File
@@ -166,7 +166,7 @@ void avfilter_unref_bufferp(AVFilterBufferRef **ref)
int avfilter_copy_frame_props(AVFilterBufferRef *dst, const AVFrame *src)
{
dst->pts = src->pts;
dst->pos = av_frame_get_pkt_pos(src);
dst->pos = src->pkt_pos;
dst->format = src->format;
switch (dst->type) {
-5
View File
@@ -200,11 +200,6 @@ static int fourxm_read_header(AVFormatContext *s)
ret = AVERROR_INVALIDDATA;
goto fail;
}
if(!fourxm->tracks[current_track].adpcm && fourxm->tracks[current_track].bits<8){
av_log(s, AV_LOG_ERROR, "bits unspecified for non ADPCM\n");
ret = AVERROR_INVALIDDATA;
goto fail;
}
i += 8 + size;
/* allocate a new AVStream */
+1 -1
View File
@@ -163,7 +163,7 @@ OBJS-$(CONFIG_MOV_DEMUXER) += mov.o isom.o mov_chan.o
OBJS-$(CONFIG_MOV_MUXER) += movenc.o isom.o avc.o \
movenchint.o rtpenc_chain.o \
mov_chan.o
OBJS-$(CONFIG_MP2_MUXER) += mp3enc.o rawenc.o id3v2enc.o
OBJS-$(CONFIG_MP2_MUXER) += mp3enc.o rawenc.o
OBJS-$(CONFIG_MP3_DEMUXER) += mp3dec.o
OBJS-$(CONFIG_MP3_MUXER) += mp3enc.o rawenc.o id3v2enc.o
OBJS-$(CONFIG_MPC_DEMUXER) += mpc.o apetag.o
-2
View File
@@ -37,8 +37,6 @@ static int ac3_eac3_probe(AVProbeData *p, enum CodecID expected_codec_id)
end = buf + p->buf_size;
for(; buf < end; buf++) {
if(buf > p->buf && (buf[0] != 0x0B || buf[1] != 0x77) )
continue;
buf2 = buf;
for(frames = 0; buf2 < end; frames++) {
-3
View File
@@ -278,9 +278,6 @@ static int ape_read_header(AVFormatContext * s)
return AVERROR(ENOMEM);
for (i = 0; i < ape->seektablelength / sizeof(uint32_t); i++)
ape->seektable[i] = avio_rl32(pb);
}else{
av_log(s, AV_LOG_ERROR, "Missing seektable\n");
return -1;
}
ape->frames[0].pos = ape->firstframe;
+2 -4
View File
@@ -578,7 +578,6 @@ static int avi_read_header(AVFormatContext *s)
avio_skip(pb, size);
} else {
uint64_t cur_pos = avio_tell(pb);
unsigned esize;
if (cur_pos < list_end)
size = FFMIN(size, list_end - cur_pos);
st = s->streams[stream_index];
@@ -592,7 +591,7 @@ static int avi_read_header(AVFormatContext *s)
avio_skip(pb, size);
break;
}
tag1 = ff_get_bmp_header(pb, st, &esize);
tag1 = ff_get_bmp_header(pb, st);
if (tag1 == MKTAG('D', 'X', 'S', 'B') || tag1 == MKTAG('D','X','S','A')) {
st->codec->codec_type = AVMEDIA_TYPE_SUBTITLE;
@@ -602,8 +601,7 @@ static int avi_read_header(AVFormatContext *s)
}
if(size > 10*4 && size<(1<<30) && size < avi->fsize){
if(esize == size-1 && (esize&1)) st->codec->extradata_size= esize - 10*4;
else st->codec->extradata_size= size - 10*4;
st->codec->extradata_size= size - 10*4;
st->codec->extradata= av_malloc(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
if (!st->codec->extradata) {
st->codec->extradata_size= 0;
+2 -5
View File
@@ -255,12 +255,9 @@ static int avi_write_header(AVFormatContext *s)
ff_parse_specific_params(stream, &au_byterate, &au_ssize, &au_scale);
avpriv_set_pts_info(s->streams[i], 64, au_scale, au_byterate);
if(stream->codec_id == CODEC_ID_XSUB)
au_scale = au_byterate = 0;
avio_wl32(pb, au_scale); /* scale */
avio_wl32(pb, au_byterate); /* rate */
avpriv_set_pts_info(s->streams[i], 64, au_scale, au_byterate);
avio_wl32(pb, 0); /* start */
avist->frames_hdr_strm = avio_tell(pb); /* remember this offset to fill later */
@@ -524,7 +521,7 @@ static int avi_write_packet(AVFormatContext *s, AVPacket *pkt)
int size= pkt->size;
// av_log(s, AV_LOG_DEBUG, "%"PRId64" %d %d\n", pkt->dts, avist->packet_count, stream_index);
while(enc->block_align==0 && pkt->dts != AV_NOPTS_VALUE && pkt->dts > avist->packet_count && enc->codec_id != CODEC_ID_XSUB){
while(enc->block_align==0 && pkt->dts != AV_NOPTS_VALUE && pkt->dts > avist->packet_count){
AVPacket empty_packet;
if(pkt->dts - avist->packet_count > 60000){
+2 -2
View File
@@ -55,7 +55,7 @@ static int avisynth_read_header(AVFormatContext *s)
res = AVIFileOpen(&avs->file, s->filename, OF_READ|OF_SHARE_DENY_WRITE, NULL);
if (res != S_OK)
{
av_log(s, AV_LOG_ERROR, "AVIFileOpen failed with error %ld\n", res);
av_log(s, AV_LOG_ERROR, "AVIFileOpen failed with error %ld", res);
AVIFileExit();
return -1;
}
@@ -63,7 +63,7 @@ static int avisynth_read_header(AVFormatContext *s)
res = AVIFileInfo(avs->file, &info, sizeof(info));
if (res != S_OK)
{
av_log(s, AV_LOG_ERROR, "AVIFileInfo failed with error %ld\n", res);
av_log(s, AV_LOG_ERROR, "AVIFileInfo failed with error %ld", res);
AVIFileExit();
return -1;
}
+3
View File
@@ -273,6 +273,9 @@ static int dv_extract_video_info(DVDemuxContext *c, uint8_t* frame)
avpriv_set_pts_info(c->vst, 64, c->sys->time_base.num,
c->sys->time_base.den);
avctx->time_base= c->sys->time_base;
if (!avctx->width)
avcodec_set_dimensions(avctx, c->sys->width, c->sys->height);
avctx->pix_fmt = c->sys->pix_fmt;
/* finding out SAR is a little bit messy */
vsc_pack = dv_extract_pack(frame, dv_video_control);
+1 -2
View File
@@ -529,9 +529,8 @@ static int ipmovie_probe(AVProbeData *p)
uint8_t *b = p->buf;
uint8_t *b_end = p->buf + p->buf_size - sizeof(signature);
do {
if (b[0] == signature[0] && memcmp(b, signature, sizeof(signature)) == 0)
if (memcmp(b++, signature, sizeof(signature)) == 0)
return AVPROBE_SCORE_MAX;
b++;
} while (b < b_end);
return 0;
+2 -5
View File
@@ -63,13 +63,10 @@ static int jacosub_probe(AVProbeData *p)
ptr += 3; /* skip UTF-8 BOM */
while (ptr < ptr_end) {
if (timed_line(ptr))
return AVPROBE_SCORE_MAX / 2;
while (jss_whitespace(*ptr))
ptr++;
if (*ptr != '#' && *ptr != '\n') {
if (timed_line(ptr))
return AVPROBE_SCORE_MAX/2 + 1;
return 0;
}
ptr += strcspn(ptr, "\n") + 1;
}
return 0;
+1 -1
View File
@@ -1874,7 +1874,7 @@ static void mov_build_index(MOVContext *mov, AVStream *st)
sc->empty_duration = av_rescale(sc->empty_duration, sc->time_scale, mov->time_scale);
sc->time_offset = sc->start_time - sc->empty_duration;
current_dts = -sc->time_offset;
if (sc->ctts_count>0 && sc->stts_count>0 &&
if (sc->ctts_data && sc->stts_data &&
sc->ctts_data[0].duration / FFMAX(sc->stts_data[0].duration, 1) > 16) {
/* more than 16 frames delay, dts are likely wrong
this happens with files created by iMovie */
+1 -1
View File
@@ -680,7 +680,7 @@ static int mov_write_audio_tag(AVIOContext *pb, MOVTrack *track)
track->enc->codec_id == CODEC_ID_ALAC ||
track->enc->codec_id == CODEC_ID_ADPCM_MS ||
track->enc->codec_id == CODEC_ID_ADPCM_IMA_WAV ||
mov_pcm_le_gt16(track->enc->codec_id)))
(mov_pcm_le_gt16(track->enc->codec_id) && version==1)))
mov_write_wave_tag(pb, track);
else if(track->tag == MKTAG('m','p','4','a'))
mov_write_esds_tag(pb, track);
+6 -18
View File
@@ -336,13 +336,6 @@ static int ogg_read_page(AVFormatContext *s, int *str)
return 0;
}
/**
* @brief find the next Ogg packet
* @param *str is set to the stream for the packet or -1 if there is
* no matching stream, in that case assume all other return
* values to be uninitialized.
* @return negative value on error or EOF.
*/
static int ogg_packet(AVFormatContext *s, int *str, int *dstart, int *dsize,
int64_t *fpos)
{
@@ -353,8 +346,6 @@ static int ogg_packet(AVFormatContext *s, int *str, int *dstart, int *dsize,
int segp = 0, psize = 0;
av_dlog(s, "ogg_packet: curidx=%i\n", ogg->curidx);
if (str)
*str = -1;
do{
idx = ogg->curidx;
@@ -533,18 +524,15 @@ static int ogg_get_length(AVFormatContext *s)
ogg_save (s);
avio_seek (s->pb, s->data_offset, SEEK_SET);
ogg_reset(s);
while (streams_left > 0 && !ogg_packet(s, &i, NULL, NULL, NULL)) {
int64_t pts;
if (i < 0) continue;
pts = ogg_calc_pts(s, i, NULL);
while (!ogg_packet(s, &i, NULL, NULL, NULL)) {
int64_t pts = ogg_calc_pts(s, i, NULL);
if (pts != AV_NOPTS_VALUE && s->streams[i]->start_time == AV_NOPTS_VALUE && !ogg->streams[i].got_start){
s->streams[i]->duration -= pts;
ogg->streams[i].got_start= 1;
streams_left--;
}else if(s->streams[i]->start_time != AV_NOPTS_VALUE && !ogg->streams[i].got_start){
ogg->streams[i].got_start= 1;
streams_left--;
}
if(streams_left<=0)
break;
}
ogg_restore (s, 0);
@@ -619,7 +607,7 @@ static int ogg_read_packet(AVFormatContext *s, AVPacket *pkt)
{
struct ogg *ogg;
struct ogg_stream *os;
int idx, ret;
int idx = -1, ret;
int pstart, psize;
int64_t fpos, pts, dts;
@@ -678,7 +666,7 @@ static int64_t ogg_read_timestamp(AVFormatContext *s, int stream_index,
AVIOContext *bc = s->pb;
int64_t pts = AV_NOPTS_VALUE;
int64_t keypos = -1;
int i;
int i = -1;
int pstart, psize;
avio_seek(bc, *pos_arg, SEEK_SET);
ogg_reset(s);
+2 -2
View File
@@ -203,12 +203,12 @@ vorbis_header (AVFormatContext * s, int idx)
int pkt_type = os->buf[os->pstart];
if (!(pkt_type & 1))
return os->private ? 0 : -1;
return 0;
if (!os->private) {
os->private = av_mallocz(sizeof(struct oggvorbis_private));
if (!os->private)
return -1;
return 0;
}
if (os->psize < 1 || pkt_type > 5)
+2 -3
View File
@@ -652,11 +652,10 @@ enum CodecID ff_wav_codec_get_id(unsigned int tag, int bps)
return id;
}
int ff_get_bmp_header(AVIOContext *pb, AVStream *st, unsigned *esize)
int ff_get_bmp_header(AVIOContext *pb, AVStream *st)
{
int tag1;
if(esize) *esize = avio_rl32(pb);
else avio_rl32(pb);
avio_rl32(pb); /* size */
st->codec->width = avio_rl32(pb);
st->codec->height = (int32_t)avio_rl32(pb);
avio_rl16(pb); /* planes */
+1 -1
View File
@@ -44,7 +44,7 @@ void ff_end_tag(AVIOContext *pb, int64_t start);
* bits_per_encoded_sample fields. Does not read extradata.
* @return codec tag
*/
int ff_get_bmp_header(AVIOContext *pb, AVStream *st, unsigned *esize);
int ff_get_bmp_header(AVIOContext *pb, AVStream *st);
void ff_put_bmp_header(AVIOContext *pb, AVCodecContext *enc, const AVCodecTag *tags, int for_asf);
int ff_put_wav_header(AVIOContext *pb, AVCodecContext *enc);
+11 -4
View File
@@ -151,7 +151,10 @@ int ff_rtmp_packet_read(URLContext *h, RTMPPacket *p,
offset += chunk_size;
size += chunk_size;
if (data_size > 0) {
ffurl_read_complete(h, &t, 1); //marker
if ((ret = ffurl_read_complete(h, &t, 1)) < 0) { // marker
ff_rtmp_packet_destroy(p);
return ret;
}
size++;
if (t != (0xC0 + channel_id))
return -1;
@@ -167,6 +170,7 @@ int ff_rtmp_packet_write(URLContext *h, RTMPPacket *pkt,
int mode = RTMP_PS_TWELVEBYTES;
int off = 0;
int size = 0;
int ret;
pkt->ts_delta = pkt->timestamp - prev_pkt[pkt->channel_id].timestamp;
@@ -218,15 +222,18 @@ int ff_rtmp_packet_write(URLContext *h, RTMPPacket *pkt,
}
prev_pkt[pkt->channel_id].extra = pkt->extra;
ffurl_write(h, pkt_hdr, p-pkt_hdr);
if ((ret = ffurl_write(h, pkt_hdr, p - pkt_hdr)) < 0)
return ret;
size = p - pkt_hdr + pkt->data_size;
while (off < pkt->data_size) {
int towrite = FFMIN(chunk_size, pkt->data_size - off);
ffurl_write(h, pkt->data + off, towrite);
if ((ret = ffurl_write(h, pkt->data + off, towrite)) < 0)
return ret;
off += towrite;
if (off < pkt->data_size) {
uint8_t marker = 0xC0 | pkt->channel_id;
ffurl_write(h, &marker, 1);
if ((ret = ffurl_write(h, &marker, 1)) < 0)
return ret;
size++;
}
}
+65 -35
View File
@@ -167,10 +167,11 @@ static int gen_connect(URLContext *s, RTMPContext *rt)
pkt.data_size = p - pkt.data;
ff_rtmp_packet_write(rt->stream, &pkt, rt->chunk_size, rt->prev_pkt[1]);
ret = ff_rtmp_packet_write(rt->stream, &pkt, rt->chunk_size,
rt->prev_pkt[1]);
ff_rtmp_packet_destroy(&pkt);
return 0;
return ret;
}
/**
@@ -194,10 +195,11 @@ static int gen_release_stream(URLContext *s, RTMPContext *rt)
ff_amf_write_null(&p);
ff_amf_write_string(&p, rt->playpath);
ff_rtmp_packet_write(rt->stream, &pkt, rt->chunk_size, rt->prev_pkt[1]);
ret = ff_rtmp_packet_write(rt->stream, &pkt, rt->chunk_size,
rt->prev_pkt[1]);
ff_rtmp_packet_destroy(&pkt);
return 0;
return ret;
}
/**
@@ -221,10 +223,11 @@ static int gen_fcpublish_stream(URLContext *s, RTMPContext *rt)
ff_amf_write_null(&p);
ff_amf_write_string(&p, rt->playpath);
ff_rtmp_packet_write(rt->stream, &pkt, rt->chunk_size, rt->prev_pkt[1]);
ret = ff_rtmp_packet_write(rt->stream, &pkt, rt->chunk_size,
rt->prev_pkt[1]);
ff_rtmp_packet_destroy(&pkt);
return 0;
return ret;
}
/**
@@ -248,10 +251,11 @@ static int gen_fcunpublish_stream(URLContext *s, RTMPContext *rt)
ff_amf_write_null(&p);
ff_amf_write_string(&p, rt->playpath);
ff_rtmp_packet_write(rt->stream, &pkt, rt->chunk_size, rt->prev_pkt[1]);
ret = ff_rtmp_packet_write(rt->stream, &pkt, rt->chunk_size,
rt->prev_pkt[1]);
ff_rtmp_packet_destroy(&pkt);
return 0;
return ret;
}
/**
@@ -276,10 +280,11 @@ static int gen_create_stream(URLContext *s, RTMPContext *rt)
ff_amf_write_null(&p);
rt->create_stream_invoke = rt->nb_invokes;
ff_rtmp_packet_write(rt->stream, &pkt, rt->chunk_size, rt->prev_pkt[1]);
ret = ff_rtmp_packet_write(rt->stream, &pkt, rt->chunk_size,
rt->prev_pkt[1]);
ff_rtmp_packet_destroy(&pkt);
return 0;
return ret;
}
@@ -305,10 +310,11 @@ static int gen_delete_stream(URLContext *s, RTMPContext *rt)
ff_amf_write_null(&p);
ff_amf_write_number(&p, rt->main_channel_id);
ff_rtmp_packet_write(rt->stream, &pkt, rt->chunk_size, rt->prev_pkt[1]);
ret = ff_rtmp_packet_write(rt->stream, &pkt, rt->chunk_size,
rt->prev_pkt[1]);
ff_rtmp_packet_destroy(&pkt);
return 0;
return ret;
}
/**
@@ -336,9 +342,13 @@ static int gen_play(URLContext *s, RTMPContext *rt)
ff_amf_write_string(&p, rt->playpath);
ff_amf_write_number(&p, rt->live);
ff_rtmp_packet_write(rt->stream, &pkt, rt->chunk_size, rt->prev_pkt[1]);
ret = ff_rtmp_packet_write(rt->stream, &pkt, rt->chunk_size,
rt->prev_pkt[1]);
ff_rtmp_packet_destroy(&pkt);
if (ret < 0)
return ret;
// set client buffer time disguised in ping packet
if ((ret = ff_rtmp_packet_create(&pkt, RTMP_NETWORK_CHANNEL, RTMP_PT_PING,
1, 10)) < 0)
@@ -349,10 +359,11 @@ static int gen_play(URLContext *s, RTMPContext *rt)
bytestream_put_be32(&p, 1);
bytestream_put_be32(&p, 256); //TODO: what is a good value here?
ff_rtmp_packet_write(rt->stream, &pkt, rt->chunk_size, rt->prev_pkt[1]);
ret = ff_rtmp_packet_write(rt->stream, &pkt, rt->chunk_size,
rt->prev_pkt[1]);
ff_rtmp_packet_destroy(&pkt);
return 0;
return ret;
}
/**
@@ -379,7 +390,8 @@ static int gen_publish(URLContext *s, RTMPContext *rt)
ff_amf_write_string(&p, rt->playpath);
ff_amf_write_string(&p, "live");
ff_rtmp_packet_write(rt->stream, &pkt, rt->chunk_size, rt->prev_pkt[1]);
ret = ff_rtmp_packet_write(rt->stream, &pkt, rt->chunk_size,
rt->prev_pkt[1]);
ff_rtmp_packet_destroy(&pkt);
return ret;
@@ -401,10 +413,11 @@ static int gen_pong(URLContext *s, RTMPContext *rt, RTMPPacket *ppkt)
p = pkt.data;
bytestream_put_be16(&p, 7);
bytestream_put_be32(&p, AV_RB32(ppkt->data+2));
ff_rtmp_packet_write(rt->stream, &pkt, rt->chunk_size, rt->prev_pkt[1]);
ret = ff_rtmp_packet_write(rt->stream, &pkt, rt->chunk_size,
rt->prev_pkt[1]);
ff_rtmp_packet_destroy(&pkt);
return 0;
return ret;
}
/**
@@ -422,10 +435,11 @@ static int gen_server_bw(URLContext *s, RTMPContext *rt)
p = pkt.data;
bytestream_put_be32(&p, 2500000);
ff_rtmp_packet_write(rt->stream, &pkt, rt->chunk_size, rt->prev_pkt[1]);
ret = ff_rtmp_packet_write(rt->stream, &pkt, rt->chunk_size,
rt->prev_pkt[1]);
ff_rtmp_packet_destroy(&pkt);
return 0;
return ret;
}
/**
@@ -446,7 +460,8 @@ static int gen_check_bw(URLContext *s, RTMPContext *rt)
ff_amf_write_number(&p, ++rt->nb_invokes);
ff_amf_write_null(&p);
ff_rtmp_packet_write(rt->stream, &pkt, rt->chunk_size, rt->prev_pkt[1]);
ret = ff_rtmp_packet_write(rt->stream, &pkt, rt->chunk_size,
rt->prev_pkt[1]);
ff_rtmp_packet_destroy(&pkt);
return ret;
@@ -467,10 +482,11 @@ static int gen_bytes_read(URLContext *s, RTMPContext *rt, uint32_t ts)
p = pkt.data;
bytestream_put_be32(&p, rt->bytes_read);
ff_rtmp_packet_write(rt->stream, &pkt, rt->chunk_size, rt->prev_pkt[1]);
ret = ff_rtmp_packet_write(rt->stream, &pkt, rt->chunk_size,
rt->prev_pkt[1]);
ff_rtmp_packet_destroy(&pkt);
return 0;
return ret;
}
//TODO: Move HMAC code somewhere. Eventually.
@@ -617,16 +633,22 @@ static int rtmp_handshake(URLContext *s, RTMPContext *rt)
if (client_pos < 0)
return client_pos;
ffurl_write(rt->stream, tosend, RTMP_HANDSHAKE_PACKET_SIZE + 1);
i = ffurl_read_complete(rt->stream, serverdata, RTMP_HANDSHAKE_PACKET_SIZE + 1);
if (i != RTMP_HANDSHAKE_PACKET_SIZE + 1) {
av_log(s, AV_LOG_ERROR, "Cannot read RTMP handshake response\n");
return AVERROR(EIO);
if ((ret = ffurl_write(rt->stream, tosend,
RTMP_HANDSHAKE_PACKET_SIZE + 1)) < 0) {
av_log(s, AV_LOG_ERROR, "Cannot write RTMP handshake request\n");
return ret;
}
i = ffurl_read_complete(rt->stream, clientdata, RTMP_HANDSHAKE_PACKET_SIZE);
if (i != RTMP_HANDSHAKE_PACKET_SIZE) {
if ((ret = ffurl_read_complete(rt->stream, serverdata,
RTMP_HANDSHAKE_PACKET_SIZE + 1)) < 0) {
av_log(s, AV_LOG_ERROR, "Cannot read RTMP handshake response\n");
return AVERROR(EIO);
return ret;
}
if ((ret = ffurl_read_complete(rt->stream, clientdata,
RTMP_HANDSHAKE_PACKET_SIZE)) < 0) {
av_log(s, AV_LOG_ERROR, "Cannot read RTMP handshake response\n");
return ret;
}
av_log(s, AV_LOG_DEBUG, "Server version %d.%d.%d.%d\n",
@@ -678,9 +700,13 @@ static int rtmp_handshake(URLContext *s, RTMPContext *rt)
return ret;
// write reply back to the server
ffurl_write(rt->stream, tosend, RTMP_HANDSHAKE_PACKET_SIZE);
if ((ret = ffurl_write(rt->stream, tosend,
RTMP_HANDSHAKE_PACKET_SIZE)) < 0)
return ret;
} else {
ffurl_write(rt->stream, serverdata+1, RTMP_HANDSHAKE_PACKET_SIZE);
if ((ret = ffurl_write(rt->stream, serverdata + 1,
RTMP_HANDSHAKE_PACKET_SIZE)) < 0)
return ret;
}
return 0;
@@ -710,7 +736,9 @@ static int rtmp_parse_result(URLContext *s, RTMPContext *rt, RTMPPacket *pkt)
return -1;
}
if (!rt->is_input)
ff_rtmp_packet_write(rt->stream, pkt, rt->chunk_size, rt->prev_pkt[1]);
if ((ret = ff_rtmp_packet_write(rt->stream, pkt, rt->chunk_size,
rt->prev_pkt[1])) < 0)
return ret;
rt->chunk_size = AV_RB32(pkt->data);
if (rt->chunk_size <= 0) {
av_log(s, AV_LOG_ERROR, "Incorrect chunk size %d\n", rt->chunk_size);
@@ -1201,7 +1229,9 @@ static int rtmp_write(URLContext *s, const uint8_t *buf, int size)
if (rt->flv_off == rt->flv_size) {
rt->skip_bytes = 4;
ff_rtmp_packet_write(rt->stream, &rt->out_pkt, rt->chunk_size, rt->prev_pkt[1]);
if ((ret = ff_rtmp_packet_write(rt->stream, &rt->out_pkt,
rt->chunk_size, rt->prev_pkt[1])) < 0)
return ret;
ff_rtmp_packet_destroy(&rt->out_pkt);
rt->flv_size = 0;
rt->flv_off = 0;
-2
View File
@@ -494,10 +494,8 @@ static int swf_write_trailer(AVFormatContext *s)
avio_wl32(pb, file_size);
avio_seek(pb, swf->duration_pos, SEEK_SET);
avio_wl16(pb, swf->video_frame_number);
if (swf->vframes_pos) {
avio_seek(pb, swf->vframes_pos, SEEK_SET);
avio_wl16(pb, swf->video_frame_number);
}
avio_seek(pb, file_size, SEEK_SET);
}
return 0;
-3
View File
@@ -1207,9 +1207,6 @@ static int parse_packet(AVFormatContext *s, AVPacket *pkt, int stream_index)
st->parser->pict_type == AV_PICTURE_TYPE_I))
out_pkt.flags |= AV_PKT_FLAG_KEY;
if(st->parser->key_frame == -1 && st->parser->pict_type==AV_PICTURE_TYPE_NONE && (pkt->flags&AV_PKT_FLAG_KEY))
out_pkt.flags |= AV_PKT_FLAG_KEY;
compute_pkt_fields(s, st, st->parser, &out_pkt);
if ((s->iformat->flags & AVFMT_GENERIC_INDEX) &&
+1 -1
View File
@@ -522,7 +522,7 @@ static int parse_videoinfoheader2(AVFormatContext *s, AVStream *st)
AVIOContext *pb = wtv->pb;
avio_skip(pb, 72); // picture aspect ratio is unreliable
ff_get_bmp_header(pb, st, NULL);
ff_get_bmp_header(pb, st);
return 72 + 40;
}
+1 -2
View File
@@ -75,7 +75,6 @@ static av_always_inline av_const int16_t av_clip_int16_arm(int a)
return x;
}
#if !CONFIG_SMALL //the code below cannot be compiled without always_inline
#define av_clip_uintp2 av_clip_uintp2_arm
static av_always_inline av_const unsigned av_clip_uintp2_arm(int a, int p)
{
@@ -83,7 +82,7 @@ static av_always_inline av_const unsigned av_clip_uintp2_arm(int a, int p)
__asm__ ("usat %0, %2, %1" : "=r"(x) : "r"(a), "i"(p));
return x;
}
#endif //!CONFIG_SMALL
#else /* HAVE_ARMV6 */
+2 -2
View File
@@ -82,8 +82,8 @@ uninstall-libs::
-$(RM) "$(SHLIBDIR)/$(SLIBNAME_WITH_MAJOR)" \
"$(SHLIBDIR)/$(SLIBNAME)" \
"$(SHLIBDIR)/$(SLIBNAME_WITH_VERSION)"
-$(RM) $(SLIB_INSTALL_EXTRA_SHLIB:%="$(SHLIBDIR)/%")
-$(RM) $(SLIB_INSTALL_EXTRA_LIB:%="$(LIBDIR)/%")
-$(RM) $(SLIB_INSTALL_EXTRA_SHLIB:%="$(SHLIBDIR)"%)
-$(RM) $(SLIB_INSTALL_EXTRA_LIB:%="$(LIBDIR)"%)
-$(RM) "$(LIBDIR)/$(LIBNAME)"
uninstall-headers::
+1 -1
View File
@@ -7,4 +7,4 @@ HEADERS = swresample.h
OBJS = swresample.o audioconvert.o resample.o rematrix.o dither.o
TESTPROGS = swresample
TESTPROGS = swresample_test
-1
View File
@@ -629,7 +629,6 @@ int swr_convert(struct SwrContext *s, uint8_t *out_arg[SWR_CH_MAX], int out_coun
av_freep(&tmp.data);
if(s->drop_output || !out_arg)
return 0;
in_count = 0;
}
if(!in_arg){
@@ -243,7 +243,7 @@ int main(int argc, char **argv){
struct SwrContext *backw_ctx= NULL;
if (argc > 1) {
if (!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help")) {
if (!strcmp(argv[1], "-h")) {
av_log(NULL, AV_LOG_INFO, "Usage: swresample-test [<num_tests>[ <test>]] \n"
"num_tests Default is %d\n", num_tests);
return 0;
+1 -1
View File
@@ -351,7 +351,7 @@ do_video_decoding "" "-sws_flags neighbor+bitexact -pix_fmt yuv420p"
fi
if [ -n "$do_avui" ] ; then
do_video_encoding avui.mov "-s pal -an -c:v avui -strict experimental -sws_flags neighbor+bitexact"
do_video_encoding avui.mov "-s pal -an -c:v avui -sws_flags neighbor+bitexact"
do_video_decoding "" "-s cif -sws_flags neighbor+bitexact -pix_fmt yuv420p"
fi
+1 -1
View File
@@ -97,7 +97,7 @@ fate-dxa-scummvm: CMD = framecrc -i $(SAMPLES)/dxa/scummvm.dxa -pix_fmt rgb24
FATE_VIDEO += $(FATE_DXA)
fate-dxa: $(FATE_DXA)
FATE_SAMPLES_PCM += fate-film-cvid
FATE_PCM += fate-film-cvid
fate-film-cvid: CMD = framecrc -i $(SAMPLES)/film/logo-capcom.cpk -an
FATE_FLIC += fate-flic-af11-palette-change
+3 -10
View File
@@ -49,19 +49,12 @@ static void probe(AVProbeData *pd, int type, int p, int size)
}
}
int main(int argc, char **argv)
int main(void)
{
unsigned int p, i, type, size, retry;
AVProbeData pd;
AVLFG state;
PutBitContext pb;
int retry_count= 4097;
int max_size = 65537;
if(argc >= 2)
retry_count = atoi(argv[1]);
if(argc >= 3)
max_size = atoi(argv[2]);
avcodec_register_all();
av_register_all();
@@ -69,14 +62,14 @@ int main(int argc, char **argv)
av_lfg_init(&state, 0xdeadbeef);
pd.buf = NULL;
for (size = 1; size < max_size; size *= 2) {
for (size = 1; size < 65537; size *= 2) {
pd.buf_size = size;
pd.buf = av_realloc(pd.buf, size + AVPROBE_PADDING_SIZE);
pd.filename = "";
fprintf(stderr, "testing size=%d\n", size);
for (retry = 0; retry < retry_count; retry += FFMAX(size, 32)) {
for (retry = 0; retry < 4097; retry += FFMAX(size, 32)) {
for (type = 0; type < 4; type++) {
for (p = 0; p < 4096; p++) {
unsigned hist = 0;