--target-os=OS compiler targets OS [$target_os]
--target-exec=CMD command to run executables on target
--target-path=DIR path to view of build directory on target
- --nm=NM use nm tool
+ --nm=NM use nm tool NM [$nm_default]
--ar=AR use archive tool AR [$ar_default]
--as=AS use assembler AS [$as_default]
+ --yasmexe=EXE use yasm-compatible assembler EXE [$yasmexe_default]
--cc=CC use C compiler CC [$cc_default]
- --ld=LD use linker LD
+ --cxx=CXX use C compiler CXX [$cxx_default]
+ --dep-cc=DEPCC use dependency generator DEPCC [$cc_default]
+ --ld=LD use linker LD [$ld_default]
--host-cc=HOSTCC use host C compiler HOSTCC
--host-cflags=HCFLAGS use HCFLAGS when compiling for host
--host-ldflags=HLDFLAGS use HLDFLAGS when linking for host
--host-libs=HLIBS use libs HLIBS when linking for host
+ --host-os=OS compiler host OS [$target_os]
--extra-cflags=ECFLAGS add ECFLAGS to CFLAGS [$CFLAGS]
+ --extra-cxxflags=ECFLAGS add ECFLAGS to CXXFLAGS [$CXXFLAGS]
--extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS [$LDFLAGS]
--extra-libs=ELIBS add ELIBS [$ELIBS]
--extra-version=STRING version string suffix []
- --optflags override optimization-related compiler flags
+ --optflags=OPTFLAGS override optimization-related compiler flags
--build-suffix=SUFFIX library name suffix []
--malloc-prefix=PREFIX prefix malloc and related names with PREFIX
+ --progs-suffix=SUFFIX program name suffix []
--arch=ARCH select architecture [$arch]
--cpu=CPU select the minimum required CPU (affects
instruction selection, may crash on older CPUs)
--- /dev/null
- * This file is part of Libav.
+ /*
- * Libav is free software; you can redistribute it and/or
++ * This file is part of FFmpeg
+ *
- * Libav is distributed in the hope that it will be useful,
++ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
- * License along with Libav; if not, write to the Free Software
++ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
++ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+ #ifndef AVCODEC_EAIDCT_H
+ #define AVCODEC_EAIDCT_H
+
+ #include <stdint.h>
+ #include "dsputil.h"
+
+ void ff_ea_idct_put_c(uint8_t *dest, int linesize, DCTELEM *block);
+
+ #endif /* AVCODEC_EAIDCT_H */
static inline void comp_block(MadContext *t, int mb_x, int mb_y,
int j, int mv_x, int mv_y, int add)
{
- MpegEncContext *s = &t->s;
if (j < 4) {
- if (offset >= (s->height - 7) * t->last_frame.linesize[0] - 7)
+ unsigned offset = (mb_y*16 + ((j&2)<<2) + mv_y)*t->last_frame.linesize[0] + mb_x*16 + ((j&1)<<3) + mv_x;
++ if (offset >= (t->avctx->height - 7) * t->last_frame.linesize[0] - 7)
+ return;
comp(t->frame.data[0] + (mb_y*16 + ((j&2)<<2))*t->frame.linesize[0] + mb_x*16 + ((j&1)<<3),
t->frame.linesize[0],
- t->last_frame.data[0] + (mb_y*16 + ((j&2)<<2) + mv_y)*t->last_frame.linesize[0] + mb_x*16 + ((j&1)<<3) + mv_x,
+ t->last_frame.data[0] + offset,
t->last_frame.linesize[0], add);
- } else if (!(s->avctx->flags & CODEC_FLAG_GRAY)) {
+ } else if (!(t->avctx->flags & CODEC_FLAG_GRAY)) {
int index = j - 3;
- if (offset >= (s->height/2 - 7) * t->last_frame.linesize[index] - 7)
+ unsigned offset = (mb_y * 8 + (mv_y/2))*t->last_frame.linesize[index] + mb_x * 8 + (mv_x/2);
++ if (offset >= (t->avctx->height/2 - 7) * t->last_frame.linesize[index] - 7)
+ return;
comp(t->frame.data[index] + (mb_y*8)*t->frame.linesize[index] + mb_x * 8,
t->frame.linesize[index],
- t->last_frame.data[index] + (mb_y * 8 + (mv_y/2))*t->last_frame.linesize[index] + mb_x * 8 + (mv_x/2),
+ t->last_frame.data[index] + offset,
t->last_frame.linesize[index], add);
}
}
}
}
- static inline int decode_block_intra(MadContext * t, DCTELEM * block)
-static inline void decode_block_intra(MadContext *s, DCTELEM * block)
++static inline int decode_block_intra(MadContext *s, DCTELEM * block)
{
- MpegEncContext *s = &t->s;
int level, i, j, run;
RLTable *rl = &ff_rl_mpeg1;
- const uint8_t *scantable = s->intra_scantable.permutated;
- int16_t *quant_matrix = s->intra_matrix;
+ const uint8_t *scantable = s->scantable.permutated;
+ int16_t *quant_matrix = s->quant_matrix;
block[0] = (128 + get_sbits(&s->gb, 8)) * quant_matrix[0];
return value;
}
- static int decode_mb(MadContext *t, int inter)
-static void decode_mb(MadContext *s, int inter)
++static int decode_mb(MadContext *s, int inter)
{
- MpegEncContext *s = &t->s;
int mv_map = 0;
int mv_x, mv_y;
int j;
for (j=0; j<6; j++) {
if (mv_map & (1<<j)) { // mv_x and mv_y are guarded by mv_map
int add = 2*decode_motion(&s->gb);
- if (t->last_frame.data[0])
- comp_block(t, s->mb_x, s->mb_y, j, mv_x, mv_y, add);
- comp_block(s, s->mb_x, s->mb_y, j, mv_x, mv_y, add);
++ if (s->last_frame.data[0])
++ comp_block(s, s->mb_x, s->mb_y, j, mv_x, mv_y, add);
} else {
- s->dsp.clear_block(t->block);
- if(decode_block_intra(t, t->block) < 0)
+ s->dsp.clear_block(s->block);
- decode_block_intra(s, s->block);
++ if(decode_block_intra(s, s->block) < 0)
+ return -1;
- idct_put(t, t->block, s->mb_x, s->mb_y, j);
+ idct_put(s, s->block, s->mb_x, s->mb_y, j);
}
}
+ return 0;
}
- static void calc_intra_matrix(MadContext *t, int qscale)
+ static void calc_quant_matrix(MadContext *s, int qscale)
{
- MpegEncContext *s = &t->s;
int i;
- if (s->avctx->idct_algo == FF_IDCT_EA) {
- s->intra_matrix[0] = (ff_inv_aanscales[0]*ff_mpeg1_default_intra_matrix[0]) >> 11;
- for (i=1; i<64; i++)
- s->intra_matrix[i] = (ff_inv_aanscales[i]*ff_mpeg1_default_intra_matrix[i]*qscale + 32) >> 10;
- } else {
- s->intra_matrix[0] = ff_mpeg1_default_intra_matrix[0];
- for (i=1; i<64; i++)
- s->intra_matrix[i] = (ff_mpeg1_default_intra_matrix[i]*qscale) << 1;
- }
+ s->quant_matrix[0] = (ff_inv_aanscales[0]*ff_mpeg1_default_intra_matrix[0]) >> 11;
+ for (i=1; i<64; i++)
+ s->quant_matrix[i] = (ff_inv_aanscales[i]*ff_mpeg1_default_intra_matrix[i]*qscale + 32) >> 10;
}
static int decode_frame(AVCodecContext *avctx,
av_reduce(&avctx->time_base.num, &avctx->time_base.den,
AV_RL16(&buf[6]), 1000, 1<<30);
- s->width = AV_RL16(&buf[8]);
- s->height = AV_RL16(&buf[10]);
- calc_intra_matrix(t, buf[13]);
+ width = AV_RL16(&buf[8]);
+ height = AV_RL16(&buf[10]);
+ calc_quant_matrix(s, buf[13]);
buf += 16;
- if (avctx->width != s->width || avctx->height != s->height) {
- if((s->width * s->height)/2048*7 > buf_end-buf)
+ if (avctx->width != width || avctx->height != height) {
++ if((width * height)/2048*7 > buf_end-buf)
+ return -1;
- if (av_image_check_size(s->width, s->height, 0, avctx) < 0)
+ if (av_image_check_size(width, height, 0, avctx) < 0)
return -1;
- avcodec_set_dimensions(avctx, s->width, s->height);
- if (t->frame.data[0])
- avctx->release_buffer(avctx, &t->frame);
- if (t->last_frame.data[0])
- avctx->release_buffer(avctx, &t->last_frame);
+ avcodec_set_dimensions(avctx, width, height);
+ if (s->frame.data[0])
+ avctx->release_buffer(avctx, &s->frame);
++ if (s->last_frame.data[0])
++ avctx->release_buffer(avctx, &s->last_frame);
}
- t->frame.reference = 3;
- if (!t->frame.data[0]) {
- if (avctx->get_buffer(avctx, &t->frame) < 0) {
- s->frame.reference = 1;
++ s->frame.reference = 3;
+ if (!s->frame.data[0]) {
+ if (avctx->get_buffer(avctx, &s->frame) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return -1;
}
}
- av_fast_malloc(&t->bitstream_buf, &t->bitstream_buf_size, (buf_end-buf) + FF_INPUT_BUFFER_PADDING_SIZE);
- if (!t->bitstream_buf)
+ av_fast_malloc(&s->bitstream_buf, &s->bitstream_buf_size, (buf_end-buf) + FF_INPUT_BUFFER_PADDING_SIZE);
+ if (!s->bitstream_buf)
return AVERROR(ENOMEM);
- bswap16_buf(t->bitstream_buf, (const uint16_t*)buf, (buf_end-buf)/2);
- memset((uint8_t*)t->bitstream_buf + (buf_end-buf), 0, FF_INPUT_BUFFER_PADDING_SIZE);
- init_get_bits(&s->gb, t->bitstream_buf, 8*(buf_end-buf));
+ bswap16_buf(s->bitstream_buf, (const uint16_t*)buf, (buf_end-buf)/2);
++ memset((uint8_t*)s->bitstream_buf + (buf_end-buf), 0, FF_INPUT_BUFFER_PADDING_SIZE);
+ init_get_bits(&s->gb, s->bitstream_buf, 8*(buf_end-buf));
for (s->mb_y=0; s->mb_y < (avctx->height+15)/16; s->mb_y++)
for (s->mb_x=0; s->mb_x < (avctx->width +15)/16; s->mb_x++)
- if(decode_mb(t, inter) < 0)
- decode_mb(s, inter);
++ if(decode_mb(s, inter) < 0)
+ return -1;
*data_size = sizeof(AVFrame);
- *(AVFrame*)data = t->frame;
+ *(AVFrame*)data = s->frame;
if (chunk_type != MADe_TAG)
- FFSWAP(AVFrame, t->frame, t->last_frame);
+ FFSWAP(AVFrame, s->frame, s->last_frame);
return buf_size;
}
sps->sar.den= 1;
if(s->avctx->debug&FF_DEBUG_PICT_INFO){
- av_log(h->s.avctx, AV_LOG_DEBUG, "sps:%u profile:%d/%d poc:%d ref:%d %dx%d %s %s crop:%d/%d/%d/%d %s %s %d/%d\n",
+ static const char csp[4][5] = { "Gray", "420", "422", "444" };
+ av_log(h->s.avctx, AV_LOG_DEBUG, "sps:%u profile:%d/%d poc:%d ref:%d %dx%d %s %s crop:%d/%d/%d/%d %s %s %d/%d b%d\n",
sps_id, sps->profile_idc, sps->level_idc,
sps->poc_type,
sps->ref_frame_count,
sps->crop_left, sps->crop_right,
sps->crop_top, sps->crop_bottom,
sps->vui_parameters_present_flag ? "VUI" : "",
- ((const char*[]){"Gray","420","422","444"})[sps->chroma_format_idc],
+ csp[sps->chroma_format_idc],
sps->timing_info_present_flag ? sps->num_units_in_tick : 0,
- sps->timing_info_present_flag ? sps->time_scale : 0
+ sps->timing_info_present_flag ? sps->time_scale : 0,
+ sps->bit_depth_luma
);
}
AVInputFormat ff_cdg_demuxer = {
.name = "cdg",
- .long_name = NULL_IF_CONFIG_SMALL("CD Graphics Format"),
+ .long_name = NULL_IF_CONFIG_SMALL("CD Graphics"),
.read_header = read_header,
.read_packet = read_packet,
+ .flags = AVFMT_GENERIC_INDEX,
.extensions = "cdg",
};
AVOutputFormat ff_crc_muxer = {
.name = "crc",
- .long_name = NULL_IF_CONFIG_SMALL("CRC testing format"),
+ .long_name = NULL_IF_CONFIG_SMALL("CRC testing"),
- .extensions = "",
.priv_data_size = sizeof(CRCState),
.audio_codec = CODEC_ID_PCM_S16LE,
.video_codec = CODEC_ID_RAWVIDEO,
#if CONFIG_DAUD_DEMUXER
AVInputFormat ff_daud_demuxer = {
.name = "daud",
- .long_name = NULL_IF_CONFIG_SMALL("D-Cinema audio format"),
+ .long_name = NULL_IF_CONFIG_SMALL("D-Cinema audio"),
.read_header = daud_header,
.read_packet = daud_packet,
- .extensions = "302",
+ .extensions = "302,daud",
};
#endif
AVInputFormat ff_ffm_demuxer = {
.name = "ffm",
- .long_name = NULL_IF_CONFIG_SMALL("FFM (FFserver live feed) format"),
- .long_name = NULL_IF_CONFIG_SMALL("FFM (AVserver live feed)"),
++ .long_name = NULL_IF_CONFIG_SMALL("FFM (FFserver live feed)"),
.priv_data_size = sizeof(FFMContext),
.read_probe = ffm_probe,
.read_header = ffm_read_header,
AVOutputFormat ff_ffm_muxer = {
.name = "ffm",
- .long_name = NULL_IF_CONFIG_SMALL("FFM (FFserver live feed) format"),
- .long_name = NULL_IF_CONFIG_SMALL("FFM (AVserver live feed)"),
- .mime_type = "",
++ .long_name = NULL_IF_CONFIG_SMALL("FFM (FFserver live feed)"),
.extensions = "ffm",
.priv_data_size = sizeof(FFMContext),
.audio_codec = CODEC_ID_MP2,
AVOutputFormat ff_framecrc_muxer = {
.name = "framecrc",
- .long_name = NULL_IF_CONFIG_SMALL("framecrc testing format"),
+ .long_name = NULL_IF_CONFIG_SMALL("framecrc testing"),
- .extensions = "",
.audio_codec = CODEC_ID_PCM_S16LE,
.video_codec = CODEC_ID_RAWVIDEO,
.write_header = ff_framehash_write_header,
AVInputFormat ff_g723_1_demuxer = {
.name = "g723_1",
- .long_name = NULL_IF_CONFIG_SMALL("G.723.1 format"),
+ .long_name = NULL_IF_CONFIG_SMALL("G.723.1"),
.read_header = g723_1_init,
.read_packet = g723_1_read_packet,
- .extensions = "tco",
+ .extensions = "tco,rco,g723_1",
.flags = AVFMT_GENERIC_INDEX
};
AVOutputFormat ff_md5_muxer = {
.name = "md5",
- .long_name = NULL_IF_CONFIG_SMALL("MD5 testing format"),
+ .long_name = NULL_IF_CONFIG_SMALL("MD5 testing"),
- .extensions = "",
.priv_data_size = PRIVSIZE,
.audio_codec = CODEC_ID_PCM_S16LE,
.video_codec = CODEC_ID_RAWVIDEO,
AVOutputFormat ff_framemd5_muxer = {
.name = "framemd5",
- .long_name = NULL_IF_CONFIG_SMALL("Per-frame MD5 testing format"),
+ .long_name = NULL_IF_CONFIG_SMALL("Per-frame MD5 testing"),
- .extensions = "",
.priv_data_size = PRIVSIZE,
.audio_codec = CODEC_ID_PCM_S16LE,
.video_codec = CODEC_ID_RAWVIDEO,
AVInputFormat ff_nut_demuxer = {
.name = "nut",
- .long_name = NULL_IF_CONFIG_SMALL("NUT format"),
+ .long_name = NULL_IF_CONFIG_SMALL("NUT"),
+ .flags = AVFMT_SEEK_TO_PTS,
.priv_data_size = sizeof(NUTContext),
.read_probe = nut_probe,
.read_header = nut_read_header,
return AVERROR(EIO);
}
+/**
+ * \brief looks for the string RTjjjjjjjjjj in the stream too resync reading
+ * \return 1 if the syncword is found 0 otherwise.
+ */
+static int nuv_resync(AVFormatContext *s, int64_t pos_limit) {
+ AVIOContext *pb = s->pb;
+ uint32_t tag = 0;
+ while(!url_feof(pb) && avio_tell(pb) < pos_limit) {
+ tag = (tag << 8) | avio_r8(pb);
+ if (tag == MKBETAG('R','T','j','j') &&
+ (tag = avio_rb32(pb)) == MKBETAG('j','j','j','j') &&
+ (tag = avio_rb32(pb)) == MKBETAG('j','j','j','j'))
+ return 1;
+ }
+ return 0;
+}
+
+/**
+ * \brief attempts to read a timestamp from stream at the given stream position
+ * \return timestamp if successful and AV_NOPTS_VALUE if failure
+ */
+static int64_t nuv_read_dts(AVFormatContext *s, int stream_index,
+ int64_t *ppos, int64_t pos_limit)
+{
+ NUVContext *ctx = s->priv_data;
+ AVIOContext *pb = s->pb;
+ uint8_t hdr[HDRSIZE];
+ nuv_frametype frametype;
+ int size, key, idx;
+ int64_t pos, dts;
+
+ if (avio_seek(pb, *ppos, SEEK_SET) < 0)
+ return AV_NOPTS_VALUE;
+
+ if (!nuv_resync(s, pos_limit))
+ return AV_NOPTS_VALUE;
+
+ while (!url_feof(pb) && avio_tell(pb) < pos_limit) {
+ if (avio_read(pb, hdr, HDRSIZE) < HDRSIZE)
+ return AV_NOPTS_VALUE;
+ frametype = hdr[0];
+ size = PKTSIZE(AV_RL32(&hdr[8]));
+ switch (frametype) {
+ case NUV_SEEKP:
+ break;
+ case NUV_AUDIO:
+ case NUV_VIDEO:
+ if (frametype == NUV_VIDEO) {
+ idx = ctx->v_id;
+ key = hdr[2] == 0;
+ } else {
+ idx = ctx->a_id;
+ key = 1;
+ }
+ if (stream_index == idx) {
+
+ pos = avio_tell(s->pb) - HDRSIZE;
+ dts = AV_RL32(&hdr[4]);
+
+ // TODO - add general support in av_gen_search, so it adds positions after reading timestamps
+ av_add_index_entry(s->streams[stream_index], pos, dts, size + HDRSIZE, 0,
+ key ? AVINDEX_KEYFRAME : 0);
+
+ *ppos = pos;
+ return dts;
+ }
+ default:
+ avio_skip(pb, size);
+ break;
+ }
+ }
+ return AV_NOPTS_VALUE;
+}
+
+
AVInputFormat ff_nuv_demuxer = {
.name = "nuv",
- .long_name = NULL_IF_CONFIG_SMALL("NuppelVideo format"),
+ .long_name = NULL_IF_CONFIG_SMALL("NuppelVideo"),
.priv_data_size = sizeof(NUVContext),
.read_probe = nuv_probe,
.read_header = nuv_header,
--- /dev/null
- .long_name = NULL_IF_CONFIG_SMALL("SubRip subtitle format"),
+/*
+ * SubRip subtitle muxer
+ * Copyright (c) 2012 Nicolas George <nicolas.george@normalesup.org>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "avformat.h"
+#include "internal.h"
+#include "libavutil/log.h"
+
+/* TODO: add options for:
+ - character encoding;
+ - LF / CRLF;
+ - byte order mark.
+ */
+
+typedef struct SRTContext{
+ unsigned index;
+} SRTContext;
+
+static int srt_write_header(AVFormatContext *avf)
+{
+ if (avf->nb_streams != 1 ||
+ avf->streams[0]->codec->codec_type != AVMEDIA_TYPE_SUBTITLE) {
+ av_log(avf, AV_LOG_ERROR,
+ "SRT supports only a single subtitles stream.\n");
+ return AVERROR(EINVAL);
+ }
+ if (avf->streams[0]->codec->codec_id != CODEC_ID_TEXT &&
+ avf->streams[0]->codec->codec_id != CODEC_ID_SRT) {
+ av_log(avf, AV_LOG_ERROR,
+ "Unsupported subtitles codec: %s\n",
+ avcodec_get_name(avf->streams[0]->codec->codec_id));
+ return AVERROR(EINVAL);
+ }
+ avpriv_set_pts_info(avf->streams[0], 64, 1, 1000);
+ return 0;
+}
+
+static int srt_write_packet(AVFormatContext *avf, AVPacket *pkt)
+{
+ SRTContext *srt = avf->priv_data;
+ int write_ts = avf->streams[0]->codec->codec_id != CODEC_ID_SRT;
+
+ srt->index++;
+ if (write_ts) {
+ char buf[64];
+ int64_t s = pkt->pts, e, d = pkt->duration;
+ int len;
+
+ if (d <= 0)
+ d = pkt->convergence_duration;
+ if (s == AV_NOPTS_VALUE || d <= 0) {
+ av_log(avf, AV_LOG_ERROR, "Insufficient timestamps.\n");
+ return AVERROR(EINVAL);
+ }
+ e = s + d;
+ len = snprintf(buf, sizeof(buf),
+ "%d\n%02d:%02d:%02d,%03d --> %02d:%02d:%02d,%03d\n",
+ srt->index,
+ (int)(s / 3600000), (int)(s / 60000) % 60,
+ (int)(s / 1000) % 60, (int)(s % 1000),
+ (int)(e / 3600000), (int)(e / 60000) % 60,
+ (int)(e / 1000) % 60, (int)(e % 1000));
+ avio_write(avf->pb, buf, len);
+ }
+ avio_write(avf->pb, pkt->data, pkt->size);
+ if (write_ts)
+ avio_write(avf->pb, "\n\n", 2);
+ avio_flush(avf->pb);
+ return 0;
+}
+
+AVOutputFormat ff_srt_muxer = {
+ .name = "srt",
++ .long_name = NULL_IF_CONFIG_SMALL("SubRip subtitle"),
+ .mime_type = "application/x-subrip",
+ .extensions = "srt",
+ .priv_data_size = sizeof(SRTContext),
+ .write_header = srt_write_header,
+ .write_packet = srt_write_packet,
+ .flags = AVFMT_VARIABLE_FPS,
+ .subtitle_codec = CODEC_ID_TEXT,
+};
int64_t pos;
uint32_t block_samples;
- if (s->pb->eof_reached)
+ if (url_feof(s->pb))
return AVERROR_EOF;
- if(wc->block_parsed){
+ if (wc->block_parsed) {
if ((ret = wv_read_block_header(s, s->pb, 0)) < 0)
return ret;
}
AVOutputFormat ff_yuv4mpegpipe_muxer = {
.name = "yuv4mpegpipe",
- .long_name = NULL_IF_CONFIG_SMALL("YUV4MPEG pipe format"),
+ .long_name = NULL_IF_CONFIG_SMALL("YUV4MPEG pipe"),
- .mime_type = "",
.extensions = "y4m",
.priv_data_size = sizeof(int),
.audio_codec = CODEC_ID_NONE,
return ret;
}
-int main(int argc, char *argv[])
+ static int16_t get_s16l(uint8_t *p)
+ {
+ union {
+ uint16_t u;
+ int16_t s;
+ } v;
+ v.u = p[0] | p[1] << 8;
+ return v.s;
+ }
+
+ static float get_f32l(uint8_t *p)
+ {
+ union av_intfloat32 v;
+ v.i = p[0] | p[1] << 8 | p[2] << 16 | p[3] << 24;
+ return v.f;
+ }
+
+static int run_psnr(FILE *f[2], int len, int shift, int skip_bytes)
{
int i, j;
uint64_t sse = 0;
(int)(dev / F), (int)(dev % F),
(int)(psnr / F), (int)(psnr % F),
maxdist, size0, size1);
- int len = argc < 4 ? 1 : atoi(argv[3]);
+ return psnr;
+}
+
+int main(int argc, char *argv[])
+{
+ FILE *f[2];
++ int len = 1;
+ int shift_first= argc < 5 ? 0 : atoi(argv[4]);
+ int skip_bytes = argc < 6 ? 0 : atoi(argv[5]);
+ int shift_last = shift_first + (argc < 7 ? 0 : atoi(argv[6]));
+ int shift;
+ int max_psnr = -1;
+ int max_psnr_shift = 0;
+
++ if (argc > 3) {
++ if (!strcmp(argv[3], "u8")) {
++ len = 1;
++ } else if (!strcmp(argv[3], "s16")) {
++ len = 2;
++ } else if (!strcmp(argv[3], "f32")) {
++ len = 4;
++ } else {
++ char *end;
++ len = strtol(argv[3], &end, 0);
++ if (*end || len > 2) {
++ fprintf(stderr, "Unsupported sample format: %s\n", argv[3]);
++ return 1;
++ }
++ }
++ }
++
+ if (argc < 3) {
+ printf("tiny_psnr <file1> <file2> [<elem size> [<shift> [<skip bytes> [<shift search range>]]]]\n");
+ printf("WAV headers are skipped automatically.\n");
+ return 1;
+ }
+
+ f[0] = fopen(argv[1], "rb");
+ f[1] = fopen(argv[2], "rb");
+ if (!f[0] || !f[1]) {
+ fprintf(stderr, "Could not open input files.\n");
+ return 1;
+ }
+
+ for (shift = shift_first; shift <= shift_last; shift++) {
+ int psnr = run_psnr(f, len, shift, skip_bytes);
+ if (psnr > max_psnr || (shift < 0 && psnr == max_psnr)) {
+ max_psnr = psnr;
+ max_psnr_shift = shift;
+ }
+ }
+ if (shift_last > shift_first)
+ printf("Best PSNR is %3d.%02d for shift %i\n", (int)(max_psnr / F), (int)(max_psnr % F), max_psnr_shift);
return 0;
}