summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile17
-rwxr-xr-xconfigure6
-rw-r--r--libavcodec/imc.c7
-rw-r--r--libavcodec/nuv.c173
-rw-r--r--libavcodec/rtjpeg.h3
-rw-r--r--libavformat/utils.c2
-rw-r--r--tests/fate/filter.mak9
7 files changed, 122 insertions, 95 deletions
diff --git a/Makefile b/Makefile
index 96b7f91354..e92d7f053a 100644
--- a/Makefile
+++ b/Makefile
@@ -17,7 +17,7 @@ PROGS-$(CONFIG_FFSERVER) += ffserver
PROGS := $(PROGS-yes:%=%$(EXESUF))
INSTPROGS = $(PROGS-yes:%=%$(PROGSSUF)$(EXESUF))
-OBJS = $(PROGS-yes:%=%.o) cmdutils.o
+OBJS = cmdutils.o
TESTTOOLS = audiogen videogen rotozoom tiny_psnr base64
HOSTPROGS := $(TESTTOOLS:%=tests/%) doc/print_options
TOOLS = qt-faststart trasher
@@ -88,12 +88,19 @@ endef
$(foreach D,$(FFLIBS),$(eval $(call DOSUBDIR,lib$(D))))
-ffplay.o: CFLAGS += $(SDL_CFLAGS)
-ffplay_g$(EXESUF): FF_EXTRALIBS += $(SDL_LIBS)
-ffserver_g$(EXESUF): LDFLAGS += $(FFSERVERLDFLAGS)
+define DOPROG
+OBJS-$(1) += $(1).o
+$(1)_g$(EXESUF): $(OBJS-$(1))
+$$(OBJS-$(1)): CFLAGS += $(CFLAGS-$(1))
+$(1)_g$(EXESUF): LDFLAGS += $(LDFLAGS-$(1))
+$(1)_g$(EXESUF): FF_EXTRALIBS += $(LIBS-$(1))
+-include $$(OBJS-$(1):.o=.d)
+endef
+
+$(foreach P,$(PROGS-yes),$(eval $(call DOPROG,$(P))))
%$(PROGSSUF)_g$(EXESUF): %.o cmdutils.o $(FF_DEP_LIBS)
- $(LD) $(LDFLAGS) -o $@ $< cmdutils.o $(FF_EXTRALIBS)
+ $(LD) $(LDFLAGS) -o $@ $(OBJS-$*) cmdutils.o $(FF_EXTRALIBS)
OBJDIRS += tools
diff --git a/configure b/configure
index 12e37f2d9f..d7f180fef8 100755
--- a/configure
+++ b/configure
@@ -3926,7 +3926,7 @@ CXX_O=$CXX_O
LD_O=$LD_O
DLLTOOL=$dlltool
LDFLAGS=$LDFLAGS
-FFSERVERLDFLAGS=$FFSERVERLDFLAGS
+LDFLAGS-ffserver=$FFSERVERLDFLAGS
SHFLAGS=$SHFLAGS
YASMFLAGS=$YASMFLAGS
BUILDSUF=$build_suffix
@@ -3960,8 +3960,8 @@ HOSTCC_C=$HOSTCC_C
HOSTCC_O=$HOSTCC_O
TARGET_EXEC=$target_exec
TARGET_PATH=$target_path
-SDL_LIBS=$sdl_libs
-SDL_CFLAGS=$sdl_cflags
+LIBS-ffplay=$sdl_libs
+CFLAGS-ffplay=$sdl_cflags
LIB_INSTALL_EXTRA_CMD=$LIB_INSTALL_EXTRA_CMD
EXTRALIBS=$extralibs
INSTALL=$install
diff --git a/libavcodec/imc.c b/libavcodec/imc.c
index 2650bf7821..184c0c7263 100644
--- a/libavcodec/imc.c
+++ b/libavcodec/imc.c
@@ -92,7 +92,6 @@ typedef struct {
float sqrt_tab[30];
GetBitContext gb;
- float one_div_log2;
DSPContext dsp;
FFTContext fft;
@@ -227,10 +226,6 @@ 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);
-
- if (avctx->codec_id == CODEC_ID_IAC) {
- }
if (avctx->codec_id == CODEC_ID_IAC) {
iac_generate_tabs(q, avctx->sample_rate);
@@ -792,7 +787,7 @@ static int imc_decode_block(AVCodecContext *avctx, IMCContext *q, int ch)
chctx->decoder_reset = 1;
if (chctx->decoder_reset) {
- memset(q->out_samples, 0, sizeof(q->out_samples));
+ memset(q->out_samples, 0, COEFFS * sizeof(*q->out_samples));
for (i = 0; i < BANDS; i++)
chctx->old_floor[i] = 1.0;
for (i = 0; i < COEFFS; i++)
diff --git a/libavcodec/nuv.c b/libavcodec/nuv.c
index 00860fe120..0475e31b35 100644
--- a/libavcodec/nuv.c
+++ b/libavcodec/nuv.c
@@ -18,6 +18,7 @@
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
@@ -35,7 +36,7 @@ typedef struct {
int quality;
int width, height;
unsigned int decomp_size;
- unsigned char* decomp_buf;
+ unsigned char *decomp_buf;
uint32_t lq[64], cq[64];
RTJpegContext rtj;
DSPContext dsp;
@@ -70,8 +71,8 @@ static const uint8_t fallback_cquant[] = {
* @param width width of the video frame
* @param height height of the video frame
*/
-static void copy_frame(AVFrame *f, const uint8_t *src,
- int width, int height) {
+static void copy_frame(AVFrame *f, const uint8_t *src, int width, int height)
+{
AVPicture pic;
avpicture_fill(&pic, src, PIX_FMT_YUV420P, width, height);
av_picture_copy((AVPicture *)f, &pic, PIX_FMT_YUV420P, width, height);
@@ -80,8 +81,9 @@ static void copy_frame(AVFrame *f, const uint8_t *src,
/**
* @brief extract quantization tables from codec data into our context
*/
-static int get_quant(AVCodecContext *avctx, NuvContext *c,
- const uint8_t *buf, int size) {
+static int get_quant(AVCodecContext *avctx, NuvContext *c, const uint8_t *buf,
+ int size)
+{
int i;
if (size < 2 * 64 * 4) {
av_log(avctx, AV_LOG_ERROR, "insufficient rtjpeg quant data\n");
@@ -97,7 +99,8 @@ static int get_quant(AVCodecContext *avctx, NuvContext *c,
/**
* @brief set quantization tables from a quality value
*/
-static void get_quant_quality(NuvContext *c, int quality) {
+static void get_quant_quality(NuvContext *c, int quality)
+{
int i;
quality = FFMAX(quality, 1);
for (i = 0; i < 64; i++) {
@@ -106,7 +109,9 @@ static void get_quant_quality(NuvContext *c, int quality) {
}
}
-static int codec_reinit(AVCodecContext *avctx, int width, int height, int quality) {
+static int codec_reinit(AVCodecContext *avctx, int width, int height,
+ int quality)
+{
NuvContext *c = avctx->priv_data;
width = FFALIGN(width, 2);
height = FFALIGN(height, 2);
@@ -118,33 +123,44 @@ static int codec_reinit(AVCodecContext *avctx, int width, int height, int qualit
if (av_image_check_size(height, width, 0, avctx) < 0 ||
buf_size > INT_MAX/8)
return -1;
- avctx->width = c->width = width;
+ avctx->width = c->width = width;
avctx->height = c->height = height;
- av_fast_malloc(&c->decomp_buf, &c->decomp_size, buf_size);
+ av_fast_malloc(&c->decomp_buf, &c->decomp_size,
+ buf_size);
if (!c->decomp_buf) {
- av_log(avctx, AV_LOG_ERROR, "Can't allocate decompression buffer.\n");
+ av_log(avctx, AV_LOG_ERROR,
+ "Can't allocate decompression buffer.\n");
return AVERROR(ENOMEM);
}
- ff_rtjpeg_decode_init(&c->rtj, &c->dsp, c->width, c->height, c->lq, c->cq);
+ ff_rtjpeg_decode_init(&c->rtj, &c->dsp, c->width, c->height,
+ c->lq, c->cq);
return 1;
} else if (quality != c->quality)
- ff_rtjpeg_decode_init(&c->rtj, &c->dsp, c->width, c->height, c->lq, c->cq);
+ ff_rtjpeg_decode_init(&c->rtj, &c->dsp, c->width, c->height,
+ c->lq, c->cq);
+
return 0;
}
static int decode_frame(AVCodecContext *avctx, void *data, int *data_size,
- AVPacket *avpkt) {
+ AVPacket *avpkt)
+{
const uint8_t *buf = avpkt->data;
- int buf_size = avpkt->size;
- NuvContext *c = avctx->priv_data;
- AVFrame *picture = data;
- int orig_size = buf_size;
+ int buf_size = avpkt->size;
+ NuvContext *c = avctx->priv_data;
+ AVFrame *picture = data;
+ int orig_size = buf_size;
int keyframe;
int size_change = 0;
int result;
- enum {NUV_UNCOMPRESSED = '0', NUV_RTJPEG = '1',
- NUV_RTJPEG_IN_LZO = '2', NUV_LZO = '3',
- NUV_BLACK = 'N', NUV_COPY_LAST = 'L'} comptype;
+ enum {
+ NUV_UNCOMPRESSED = '0',
+ NUV_RTJPEG = '1',
+ NUV_RTJPEG_IN_LZO = '2',
+ NUV_LZO = '3',
+ NUV_BLACK = 'N',
+ NUV_COPY_LAST = 'L'
+ } comptype;
if (buf_size < 12) {
av_log(avctx, AV_LOG_ERROR, "coded frame too small\n");
@@ -155,12 +171,13 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size,
if (buf[0] == 'D' && buf[1] == 'R') {
int ret;
// skip rest of the frameheader.
- buf = &buf[12];
+ buf = &buf[12];
buf_size -= 12;
- ret = get_quant(avctx, c, buf, buf_size);
+ ret = get_quant(avctx, c, buf, buf_size);
if (ret < 0)
return ret;
- ff_rtjpeg_decode_init(&c->rtj, &c->dsp, c->width, c->height, c->lq, c->cq);
+ ff_rtjpeg_decode_init(&c->rtj, &c->dsp, c->width, c->height, c->lq,
+ c->cq);
return orig_size;
}
@@ -170,28 +187,32 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size,
}
comptype = buf[1];
switch (comptype) {
- case NUV_RTJPEG_IN_LZO:
- case NUV_RTJPEG:
- keyframe = !buf[2]; break;
- case NUV_COPY_LAST:
- keyframe = 0; break;
- default:
- keyframe = 1; break;
+ case NUV_RTJPEG_IN_LZO:
+ case NUV_RTJPEG:
+ keyframe = !buf[2];
+ break;
+ case NUV_COPY_LAST:
+ keyframe = 0;
+ break;
+ default:
+ keyframe = 1;
+ break;
}
retry:
// skip rest of the frameheader.
- buf = &buf[12];
+ buf = &buf[12];
buf_size -= 12;
if (comptype == NUV_RTJPEG_IN_LZO || comptype == NUV_LZO) {
int outlen = c->decomp_size - AV_LZO_OUTPUT_PADDING, inlen = buf_size;
if (av_lzo1x_decode(c->decomp_buf, &outlen, buf, &inlen))
av_log(avctx, AV_LOG_ERROR, "error during lzo decompression\n");
- buf = c->decomp_buf;
+ buf = c->decomp_buf;
buf_size = c->decomp_size - AV_LZO_OUTPUT_PADDING - outlen;
}
if (c->codec_frameheader) {
- int w, h, q, res;
- if (buf_size < 12) {
+ int w, h, q;
+ int res;
+ if (buf_size < RTJPEG_HEADER_SIZE) {
av_log(avctx, AV_LOG_ERROR, "Too small NUV video frame\n");
return AVERROR_INVALIDDATA;
}
@@ -214,14 +235,14 @@ retry:
size_change = 1;
goto retry;
}
- buf = &buf[12];
- buf_size -= 12;
+ buf = &buf[RTJPEG_HEADER_SIZE];
+ buf_size -= RTJPEG_HEADER_SIZE;
}
if ((size_change || keyframe) && c->pic.data[0])
avctx->release_buffer(avctx, &c->pic);
- c->pic.reference = 3;
- c->pic.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_READABLE |
+ c->pic.reference = 3;
+ c->pic.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_READABLE |
FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE;
result = avctx->reget_buffer(avctx, &c->pic);
if (result < 0) {
@@ -233,63 +254,69 @@ retry:
c->pic.key_frame = keyframe;
// decompress/copy/whatever data
switch (comptype) {
- case NUV_LZO:
- case NUV_UNCOMPRESSED: {
- int height = c->height;
- if (buf_size < c->width * height * 3 / 2) {
- av_log(avctx, AV_LOG_ERROR, "uncompressed frame too short\n");
- height = buf_size / c->width / 3 * 2;
- }
- copy_frame(&c->pic, buf, c->width, height);
- break;
- }
- case NUV_RTJPEG_IN_LZO:
- case NUV_RTJPEG: {
- ff_rtjpeg_decode_frame_yuv420(&c->rtj, &c->pic, buf, buf_size);
- break;
+ case NUV_LZO:
+ case NUV_UNCOMPRESSED: {
+ int height = c->height;
+ if (buf_size < c->width * height * 3 / 2) {
+ av_log(avctx, AV_LOG_ERROR, "uncompressed frame too short\n");
+ height = buf_size / c->width / 3 * 2;
}
- case NUV_BLACK: {
- memset(c->pic.data[0], 0, c->width * c->height);
- memset(c->pic.data[1], 128, c->width * c->height / 4);
- memset(c->pic.data[2], 128, c->width * c->height / 4);
- break;
- }
- case NUV_COPY_LAST: {
- /* nothing more to do here */
- break;
- }
- default:
- av_log(avctx, AV_LOG_ERROR, "unknown compression\n");
- return -1;
+ copy_frame(&c->pic, buf, c->width, height);
+ break;
+ }
+ case NUV_RTJPEG_IN_LZO:
+ case NUV_RTJPEG:
+ ff_rtjpeg_decode_frame_yuv420(&c->rtj, &c->pic, buf, buf_size);
+ break;
+ case NUV_BLACK:
+ memset(c->pic.data[0], 0, c->width * c->height);
+ memset(c->pic.data[1], 128, c->width * c->height / 4);
+ memset(c->pic.data[2], 128, c->width * c->height / 4);
+ break;
+ case NUV_COPY_LAST:
+ /* nothing more to do here */
+ break;
+ default:
+ av_log(avctx, AV_LOG_ERROR, "unknown compression\n");
+ return -1;
}
- *picture = c->pic;
+ *picture = c->pic;
*data_size = sizeof(AVFrame);
return orig_size;
}
-static av_cold int decode_init(AVCodecContext *avctx) {
- NuvContext *c = avctx->priv_data;
+static av_cold int decode_init(AVCodecContext *avctx)
+{
+ NuvContext *c = avctx->priv_data;
avctx->pix_fmt = PIX_FMT_YUV420P;
c->pic.data[0] = NULL;
- c->decomp_buf = NULL;
- c->quality = -1;
- c->width = 0;
- c->height = 0;
+ c->decomp_buf = NULL;
+ c->quality = -1;
+ c->width = 0;
+ c->height = 0;
+
c->codec_frameheader = avctx->codec_tag == MKTAG('R', 'J', 'P', 'G');
+
if (avctx->extradata_size)
get_quant(avctx, c, avctx->extradata, avctx->extradata_size);
+
ff_dsputil_init(&c->dsp, avctx);
+
if (codec_reinit(avctx, avctx->width, avctx->height, -1) < 0)
return 1;
+
return 0;
}
-static av_cold int decode_end(AVCodecContext *avctx) {
+static av_cold int decode_end(AVCodecContext *avctx)
+{
NuvContext *c = avctx->priv_data;
+
av_freep(&c->decomp_buf);
if (c->pic.data[0])
avctx->release_buffer(avctx, &c->pic);
+
return 0;
}
diff --git a/libavcodec/rtjpeg.h b/libavcodec/rtjpeg.h
index e127a19202..48c84ff505 100644
--- a/libavcodec/rtjpeg.h
+++ b/libavcodec/rtjpeg.h
@@ -25,6 +25,9 @@
#include <stdint.h>
#include "dsputil.h"
+#define RTJPEG_FILE_VERSION 0
+#define RTJPEG_HEADER_SIZE 12
+
typedef struct {
int w, h;
DSPContext *dsp;
diff --git a/libavformat/utils.c b/libavformat/utils.c
index a8fbbe1ac6..23b72b5b7b 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -2798,7 +2798,7 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
/* round guessed framerate to a "standard" framerate if it's
* within 1% of the original estimate*/
for (j = 1; j < MAX_STD_TIMEBASES; j++) {
- AVRational std_fps = (AVRational){get_std_framerate(j), 12*1001};
+ AVRational std_fps = { get_std_framerate(j), 12*1001 };
double error = fabs(av_q2d(st->avg_frame_rate) / av_q2d(std_fps) - 1);
if (error < best_error) {
diff --git a/tests/fate/filter.mak b/tests/fate/filter.mak
index 73b317b347..0d15ddbfbf 100644
--- a/tests/fate/filter.mak
+++ b/tests/fate/filter.mak
@@ -19,21 +19,16 @@ $(FATE_AMIX): CMP = oneoff
$(FATE_AMIX): CMP_UNIT = f32
FATE_FILTER += $(FATE_AMIX)
-FATE_SAMPLES_AVCONV += $(FATE_AMIX)
-FATE_ASYNCTS += fate-filter-asyncts
+FATE_FILTER += fate-filter-asyncts
fate-filter-asyncts: SRC = $(SAMPLES)/nellymoser/nellymoser-discont.flv
fate-filter-asyncts: CMD = pcm -i $(SRC) -af aresample=min_comp=0.001:min_hard_comp=0.1
fate-filter-asyncts: CMP = oneoff
fate-filter-asyncts: REF = $(SAMPLES)/nellymoser/nellymoser-discont.pcm
-FATE_FILTER += $(FATE_ASYNCTS)
-FATE_SAMPLES_AVCONV += $(FATE_ASYNCTS)
-
fate-filter-delogo: CMD = framecrc -i $(SAMPLES)/real/rv30.rm -vf delogo=show=0:x=290:y=25:w=26:h=16 -an
FATE_FILTER += fate-filter-delogo
-FATE_SAMPLES_AVCONV += fate-filter-delogo
FATE_YADIF += fate-filter-yadif-mode0
fate-filter-yadif-mode0: CMD = framecrc -flags bitexact -idct simple -i $(SAMPLES)/mpeg2/mpeg2_field_encoding.ts -vf yadif=0
@@ -42,6 +37,6 @@ FATE_YADIF += fate-filter-yadif-mode1
fate-filter-yadif-mode1: CMD = framecrc -flags bitexact -idct simple -i $(SAMPLES)/mpeg2/mpeg2_field_encoding.ts -vf yadif=1
FATE_FILTER += $(FATE_YADIF)
-FATE_SAMPLES_AVCONV += $(FATE_YADIF)
+FATE_SAMPLES_AVCONV += $(FATE_FILTER)
fate-filter: $(FATE_FILTER)