[libav-devel] [PATCH 19/21] wmaenc: improve channel count and bitrate error handling in encode_init()

2011-05-11 Thread Anton Khirnov
From: Tomas Härdin 

Signed-off-by: Michael Niedermayer 
Signed-off-by: Anton Khirnov 
---
 libavcodec/wmaenc.c |   16 +++-
 1 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/libavcodec/wmaenc.c b/libavcodec/wmaenc.c
index d2e811f..3cdb4a0 100644
--- a/libavcodec/wmaenc.c
+++ b/libavcodec/wmaenc.c
@@ -33,11 +33,17 @@ static int encode_init(AVCodecContext * avctx){
 
 s->avctx = avctx;
 
-if(avctx->channels > MAX_CHANNELS)
-return -1;
+if(avctx->channels > MAX_CHANNELS) {
+av_log(avctx, AV_LOG_ERROR, "too many channels: got %i, need %i or 
fewer",
+   avctx->channels, MAX_CHANNELS);
+return AVERROR(EINVAL);
+}
 
-if(avctx->bit_rate < 24*1000)
-return -1;
+if(avctx->bit_rate < 24*1000) {
+av_log(avctx, AV_LOG_ERROR, "bitrate too low: got %i, need 24000 or 
higher\n",
+   avctx->bit_rate);
+return AVERROR(EINVAL);
+}
 
 /* extract flag infos */
 flags1 = 0;
-- 
1.7.5.1

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 18/21] matroskaenc: make sure we don't produce invalid file with no codec ID

2011-05-11 Thread Anton Khirnov
From: Aurelien Jacobs 

Signed-off-by: Aurelien Jacobs 
Signed-off-by: Anton Khirnov 
---
 libavformat/matroskaenc.c |4 
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index 4aa4caf..1bbabc9 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -614,6 +614,10 @@ static int mkv_write_tracks(AVFormatContext *s)
 
 case AVMEDIA_TYPE_SUBTITLE:
 put_ebml_uint(pb, MATROSKA_ID_TRACKTYPE, 
MATROSKA_TRACK_TYPE_SUBTITLE);
+if (!native_id) {
+av_log(s, AV_LOG_ERROR, "Subtitle codec %d is not 
supported.\n", codec->codec_id);
+return AVERROR(ENOSYS);
+}
 break;
 default:
 av_log(s, AV_LOG_ERROR, "Only audio, video, and subtitles are 
supported for Matroska.\n");
-- 
1.7.5.1

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 11/21] matroskadec: set timestamps for RealAudio packets.

2011-05-11 Thread Anton Khirnov
From: Reimar Döffinger 

Improves seeking in ffplay with
http://samples.mplayerhq.hu/Matroska/RA_missing_timestamps.mkv

Signed-off-by: Anton Khirnov 
---
 libavformat/matroskadec.c |8 
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index 0fa94a1..b75d22f 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -127,6 +127,7 @@ typedef struct {
 int  sub_packet_size;
 int  sub_packet_cnt;
 int  pkt_cnt;
+uint64_t buf_timecode;
 uint8_t *buf;
 } MatroskaTrackAudio;
 
@@ -1743,6 +1744,8 @@ static int matroska_parse_block(MatroskaDemuxContext 
*matroska, uint8_t *data,
 int x;
 
 if (!track->audio.pkt_cnt) {
+if (track->audio.sub_packet_cnt == 0)
+track->audio.buf_timecode = timecode;
 if (st->codec->codec_id == CODEC_ID_RA_288)
 for (x=0; xaudio.buf+x*2*w+y*cfs,
@@ -1765,6 +1768,8 @@ static int matroska_parse_block(MatroskaDemuxContext 
*matroska, uint8_t *data,
 av_new_packet(pkt, a);
 memcpy(pkt->data, track->audio.buf
+ a * (h*w / a - track->audio.pkt_cnt--), a);
+pkt->pts = track->audio.buf_timecode;
+track->audio.buf_timecode = AV_NOPTS_VALUE;
 pkt->pos = pos;
 pkt->stream_index = st->index;
 
dynarray_add(&matroska->packets,&matroska->num_packets,pkt);
@@ -1908,6 +1913,9 @@ static int matroska_read_seek(AVFormatContext *s, int 
stream_index,
 
 index_min = index;
 for (i=0; i < matroska->tracks.nb_elem; i++) {
+tracks[i].audio.pkt_cnt = 0;
+tracks[i].audio.sub_packet_cnt = 0;
+tracks[i].audio.buf_timecode = AV_NOPTS_VALUE;
 tracks[i].end_timecode = 0;
 if (tracks[i].type == MATROSKA_TRACK_TYPE_SUBTITLE
 && !tracks[i].stream->discard != AVDISCARD_ALL) {
-- 
1.7.5.1

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 15/21] ape: allow demuxing of files with metadata tags.

2011-05-11 Thread Anton Khirnov
From: Carl Eugen Hoyos 

Signed-off-by: Anton Khirnov 
---
 libavformat/ape.c |6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavformat/ape.c b/libavformat/ape.c
index 956036d..ade6c75 100644
--- a/libavformat/ape.c
+++ b/libavformat/ape.c
@@ -159,8 +159,8 @@ static int ape_read_header(AVFormatContext * s, 
AVFormatParameters * ap)
 int total_blocks;
 int64_t pts;
 
-/* TODO: Skip any leading junk such as id3v2 tags */
-ape->junklength = 0;
+/* Skip any leading junk such as id3v2 tags */
+ape->junklength = avio_tell(pb);
 
 tag = avio_rl32(pb);
 if (tag != MKTAG('M', 'A', 'C', ' '))
@@ -276,7 +276,7 @@ static int ape_read_header(AVFormatContext * s, 
AVFormatParameters * ap)
 ape->frames[0].nblocks = ape->blocksperframe;
 ape->frames[0].skip= 0;
 for (i = 1; i < ape->totalframes; i++) {
-ape->frames[i].pos  = ape->seektable[i]; //ape->frames[i-1].pos + 
ape->blocksperframe;
+ape->frames[i].pos  = ape->seektable[i] + ape->junklength; 
//ape->frames[i-1].pos + ape->blocksperframe;
 ape->frames[i].nblocks  = ape->blocksperframe;
 ape->frames[i - 1].size = ape->frames[i].pos - ape->frames[i - 1].pos;
 ape->frames[i].skip = (ape->frames[i].pos - ape->frames[0].pos) & 
3;
-- 
1.7.5.1

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 13/21] lavf: fix av_find_best_stream when providing a wanted stream.

2011-05-11 Thread Anton Khirnov
From: Marton Balint 

In the main loop, stream_number is incremented after checking the stream type,
so the search usually will not find the wanted stream.

This patch eliminates the useless stream_number variable and introduces a new
one, called real_stream_index to store the real stream index of the current
stream, no matter if we are looping through all the streams or only the streams
of a program.

Signed-off-by: Michael Niedermayer 
Signed-off-by: Anton Khirnov 
---
 libavformat/utils.c |9 +
 1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/libavformat/utils.c b/libavformat/utils.c
index 830e5d0..2afac16 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -2462,7 +2462,7 @@ int av_find_best_stream(AVFormatContext *ic,
 AVCodec **decoder_ret,
 int flags)
 {
-int i, nb_streams = ic->nb_streams, stream_number = 0;
+int i, nb_streams = ic->nb_streams;
 int ret = AVERROR_STREAM_NOT_FOUND, best_count = -1;
 unsigned *program = NULL;
 AVCodec *decoder = NULL, *best_decoder = NULL;
@@ -2475,11 +2475,12 @@ int av_find_best_stream(AVFormatContext *ic,
 }
 }
 for (i = 0; i < nb_streams; i++) {
-AVStream *st = ic->streams[program ? program[i] : i];
+int real_stream_index = program ? program[i] : i;
+AVStream *st = ic->streams[real_stream_index];
 AVCodecContext *avctx = st->codec;
 if (avctx->codec_type != type)
 continue;
-if (wanted_stream_nb >= 0 && stream_number++ != wanted_stream_nb)
+if (wanted_stream_nb >= 0 && real_stream_index != wanted_stream_nb)
 continue;
 if (st->disposition & 
(AV_DISPOSITION_HEARING_IMPAIRED|AV_DISPOSITION_VISUAL_IMPAIRED))
 continue;
@@ -2494,7 +2495,7 @@ int av_find_best_stream(AVFormatContext *ic,
 if (best_count >= st->codec_info_nb_frames)
 continue;
 best_count = st->codec_info_nb_frames;
-ret = program ? program[i] : i;
+ret = real_stream_index;
 best_decoder = decoder;
 if (program && i == nb_streams - 1 && ret < 0) {
 program = NULL;
-- 
1.7.5.1

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 14/21] lavf: fix function name in compute_pkt_fields2 av_dlog message

2011-05-11 Thread Anton Khirnov
From: Stefano Sabatini 

Signed-off-by: Anton Khirnov 
---
 libavformat/utils.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/libavformat/utils.c b/libavformat/utils.c
index 2afac16..67aa76a 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -2851,7 +2851,7 @@ static int compute_pkt_fields2(AVFormatContext *s, 
AVStream *st, AVPacket *pkt){
 int delay = FFMAX(st->codec->has_b_frames, !!st->codec->max_b_frames);
 int num, den, frame_size, i;
 
-av_dlog(s, "av_write_frame: pts:%"PRId64" dts:%"PRId64" cur_dts:%"PRId64" 
b:%d size:%d st:%d\n",
+av_dlog(s, "compute_pkt_fields2: pts:%"PRId64" dts:%"PRId64" 
cur_dts:%"PRId64" b:%d size:%d st:%d\n",
 pkt->pts, pkt->dts, st->cur_dts, delay, pkt->size, 
pkt->stream_index);
 
 /*if(pkt->pts == AV_NOPTS_VALUE && pkt->dts == AV_NOPTS_VALUE)
-- 
1.7.5.1

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 09/21] movenc: always write esds descriptor length using 4 bytes.

2011-05-11 Thread Anton Khirnov
From: Baptiste Coudurier 

ipod shuffle doesn't support anything else.

Signed-off-by: Anton Khirnov 
---
 libavformat/movenc.c|   14 +++---
 tests/ref/lavf/mov  |4 ++--
 tests/ref/vsynth1/mpeg4 |4 ++--
 tests/ref/vsynth2/mpeg4 |4 ++--
 4 files changed, 9 insertions(+), 17 deletions(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index bdd92f2..52c775a 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -238,16 +238,9 @@ static int mov_write_enda_tag(AVIOContext *pb)
 return 10;
 }
 
-static unsigned int descrLength(unsigned int len)
-{
-int i;
-for(i=1; len>>(7*i); i++);
-return len + 1 + i;
-}
-
 static void putDescr(AVIOContext *pb, int tag, unsigned int size)
 {
-int i= descrLength(size) - size - 2;
+int i = 3;
 avio_w8(pb, tag);
 for(; i>0; i--)
 avio_w8(pb, (size>>(7*i)) | 0x80);
@@ -257,15 +250,14 @@ static void putDescr(AVIOContext *pb, int tag, unsigned 
int size)
 static int mov_write_esds_tag(AVIOContext *pb, MOVTrack *track) // Basic
 {
 int64_t pos = avio_tell(pb);
-int decoderSpecificInfoLen = track->vosLen ? descrLength(track->vosLen):0;
+int decoderSpecificInfoLen = track->vosLen ? 5+track->vosLen : 0;
 
 avio_wb32(pb, 0); // size
 ffio_wfourcc(pb, "esds");
 avio_wb32(pb, 0); // Version
 
 // ES descriptor
-putDescr(pb, 0x03, 3 + descrLength(13 + decoderSpecificInfoLen) +
- descrLength(1));
+putDescr(pb, 0x03, 3 + 5+13 + decoderSpecificInfoLen + 5+1);
 avio_wb16(pb, track->trackID);
 avio_w8(pb, 0x00); // flags (= no flags)
 
diff --git a/tests/ref/lavf/mov b/tests/ref/lavf/mov
index 943c605..22aac36 100644
--- a/tests/ref/lavf/mov
+++ b/tests/ref/lavf/mov
@@ -1,3 +1,3 @@
-c145305a775eb2de43cdf94eb1ab5240 *./tests/data/lavf/lavf.mov
-357669 ./tests/data/lavf/lavf.mov
+439684b82ccc1fdd24a23392c238ae53 *./tests/data/lavf/lavf.mov
+357681 ./tests/data/lavf/lavf.mov
 ./tests/data/lavf/lavf.mov CRC=0x2f6a9b26
diff --git a/tests/ref/vsynth1/mpeg4 b/tests/ref/vsynth1/mpeg4
index 76b3904..ebe2f5a 100644
--- a/tests/ref/vsynth1/mpeg4
+++ b/tests/ref/vsynth1/mpeg4
@@ -1,4 +1,4 @@
-fd83f2ef5887a62b4d755d7cb5f0ac59 *./tests/data/vsynth1/odivx.mp4
-540144 ./tests/data/vsynth1/odivx.mp4
+080e75117f8142001b096cd977ba287e *./tests/data/vsynth1/odivx.mp4
+540156 ./tests/data/vsynth1/odivx.mp4
 8828a375448dc5c2215163ba70656f89 *./tests/data/mpeg4.vsynth1.out.yuv
 stddev:7.97 PSNR: 30.10 MAXDIFF:  105 bytes:  7603200/  7603200
diff --git a/tests/ref/vsynth2/mpeg4 b/tests/ref/vsynth2/mpeg4
index 9a6158c..fe436e8 100644
--- a/tests/ref/vsynth2/mpeg4
+++ b/tests/ref/vsynth2/mpeg4
@@ -1,4 +1,4 @@
-47de227982e77830a2db278214a08773 *./tests/data/vsynth2/odivx.mp4
-119797 ./tests/data/vsynth2/odivx.mp4
+8ffbe8ce43fe126b12cf9621717d641b *./tests/data/vsynth2/odivx.mp4
+119809 ./tests/data/vsynth2/odivx.mp4
 90a3577850239083a9042bef33c50e85 *./tests/data/mpeg4.vsynth2.out.yuv
 stddev:5.34 PSNR: 33.57 MAXDIFF:   83 bytes:  7603200/  7603200
-- 
1.7.5.1

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 10/21] dnxhdenc: add AVClass in private context.

2011-05-11 Thread Anton Khirnov
From: Baptiste Coudurier 

Fixes private options.

Signed-off-by: Anton Khirnov 
---
 libavcodec/dnxhdenc.c |4 ++--
 libavcodec/dnxhdenc.h |1 +
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/libavcodec/dnxhdenc.c b/libavcodec/dnxhdenc.c
index e00b6f6..78da1c1 100644
--- a/libavcodec/dnxhdenc.c
+++ b/libavcodec/dnxhdenc.c
@@ -433,7 +433,7 @@ static int dnxhd_calc_bits_thread(AVCodecContext *avctx, 
void *arg, int jobnr, i
 int n = dnxhd_switch_matrix(ctx, i);
 
 memcpy(block, src_block, 64*sizeof(*block));
-last_index = ctx->m.dct_quantize((MpegEncContext*)ctx, block, i, 
qscale, &overflow);
+last_index = ctx->m.dct_quantize(&ctx->m, block, i, qscale, 
&overflow);
 ac_bits += dnxhd_calc_ac_bits(ctx, block, last_index);
 
 diff = block[0] - ctx->m.last_dc[n];
@@ -478,7 +478,7 @@ static int dnxhd_encode_thread(AVCodecContext *avctx, void 
*arg, int jobnr, int
 DCTELEM *block = ctx->blocks[i];
 int last_index, overflow;
 int n = dnxhd_switch_matrix(ctx, i);
-last_index = ctx->m.dct_quantize((MpegEncContext*)ctx, block, i, 
qscale, &overflow);
+last_index = ctx->m.dct_quantize(&ctx->m, block, i, qscale, 
&overflow);
 //START_TIMER;
 dnxhd_encode_block(ctx, block, last_index, n);
 //STOP_TIMER("encode_block");
diff --git a/libavcodec/dnxhdenc.h b/libavcodec/dnxhdenc.h
index 83c0b1c..43f65e4 100644
--- a/libavcodec/dnxhdenc.h
+++ b/libavcodec/dnxhdenc.h
@@ -39,6 +39,7 @@ typedef struct {
 } RCEntry;
 
 typedef struct DNXHDEncContext {
+AVClass *class;
 MpegEncContext m; ///< Used for quantization dsp functions
 
 AVFrame frame;
-- 
1.7.5.1

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 12/21] lavf: fix av_find_best_stream when decoder_ret is given and using a related stream.

2011-05-11 Thread Anton Khirnov
From: Marton Balint 

Yet another fix for the code originally designed for use without related_stream.

Signed-off-by: Michael Niedermayer 
Signed-off-by: Anton Khirnov 
---
 libavformat/utils.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/libavformat/utils.c b/libavformat/utils.c
index 7959102..830e5d0 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -2484,7 +2484,7 @@ int av_find_best_stream(AVFormatContext *ic,
 if (st->disposition & 
(AV_DISPOSITION_HEARING_IMPAIRED|AV_DISPOSITION_VISUAL_IMPAIRED))
 continue;
 if (decoder_ret) {
-decoder = avcodec_find_decoder(ic->streams[i]->codec->codec_id);
+decoder = avcodec_find_decoder(st->codec->codec_id);
 if (!decoder) {
 if (ret < 0)
 ret = AVERROR_DECODER_NOT_FOUND;
-- 
1.7.5.1

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 17/21] matroskaenc: add missing new line in av_log() call

2011-05-11 Thread Anton Khirnov
From: Aurelien Jacobs 

Signed-off-by: Aurelien Jacobs 
Signed-off-by: Anton Khirnov 
---
 libavformat/matroskaenc.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index 781121a..4aa4caf 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -616,7 +616,7 @@ static int mkv_write_tracks(AVFormatContext *s)
 put_ebml_uint(pb, MATROSKA_ID_TRACKTYPE, 
MATROSKA_TRACK_TYPE_SUBTITLE);
 break;
 default:
-av_log(s, AV_LOG_ERROR, "Only audio, video, and subtitles are 
supported for Matroska.");
+av_log(s, AV_LOG_ERROR, "Only audio, video, and subtitles are 
supported for Matroska.\n");
 break;
 }
 ret = mkv_write_codecprivate(s, pb, codec, native_id, qt_id);
-- 
1.7.5.1

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 08/21] movenc: fix yuv range in avid atoms used by dnxhd.

2011-05-11 Thread Anton Khirnov
From: Baptiste Coudurier 

Signed-off-by: Anton Khirnov 
---
 libavformat/movenc.c  |2 +-
 tests/ref/vsynth1/dnxhd_1080i |2 +-
 tests/ref/vsynth2/dnxhd_1080i |2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 1d3eb3f..bdd92f2 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -535,7 +535,7 @@ static int mov_write_avid_tag(AVIOContext *pb, MOVTrack 
*track)
 ffio_wfourcc(pb, "ACLR");
 ffio_wfourcc(pb, "ACLR");
 ffio_wfourcc(pb, "0001");
-avio_wb32(pb, 1); /* yuv 1 / rgb 2 ? */
+avio_wb32(pb, 2); /* yuv range: full 1 / normal 2 */
 avio_wb32(pb, 0); /* unknown */
 
 avio_wb32(pb, 24); /* size */
diff --git a/tests/ref/vsynth1/dnxhd_1080i b/tests/ref/vsynth1/dnxhd_1080i
index 654242c..80484b5 100644
--- a/tests/ref/vsynth1/dnxhd_1080i
+++ b/tests/ref/vsynth1/dnxhd_1080i
@@ -1,4 +1,4 @@
-8a814d4056ca2810a8ed0bad3b70f358 *./tests/data/vsynth1/dnxhd-1080i.mov
+34949ea38da2cf6a8406ad600ad95cfa *./tests/data/vsynth1/dnxhd-1080i.mov
 3031875 ./tests/data/vsynth1/dnxhd-1080i.mov
 0c651e840f860592f0d5b66030d9fa32 *./tests/data/dnxhd_1080i.vsynth1.out.yuv
 stddev:6.29 PSNR: 32.15 MAXDIFF:   64 bytes:   760320/  7603200
diff --git a/tests/ref/vsynth2/dnxhd_1080i b/tests/ref/vsynth2/dnxhd_1080i
index 3dc0ef5..ae98846 100644
--- a/tests/ref/vsynth2/dnxhd_1080i
+++ b/tests/ref/vsynth2/dnxhd_1080i
@@ -1,4 +1,4 @@
-c81c7cfb375f61b7ab9b60fa340fe52a *./tests/data/vsynth2/dnxhd-1080i.mov
+995e433cd076e3c1534fa73181744a84 *./tests/data/vsynth2/dnxhd-1080i.mov
 3031875 ./tests/data/vsynth2/dnxhd-1080i.mov
 3c559af629ae0a8fb1a9a0e4b4da7733 *./tests/data/dnxhd_1080i.vsynth2.out.yuv
 stddev:1.31 PSNR: 45.77 MAXDIFF:   23 bytes:   760320/  7603200
-- 
1.7.5.1

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 20/21] srtdec: make sure we don't write past the end of buffer

2011-05-11 Thread Anton Khirnov
From: Aurelien Jacobs 

Signed-off-by: Aurelien Jacobs 
Signed-off-by: Anton Khirnov 
---
 libavcodec/srtdec.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/libavcodec/srtdec.c b/libavcodec/srtdec.c
index da625aa..677c550 100644
--- a/libavcodec/srtdec.c
+++ b/libavcodec/srtdec.c
@@ -94,7 +94,7 @@ static const char *srt_to_ass(AVCodecContext *avctx, char 
*out, char *out_end,
 break;
 case '<':
 tag_close = in[1] == '/';
-if (sscanf(in+tag_close+1, "%128[^>]>%n%c", buffer, &len,&c) >= 2) 
{
+if (sscanf(in+tag_close+1, "%127[^>]>%n%c", buffer, &len,&c) >= 2) 
{
 if ((param = strchr(buffer, ' ')))
 *param++ = 0;
 if ((!tag_close && sptr < FF_ARRAY_ELEMS(stack)) ||
-- 
1.7.5.1

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 21/21] mpegvideo: make FF_DEBUG_DCT_COEFF output coeffs via av_log() instead of just via AVFrame.

2011-05-11 Thread Anton Khirnov
From: Michael Niedermayer 

This allows the values to be used without changing C code and is closer to how
the other DEBUG flags work.

Signed-off-by: Anton Khirnov 
---
 libavcodec/mpegvideo.c |9 +++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index 2c0525e..09e8134 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -1869,9 +1869,14 @@ void MPV_decode_mb_internal(MpegEncContext *s, DCTELEM 
block[12][64],
/* save DCT coefficients */
int i,j;
DCTELEM *dct = &s->current_picture.dct_coeff[mb_xy*64*6];
-   for(i=0; i<6; i++)
-   for(j=0; j<64; j++)
+   av_log(s->avctx, AV_LOG_DEBUG, "DCT coeffs of MB at %dx%d:\n", s->mb_x, 
s->mb_y);
+   for(i=0; i<6; i++){
+   for(j=0; j<64; j++){
*dct++ = block[i][s->dsp.idct_permutation[j]];
+   av_log(s->avctx, AV_LOG_DEBUG, "%5d", dct[-1]);
+   }
+   av_log(s->avctx, AV_LOG_DEBUG, "\n");
+   }
 }
 
 s->current_picture.qscale_table[mb_xy]= s->qscale;
-- 
1.7.5.1

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 06/21] mpegts: do not output known sized packet if an unbounded packet is already queued.

2011-05-11 Thread Anton Khirnov
From: Baptiste Coudurier 

Fix issue #2624.

Signed-off-by: Anton Khirnov 
---
 libavformat/mpegts.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index 3130eb9..e6779fe 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -801,7 +801,7 @@ static int mpegts_push_data(MpegTSFilter *filter,
  * a couple of seconds to milliseconds for properly muxed files.
  * total_size is the number of bytes following pes_packet_length
  * in the pes header, i.e. not counting the first 6 bytes */
-if (pes->total_size < MAX_PES_PAYLOAD &&
+if (!ts->stop_parse && pes->total_size < MAX_PES_PAYLOAD &&
 pes->pes_header_size + pes->data_index == pes->total_size + 6) 
{
 ts->stop_parse = 1;
 new_pes_packet(pes, ts->pkt);
-- 
1.7.5.1

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 07/21] movenc: fix adpcm mono muxing.

2011-05-11 Thread Anton Khirnov
From: Alex Converse 

Signed-off-by: Anton Khirnov 
---
 libavformat/movenc.c |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 0327bdf..1d3eb3f 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -91,6 +91,7 @@ static int mov_write_stsz_tag(AVIOContext *pb, MOVTrack 
*track)
 }
 if (equalChunks) {
 int sSize = track->cluster[0].size/track->cluster[0].entries;
+sSize = FFMAX(1, sSize); // adpcm mono case could make sSize == 0
 avio_wb32(pb, sSize); // sample size
 avio_wb32(pb, entries); // sample count
 }
-- 
1.7.5.1

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 16/21] matroskadec: check that pointers were initialized before accessing them

2011-05-11 Thread Anton Khirnov
From: Aurelien Jacobs 

Signed-off-by: Aurelien Jacobs 
Signed-off-by: Anton Khirnov 
---
 libavformat/matroskadec.c |8 +---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index b75d22f..d65917c 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -1085,19 +1085,21 @@ static void matroska_convert_tags(AVFormatContext *s)
 if (tags[i].target.attachuid) {
 MatroskaAttachement *attachment = matroska->attachments.elem;
 for (j=0; jattachments.nb_elem; j++)
-if (attachment[j].uid == tags[i].target.attachuid)
+if (attachment[j].uid == tags[i].target.attachuid
+&& attachment[j].stream)
 matroska_convert_tag(s, &tags[i].tag,
  &attachment[j].stream->metadata, 
NULL);
 } else if (tags[i].target.chapteruid) {
 MatroskaChapter *chapter = matroska->chapters.elem;
 for (j=0; jchapters.nb_elem; j++)
-if (chapter[j].uid == tags[i].target.chapteruid)
+if (chapter[j].uid == tags[i].target.chapteruid
+&& chapter[j].chapter)
 matroska_convert_tag(s, &tags[i].tag,
  &chapter[j].chapter->metadata, NULL);
 } else if (tags[i].target.trackuid) {
 MatroskaTrack *track = matroska->tracks.elem;
 for (j=0; jtracks.nb_elem; j++)
-if (track[j].uid == tags[i].target.trackuid)
+if (track[j].uid == tags[i].target.trackuid && track[j].stream)
 matroska_convert_tag(s, &tags[i].tag,
  &track[j].stream->metadata, NULL);
 } else {
-- 
1.7.5.1

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 05/21] dfa: fix buffer overflow checks to avoid integer overflows.

2011-05-11 Thread Anton Khirnov
From: Reimar Döffinger 

Signed-off-by: Anton Khirnov 
---
 libavcodec/dfa.c |   35 +++
 1 files changed, 19 insertions(+), 16 deletions(-)

diff --git a/libavcodec/dfa.c b/libavcodec/dfa.c
index b149791..1556bc7 100644
--- a/libavcodec/dfa.c
+++ b/libavcodec/dfa.c
@@ -62,12 +62,14 @@ static int decode_tsw1(uint8_t *frame, int width, int 
height,
 const uint8_t *frame_start = frame;
 const uint8_t *frame_end   = frame + width * height;
 int mask = 0x1, bitbuf = 0;
-int v, offset, count, segments;
+int v, count, segments;
+unsigned offset;
 
 segments = bytestream_get_le32(&src);
-frame   += bytestream_get_le32(&src);
-if (frame < frame_start || frame > frame_end)
+offset   = bytestream_get_le32(&src);
+if (frame_end - frame <= offset)
 return -1;
+frame += offset;
 while (segments--) {
 if (mask == 0x1) {
 if (src >= src_end)
@@ -189,11 +191,11 @@ static int decode_bdlt(uint8_t *frame, int width, int 
height,
 int count, lines, segments;
 
 count = bytestream_get_le16(&src);
-if (count >= height || width * count < 0)
+if (count >= height)
 return -1;
 frame += width * count;
 lines = bytestream_get_le16(&src);
-if (frame + lines * width > frame_end || src >= src_end)
+if (count + lines > height || src >= src_end)
 return -1;
 
 while (lines--) {
@@ -203,17 +205,17 @@ static int decode_bdlt(uint8_t *frame, int width, int 
height,
 while (segments--) {
 if (src_end - src < 3)
 return -1;
-line_ptr += *src++;
-if (line_ptr >= frame)
+if (frame - line_ptr <= *src)
 return -1;
+line_ptr += *src++;
 count = (int8_t)*src++;
 if (count >= 0) {
-if (line_ptr + count > frame || src_end - src < count)
+if (frame - line_ptr < count || src_end - src < count)
 return -1;
 bytestream_get_buffer(&src, line_ptr, count);
 } else {
 count = -count;
-if (line_ptr + count > frame || src >= src_end)
+if (frame - line_ptr < count || src >= src_end)
 return -1;
 memset(line_ptr, *src++, count);
 }
@@ -232,15 +234,16 @@ static int decode_wdlt(uint8_t *frame, int width, int 
height,
 int count, i, v, lines, segments;
 
 lines = bytestream_get_le16(&src);
-if (frame + lines * width > frame_end || src >= src_end)
+if (lines > height || src >= src_end)
 return -1;
 
 while (lines--) {
 segments = bytestream_get_le16(&src);
 while ((segments & 0xC000) == 0xC000) {
-frame-= (int16_t)segments * width;
-if (frame >= frame_end)
+unsigned delta = -((int16_t)segments * width);
+if (frame_end - frame <= delta)
 return -1;
+frame+= delta;
 segments = bytestream_get_le16(&src);
 }
 if (segments & 0x8000) {
@@ -252,18 +255,18 @@ static int decode_wdlt(uint8_t *frame, int width, int 
height,
 while (segments--) {
 if (src_end - src < 2)
 return -1;
-line_ptr += *src++;
-if (line_ptr >= frame)
+if (frame - line_ptr <= *src)
 return -1;
+line_ptr += *src++;
 count = (int8_t)*src++;
 if (count >= 0) {
-if (line_ptr + count*2 > frame || src_end - src < count*2)
+if (frame - line_ptr < count*2 || src_end - src < count*2)
 return -1;
 bytestream_get_buffer(&src, line_ptr, count*2);
 line_ptr += count * 2;
 } else {
 count = -count;
-if (line_ptr + count*2 > frame || src_end - src < 2)
+if (frame - line_ptr < count*2 || src_end - src < 2)
 return -1;
 v = bytestream_get_le16(&src);
 for (i = 0; i < count; i++)
-- 
1.7.5.1

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 02/21] patcheck: warn about assert usage

2011-05-11 Thread Anton Khirnov
From: Peter Ross 

Signed-off-by: Michael Niedermayer 
Signed-off-by: Anton Khirnov 
---
 tools/patcheck |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/tools/patcheck b/tools/patcheck
index a8c0cc8..19faf47 100755
--- a/tools/patcheck
+++ b/tools/patcheck
@@ -84,6 +84,7 @@ hiegrep '(:\+|,|;)( *|static|\*)*'"$ERE_PRITYP"' *\*( 
|\*)*(src|source|input|in[
 hiegrep '(:\+|,|;)( *|static|\*)*'"$ERE_PRITYP"' 
*(src|source|input|in)([0-9A-Z_][0-9A-Za-z_]*){1,} *\[' 'missing const 
(test2)?' $*
 hiegrep ' *static *'"$ERE_FUNCS"'[^)]*\);' 'static prototype, maybe you should 
reorder your functions' $*
 hiegrep '@file: *[a-zA-Z0-9_]' 'doxy filetag with filename can in the future 
cause problems when forgotten during a rename' $*
+hiegrep '\bassert' 'Please use av_assert0, av_assert1 or av_assert2' $*
 
 hiegrep2 '\.long_name *=' 'NULL_IF_CONFIG_SMAL' 'missing NULL_IF_CONFIG_SMAL' 
$*
 hiegrep2 '\.pix_fmts *= *\(' 'const' 'missing const for pix_fmts array' $*
-- 
1.7.5.1

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 04/21] lavc: Mark MS-MPEG4v1 encoder as experimental.

2011-05-11 Thread Anton Khirnov
From: Carl Eugen Hoyos 

The encoder has never produced files that could be decoded
with any software.

Signed-off-by: Anton Khirnov 
---
 libavcodec/msmpeg4.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/libavcodec/msmpeg4.c b/libavcodec/msmpeg4.c
index 6c9c209..0400c96 100644
--- a/libavcodec/msmpeg4.c
+++ b/libavcodec/msmpeg4.c
@@ -1902,7 +1902,7 @@ AVCodec ff_msmpeg4v1_decoder = {
 NULL,
 ff_h263_decode_end,
 ff_h263_decode_frame,
-CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1,
+CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_EXPERIMENTAL,
 .max_lowres= 3,
 .long_name= NULL_IF_CONFIG_SMALL("MPEG-4 part 2 Microsoft variant version 
1"),
 .pix_fmts= ff_pixfmt_list_420,
-- 
1.7.5.1

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 01/21] configure: sort filter deps entries

2011-05-11 Thread Anton Khirnov
From: Stefano Sabatini 

Signed-off-by: Anton Khirnov 
---
 configure |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/configure b/configure
index 955a568..ac2a7eb 100755
--- a/configure
+++ b/configure
@@ -1467,8 +1467,8 @@ drawtext_filter_deps="libfreetype"
 frei0r_filter_deps="frei0r dlopen strtok_r"
 frei0r_src_filter_deps="frei0r dlopen strtok_r"
 hqdn3d_filter_deps="gpl"
-scale_filter_deps="swscale"
 ocv_filter_deps="libopencv"
+scale_filter_deps="swscale"
 yadif_filter_deps="gpl"
 
 # libraries
-- 
1.7.5.1

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 03/21] ffprobe: tweak error message in open_input_file()

2011-05-11 Thread Anton Khirnov
From: Stefano Sabatini 

Replace "codec (id=%d)" with "codec with id %d", slightly more
readable.

Signed-off-by: Anton Khirnov 
---
 ffprobe.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/ffprobe.c b/ffprobe.c
index 6e26c11..b5d19f0 100644
--- a/ffprobe.c
+++ b/ffprobe.c
@@ -285,7 +285,7 @@ static int open_input_file(AVFormatContext **fmt_ctx_ptr, 
const char *filename)
 AVCodec *codec;
 
 if (!(codec = avcodec_find_decoder(stream->codec->codec_id))) {
-fprintf(stderr, "Unsupported codec (id=%d) for input stream %d\n",
+fprintf(stderr, "Unsupported codec with id %d for input stream 
%d\n",
 stream->codec->codec_id, stream->index);
 } else if (avcodec_open(stream->codec, codec) < 0) {
 fprintf(stderr, "Error while opening codec for input stream %d\n",
-- 
1.7.5.1

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 2/2] ffplay: remove audio_write_get_buf_size() forward declaration

2011-05-11 Thread Anton Khirnov
On Wed, 11 May 2011 14:00:06 -0700, Alex Converse  wrote:
> From: Stefano Sabatini 
> 
> Move up the definition of audio_write_get_buf_size(), so that it is
> defined before it is used. Simplify.
> (cherry picked from commit 8776f3d22e401e30d17856e341f6cabbbefa92f7)
> ---
>  ffplay.c |   16 +++-
>  1 files changed, 7 insertions(+), 9 deletions(-)
> 
> diff --git a/ffplay.c b/ffplay.c
> index 07727b6..75b98d7 100644
> --- a/ffplay.c
> +++ b/ffplay.c
> @@ -220,7 +220,6 @@ typedef struct VideoState {
>  } VideoState;
>  
>  static void show_help(void);
> -static int audio_write_get_buf_size(VideoState *is);
>  
>  /* options specified by the user */
>  static AVInputFormat *file_iformat;
> @@ -770,6 +769,13 @@ static void video_image_display(VideoState *is)
>  }
>  }
>  
> +/* get the current audio output buffer size, in samples. With SDL, we
> +   cannot have a precise information */
> +static int audio_write_get_buf_size(VideoState *is)
> +{
> +return is->audio_buf_size - is->audio_buf_index;
> +}
> +
>  static inline int compute_mod(int a, int b)
>  {
>  a = a % b;
> @@ -2148,14 +2154,6 @@ static int audio_decode_frame(VideoState *is, double 
> *pts_ptr)
>  }
>  }
>  
> -/* get the current audio output buffer size, in samples. With SDL, we
> -   cannot have a precise information */
> -static int audio_write_get_buf_size(VideoState *is)
> -{
> -return is->audio_buf_size - is->audio_buf_index;
> -}
> -
> -
>  /* prepare a new audio buffer */
>  static void sdl_audio_callback(void *opaque, Uint8 *stream, int len)
>  {
> -- 
> 1.7.3.1
> 

Looks ok.

--
Anton Khirnov
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 10/18] ffmpeg: use parse_number_and_die() when it makes sense

2011-05-11 Thread Anton Khirnov
On Tue, 10 May 2011 09:29:47 +0200, Stefano Sabatini 
 wrote:
> On date Monday 2011-05-09 20:25:31 -0400, Ronald S. Bultje encoded:
> > Hi,
> > 
> > On Mon, May 9, 2011 at 7:09 PM, Stefano Sabatini
> >  wrote:
> > > On date Monday 2011-05-09 18:06:51 -0400, Ronald S. Bultje encoded:
> > >> Hi,
> > >>
> > >> On Mon, May 9, 2011 at 1:49 PM, Anton Khirnov  wrote:
> > >> > -static void opt_qscale(const char *arg)
> > >> > +static int opt_qscale(const char *opt, const char *arg)
> > >> > ??{
> > >> > - ?? ??video_qscale = atof(arg);
> > >> > - ?? ??if (video_qscale <= 0 ||
> > >> > - ?? ?? ?? ??video_qscale > 255) {
> > >> > + ?? ??video_qscale = parse_number_or_die(opt, arg, OPT_FLOAT, 0, 255);
> > >> > + ?? ??if (video_qscale <= 0 || video_qscale > 255) {
> > >> > ?? ?? ?? ?? fprintf(stderr, "qscale must be > 0.0 and <= 255\n");
> > >> > - ?? ?? ?? ??ffmpeg_exit(1);
> > >> > + ?? ?? ?? ??return AVERROR(EINVAL);
> > >> > ?? ?? }
> > >> > + ?? ??return 0;
> > >> > ??}
> > >>
> > >> Shouldn't it die already if outside the [0,255] range as per
> > >> parse_number_or_die?
> > >
> > > No parse_number_or_die(opt, arg, OPT_FLOAT, 0, 255) won't fail with
> > > 0.0, which is not a valid value. Alternatively maybe:
> > > parse_number_or_die(opt, arg, OPT_FLOAT, EPS, 255)
> 
> 
> > >
> > > but which is not very clear from the reporting point of view, or
> > > choose as minimum an arbitrary small number.
> > 
> > Your check post parse_number_or_die() has the same issue, no?
> 
> The post-check has the only objective of rejecting q == 0.
> 

Then it should do exactly that and not more, as that's confusing.


>From 387e115ac1d6e2efda4ee61f2b90cdaee4b4f0c9 Mon Sep 17 00:00:00 2001
From: Stefano Sabatini 
Date: Mon, 11 Apr 2011 13:16:07 +0200
Subject: [PATCH] ffmpeg: use parse_number_and_die() when it makes sense

Prefer parse_number_or_die() over atoi()/atol() parsing for the options:
-pass, -top, -vc, and -qscale.

Improve input validation.

Signed-off-by: Stefano Sabatini 
Signed-off-by: Anton Khirnov 
---
 ffmpeg.c |   39 ++-
 1 files changed, 18 insertions(+), 21 deletions(-)

diff --git a/ffmpeg.c b/ffmpeg.c
index 3ae8672..68a9ed5 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -2822,19 +2822,20 @@ static int opt_metadata(const char *opt, const char 
*arg)
 return 0;
 }
 
-static void opt_qscale(const char *arg)
+static int opt_qscale(const char *opt, const char *arg)
 {
-video_qscale = atof(arg);
-if (video_qscale <= 0 ||
-video_qscale > 255) {
+video_qscale = parse_number_or_die(opt, arg, OPT_FLOAT, 0, 255);
+if (video_qscale == 0)
 fprintf(stderr, "qscale must be > 0.0 and <= 255\n");
-ffmpeg_exit(1);
+return AVERROR(EINVAL);
 }
+return 0;
 }
 
-static void opt_top_field_first(const char *arg)
+static int opt_top_field_first(const char *opt, const char *arg)
 {
-top_field_first= atoi(arg);
+top_field_first = parse_number_or_die(opt, arg, OPT_INT, 0, 1);
+return 0;
 }
 
 static int opt_thread_count(const char *opt, const char *arg)
@@ -2876,9 +2877,10 @@ static int opt_audio_channels(const char *opt, const 
char *arg)
 return 0;
 }
 
-static void opt_video_channel(const char *arg)
+static int opt_video_channel(const char *opt, const char *arg)
 {
-video_channel = strtol(arg, NULL, 0);
+video_channel = parse_number_or_die(opt, arg, OPT_INT64, 0, INT_MAX);
+return 0;
 }
 
 static void opt_video_standard(const char *arg)
@@ -3860,15 +3862,10 @@ static void opt_output_file(const char *filename)
 }
 
 /* same option as mencoder */
-static void opt_pass(const char *pass_str)
+static int opt_pass(const char *opt, const char *arg)
 {
-int pass;
-pass = atoi(pass_str);
-if (pass != 1 && pass != 2) {
-fprintf(stderr, "pass number can be only 1 or 2\n");
-ffmpeg_exit(1);
-}
-do_pass = pass;
+do_pass = parse_number_or_die(opt, arg, OPT_INT, 1, 2);
+return 0;
 }
 
 static int64_t getutime(void)
@@ -4290,13 +4287,13 @@ static const OptionDef options[] = {
 { "intra", OPT_BOOL | OPT_EXPERT | OPT_VIDEO, {(void*)&intra_only}, "use 
only intra frames"},
 { "vn", OPT_BOOL | OPT_VIDEO, {(void*)&video_disable}, "disable video" },
 { "vdt", OPT_INT | HAS_ARG | OPT_EXPERT | OPT_VIDEO, 
{(void*)&video_discard}, "discard threshold", "n" },
-{ "qscale", HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)opt_qscale}, "use 
fixed video quantizer scale (VBR)", "q" },
+{ "qscale", HAS_ARG | OPT_FUNC2 | OPT_EXPERT | OPT_VIDEO, 
{(void*)opt_qscale}, "use fixed video quantizer scale (VBR)", "q" },
 { "rc_override", HAS_ARG | OPT_EXPERT | OPT_VIDEO, 
{(void*)opt_video_rc_override_string}, "rate control override for specific 
intervals", "override" },
 { "vcodec", HAS_ARG | OPT_VIDEO, {(void*)opt_video_codec}, "force video 
codec ('copy' to copy stream)", "codec" },
 { "me_threshold", HAS_ARG | OPT_FUNC2 | OPT_EXPERT | OPT_VIDEO, 
{(void*)opt_me_threshold}, "motion estimat

Re: [libav-devel] [PATCH 10/18] ffmpeg: use parse_number_and_die() when it makes sense

2011-05-11 Thread Anton Khirnov
On Mon, 9 May 2011 18:06:51 -0400, "Ronald S. Bultje"  
wrote:
> Hi,
> 
> On Mon, May 9, 2011 at 1:49 PM, Anton Khirnov  wrote:
> > -static void opt_qscale(const char *arg)
> > +static int opt_qscale(const char *opt, const char *arg)
> > ??{
> > - ?? ??video_qscale = atof(arg);
> > - ?? ??if (video_qscale <= 0 ||
> > - ?? ?? ?? ??video_qscale > 255) {
> > + ?? ??video_qscale = parse_number_or_die(opt, arg, OPT_FLOAT, 0, 255);
> > + ?? ??if (video_qscale <= 0 || video_qscale > 255) {
> > ?? ?? ?? ?? fprintf(stderr, "qscale must be > 0.0 and <= 255\n");
> > - ?? ?? ?? ??ffmpeg_exit(1);
> > + ?? ?? ?? ??return AVERROR(EINVAL);
> > ?? ?? }
> > + ?? ??return 0;
> > ??}
> 
> Shouldn't it die already if outside the [0,255] range as per
> parse_number_or_die?
> 
> > -static void opt_top_field_first(const char *arg)
> > +static int opt_top_field_first(const char *opt, const char *arg)
> > ??{
> > - ?? ??top_field_first= atoi(arg);
> > + ?? ??top_field_first = parse_number_or_die(opt, arg, OPT_INT, 0, 1);
> > + ?? ??return 0;
> > ??}
> >
> > ??static int opt_thread_count(const char *opt, const char *arg)
> > @@ -2886,9 +2887,10 @@ static int opt_audio_channels(const char *opt, const 
> > char *arg)
> > ?? ?? return 0;
> > ??}
> >
> > -static void opt_video_channel(const char *arg)
> > +static int opt_video_channel(const char *opt, const char *arg)
> > ??{
> > - ?? ??video_channel = strtol(arg, NULL, 0);
> > + ?? ??video_channel = parse_number_or_die(opt, arg, OPT_INT64, 0, INT_MAX);
> > + ?? ??return 0;
> > ??}
> >
> > ??static void opt_video_standard(const char *arg)
> > @@ -3870,15 +3872,10 @@ static void opt_output_file(const char *filename)
> > ??}
> >
> > ??/* same option as mencoder */
> > -static void opt_pass(const char *pass_str)
> > +static int opt_pass(const char *opt, const char *arg)
> > ??{
> > - ?? ??int pass;
> > - ?? ??pass = atoi(pass_str);
> > - ?? ??if (pass != 1 && pass != 2) {
> > - ?? ?? ?? ??fprintf(stderr, "pass number can be only 1 or 2\n");
> > - ?? ?? ?? ??ffmpeg_exit(1);
> > - ?? ??}
> > - ?? ??do_pass = pass;
> > + ?? ??do_pass = parse_number_or_die(opt, arg, OPT_INT, 1, 2);
> > + ?? ??return 0;
> > ??}
> >
> > ??static int64_t getutime(void)
> > @@ -4300,13 +4297,13 @@ static const OptionDef options[] = {
> > ?? ?? { "intra", OPT_BOOL | OPT_EXPERT | OPT_VIDEO, {(void*)&intra_only}, 
> > "use only intra frames"},
> > ?? ?? { "vn", OPT_BOOL | OPT_VIDEO, {(void*)&video_disable}, "disable 
> > video" },
> > ?? ?? { "vdt", OPT_INT | HAS_ARG | OPT_EXPERT | OPT_VIDEO, 
> > {(void*)&video_discard}, "discard threshold", "n" },
> > - ?? ??{ "qscale", HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)opt_qscale}, 
> > "use fixed video quantizer scale (VBR)", "q" },
> > + ?? ??{ "qscale", HAS_ARG | OPT_FUNC2 | OPT_EXPERT | OPT_VIDEO, 
> > {(void*)opt_qscale}, "use fixed video quantizer scale (VBR)", "q" },
> > ?? ?? { "rc_override", HAS_ARG | OPT_EXPERT | OPT_VIDEO, 
> > {(void*)opt_video_rc_override_string}, "rate control override for specific 
> > intervals", "override" },
> > ?? ?? { "vcodec", HAS_ARG | OPT_VIDEO, {(void*)opt_video_codec}, "force 
> > video codec ('copy' to copy stream)", "codec" },
> > ?? ?? { "me_threshold", HAS_ARG | OPT_FUNC2 | OPT_EXPERT | OPT_VIDEO, 
> > {(void*)opt_me_threshold}, "motion estimaton threshold", ??"threshold" },
> > ?? ?? { "sameq", OPT_BOOL | OPT_VIDEO, {(void*)&same_quality},
> > ?? ?? ?? "use same quantizer as source (implies VBR)" },
> > - ?? ??{ "pass", HAS_ARG | OPT_VIDEO, {(void*)&opt_pass}, "select the pass 
> > number (1 or 2)", "n" },
> > + ?? ??{ "pass", HAS_ARG | OPT_FUNC2 | OPT_VIDEO, {(void*)opt_pass}, 
> > "select the pass number (1 or 2)", "n" },
> > ?? ?? { "passlogfile", HAS_ARG | OPT_STRING | OPT_VIDEO, 
> > {(void*)&pass_logfilename_prefix}, "select two pass log file name prefix", 
> > "prefix" },
> > ?? ?? { "deinterlace", OPT_BOOL | OPT_EXPERT | OPT_VIDEO, 
> > {(void*)&do_deinterlace},
> > ?? ?? ?? "deinterlace pictures" },
> > @@ -4318,7 +4315,7 @@ static const OptionDef options[] = {
> > ??#endif
> > ?? ?? { "intra_matrix", HAS_ARG | OPT_EXPERT | OPT_VIDEO, 
> > {(void*)opt_intra_matrix}, "specify intra matrix coeffs", "matrix" },
> > ?? ?? { "inter_matrix", HAS_ARG | OPT_EXPERT | OPT_VIDEO, 
> > {(void*)opt_inter_matrix}, "specify inter matrix coeffs", "matrix" },
> > - ?? ??{ "top", HAS_ARG | OPT_EXPERT | OPT_VIDEO, 
> > {(void*)opt_top_field_first}, "top=1/bottom=0/auto=-1 field first", "" },
> > + ?? ??{ "top", HAS_ARG | OPT_FUNC2 | OPT_EXPERT | OPT_VIDEO, 
> > {(void*)opt_top_field_first}, "top=1/bottom=0/auto=-1 field first", "" },
> > ?? ?? { "dc", OPT_INT | HAS_ARG | OPT_EXPERT | OPT_VIDEO, 
> > {(void*)&intra_dc_precision}, "intra_dc_precision", "precision" },
> > ?? ?? { "vtag", OPT_FUNC2 | HAS_ARG | OPT_EXPERT | OPT_VIDEO, 
> > {(void*)opt_codec_tag}, "force video tag/fourcc", "fourcc/tag" },
> > ?? ?? { "newvideo", OPT_VIDEO | OPT_FUNC2, {(void*)opt_new_stream}, "add a 
> > new video stream to the current output stream" },
> > @

[libav-devel] [PATCH] ffmpeg: factorize quality calculation

2011-05-11 Thread Anton Khirnov
From: Michael Niedermayer 

Calculate quality value once per stream in print_report().
Also fix segfault, as coded_frame can be NULL.

Signed-off-by: Anton Khirnov 
---
 ffmpeg.c |   13 ++---
 1 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/ffmpeg.c b/ffmpeg.c
index b691a10..3ae8672 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -1326,26 +1326,25 @@ static void print_report(AVFormatContext **output_files,
 ti1 = 1e10;
 vid = 0;
 for(i=0;ist->codec;
+if (!ost->st->stream_copy && enc->coded_frame)
+q = enc->coded_frame->quality/(float)FF_QP2LAMBDA;
 if (vid && enc->codec_type == AVMEDIA_TYPE_VIDEO) {
-snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "q=%2.1f ",
- !ost->st->stream_copy ?
- enc->coded_frame->quality/(float)FF_QP2LAMBDA : -1);
+snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "q=%2.1f ", 
q);
 }
 if (!vid && enc->codec_type == AVMEDIA_TYPE_VIDEO) {
 float t = (av_gettime()-timer_start) / 100.0;
 
 frame_number = ost->frame_number;
 snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "frame=%5d 
fps=%3d q=%3.1f ",
- frame_number, (t>1)?(int)(frame_number/t+0.5) : 0,
- !ost->st->stream_copy ?
- enc->coded_frame->quality/(float)FF_QP2LAMBDA : -1);
+ frame_number, (t>1)?(int)(frame_number/t+0.5) : 0, q);
 if(is_last_report)
 snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "L");
 if(qp_hist){
 int j;
-int qp= lrintf(enc->coded_frame->quality/(float)FF_QP2LAMBDA);
+int qp = lrintf(q);
 if(qp>=0 && qphttps://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH] ffmpeg.c: fix seting of decode_interrupt_cb().

2011-05-11 Thread Anton Khirnov
From: Michael Niedermayer 

Signed-off-by: Anton Khirnov 
---
 ffmpeg.c |5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/ffmpeg.c b/ffmpeg.c
index 5ab3c7a..afd4374 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -2460,14 +2460,13 @@ static int transcode(AVFormatContext **output_files,
 print_sdp(output_files, nb_output_files);
 }
 
-if (!using_stdin && verbose >= 0) {
+if (verbose >= 0)
 #if HAVE_KBHIT
 fprintf(stderr, "Press [q] to stop encoding\n");
 #else
 fprintf(stderr, "Press ctrl-c to stop encoding\n");
 #endif
-avio_set_interrupt_cb(decode_interrupt_cb);
-}
+avio_set_interrupt_cb(decode_interrupt_cb);
 term_init();
 
 timer_start = av_gettime();
-- 
1.7.5.1

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH] MP3 file contains the string NSVs, the NSV probe will think it is a NSV file instead of a MP3 file. Check for 0xBEEF after a Video/Audio chunck for more accuracy

2011-05-11 Thread Thierry Foucu
---
 libavformat/nsvdec.c |   20 +---
 1 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/libavformat/nsvdec.c b/libavformat/nsvdec.c
index b70d3b9..8f55bbc 100644
--- a/libavformat/nsvdec.c
+++ b/libavformat/nsvdec.c
@@ -737,6 +737,9 @@ static int nsv_read_close(AVFormatContext *s)
 static int nsv_probe(AVProbeData *p)
 {
 int i;
+int score;
+int vsize, asize, auxcount;
+score = 0;
 av_dlog(NULL, "nsv_probe(), buf_size %d\n", p->buf_size);
 /* check file header */
 /* streamed files might not have any header */
@@ -749,14 +752,25 @@ static int nsv_probe(AVProbeData *p)
 /* sometimes even the first header is at 9KB or something :^) */
 for (i = 1; i < p->buf_size - 3; i++) {
 if (p->buf[i+0] == 'N' && p->buf[i+1] == 'S' &&
-p->buf[i+2] == 'V' && p->buf[i+3] == 's')
-return AVPROBE_SCORE_MAX-20;
+p->buf[i+2] == 'V' && p->buf[i+3] == 's') {
+score = AVPROBE_SCORE_MAX/5;
+/* Get the chunk size and check if at the end we are getting 
0xBEEF */
+auxcount = p->buf[i+19];
+vsize = p->buf[i+20]  | p->buf[i+21] << 8;
+asize = p->buf[i+22]  | p->buf[i+23] << 8;
+vsize = (vsize << 4) | (auxcount >> 4);
+if ((asize + vsize + i + 23) <  p->buf_size - 2) {
+if (p->buf[i+23+asize+vsize+1] == 0xEF &&
+p->buf[i+23+asize+vsize+2] == 0xBE)
+return AVPROBE_SCORE_MAX-20;
+}
+}
 }
 /* so we'll have more luck on extension... */
 if (av_match_ext(p->filename, "nsv"))
 return AVPROBE_SCORE_MAX/2;
 /* FIXME: add mime-type check */
-return 0;
+return score;
 }
 
 AVInputFormat ff_nsv_demuxer = {
-- 
1.7.3.1

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] tiff: add support to TIFF_SAMPLES_PER_PIXEL case in tiff_decode_tag()

2011-05-11 Thread Stefano Sabatini
On date Wednesday 2011-05-11 13:22:07 +0200, Kostya encoded:
> On Wed, May 11, 2011 at 01:10:19PM +0200, Stefano Sabatini wrote:
[...]
> > > You're right, and having init_image() after all those tags are parsed is
> > > better (I cannot argue with that), but I still think it's better to 
> > > operate
> > > with sum of pixels per component from the beginning, so the flow would be:
> > > 
> > > => BitsPerSample = { 8 }
> > > => SamplesPerPixel = 3
> > > bpp = 8, bppcount = 1, spp = 3
> > > 
> > > since bppcount == 1 multiply bpp by spp, so final bpp = 8 * 3 = 24
> > > 
> > > => BitsPerSample = { 8, 8, 8 }
> > > => no SamplesPerPixel or = 3
> > > 
> > > bpp = 24, bppcount = 3, spp = 1 (default setting) or 3
> > > since bppcount != 1, ignore spp (optionally check if bppcount != 1 && spp 
> > > !=
> > >  bppcount and complain then)
> > > final bpp is unchanged and is 24
> > > 
> > > What do you think?
> > 
> > Still doesn't work in the illegal case when we have more than one
> > SamplesPerPixel tags, but that's not a very likely case, so if you
> > prefer this approach I'm fine with it.
> 

> Probably it's better to implement generic checking for unsorted and/or
> repeating tags anyway by keeping track of last tag id (and if it's unsorted
> then it's incorrect format no matter how many identical tags are in that
> file).

Even in this case it would be best practice to issue a warning and try
to decode the file properly anyway, indeed there is nothing
intrinsically wrong in unsorted or duplicated tags, even if they're
not allowed by the specs.

Patch updated according to this logic, but I want to note that I
consider the previous approach more robust and thus preferable
(doesn't assume tags unicity and a specific order, avoids
SamplesPerPixel/BitsPerSample coupling and the need for custom
checks).

Anyway the new patch is simpler, and the other changes can be easily
applied on top of it, so I'm fine with this patch.
>From 76d7ee6b0511016bff90b17d919b2b78518e741c Mon Sep 17 00:00:00 2001
From: Stefano Sabatini 
Date: Mon, 9 May 2011 12:51:24 +0200
Subject: [PATCH] tiff: add support to TIFF_SAMPLES_PER_PIXEL case in tiff_decode_tag()

Format detection and internal frame initialization is moved to a
separate init_image() function, which is called when all the tags have
been read, and so both BitsPerSample and SamplesPerPixel information
has been collected.

Fix decoding of file 11.tiff, trac issue number #167.

Based on a patch by Kostya Shishkov .
---
 libavcodec/tiff.c |  118 -
 1 files changed, 62 insertions(+), 56 deletions(-)

diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index f252913..63e3a7d 100644
--- a/libavcodec/tiff.c
+++ b/libavcodec/tiff.c
@@ -38,7 +38,7 @@ typedef struct TiffContext {
 AVFrame picture;
 
 int width, height;
-unsigned int bpp;
+unsigned int bpp, bppcount;
 int le;
 enum TiffCompr compr;
 int invert;
@@ -208,6 +208,53 @@ static int tiff_unpack_strip(TiffContext *s, uint8_t* dst, int stride, const uin
 return 0;
 }
 
+static int init_image(TiffContext *s)
+{
+int i, ret;
+uint32_t *pal;
+
+switch (s->bpp*10 + s->bppcount) {
+case 11:
+s->avctx->pix_fmt = PIX_FMT_MONOBLACK;
+break;
+case 81:
+s->avctx->pix_fmt = PIX_FMT_PAL8;
+break;
+case 243:
+s->avctx->pix_fmt = PIX_FMT_RGB24;
+break;
+case 161:
+s->avctx->pix_fmt = PIX_FMT_GRAY16BE;
+break;
+case 324:
+s->avctx->pix_fmt = PIX_FMT_RGBA;
+break;
+case 483:
+s->avctx->pix_fmt = s->le ? PIX_FMT_RGB48LE : PIX_FMT_RGB48BE;
+break;
+default:
+av_log(s->avctx, AV_LOG_ERROR, "This format is not supported (bpp=%d, bppcount=%d)\n", s->bpp, s->bppcount);
+return AVERROR_INVALIDDATA;
+}
+if (s->width != s->avctx->width || s->height != s->avctx->height) {
+if ((ret = av_image_check_size(s->width, s->height, 0, s->avctx)) < 0)
+return ret;
+avcodec_set_dimensions(s->avctx, s->width, s->height);
+}
+if (s->picture.data[0])
+s->avctx->release_buffer(s->avctx, &s->picture);
+if ((ret = s->avctx->get_buffer(s->avctx, &s->picture)) < 0) {
+av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed\n");
+return ret;
+}
+if (s->bpp == 8 && s->picture.data[1]){
+/* make default grayscale pal */
+pal = (uint32_t *) s->picture.data[1];
+for (i = 0; i < 256; i++)
+pal[i] = i * 0x010101;
+}
+return 0;
+}
 
 static int tiff_decode_tag(TiffContext *s, const uint8_t *start, const uint8_t *buf, const uint8_t *end_buf)
 {
@@ -261,6 +308,7 @@ static int tiff_decode_tag(TiffContext *s, const uint8_t *start, const uint8_t *
 s->height = value;
 break;
 case TIFF_BPP:
+s->bppcount = count;
 if(count > 4){
 av_log(s->avctx, AV_LOG_ERROR, "

[libav-devel] [PATCH 3/3] Restructure video filter implementation in ffmpeg.c.

2011-05-11 Thread Alex Converse
From: Michael Niedermayer 

This fixes several bugs like multiple outputs and -aspect mixed with -vf

(cherry picked from commit 1762d9ced70ccc46c5d3e5d64e56a48d0fbbd4f7)
(cherry picked from commit a7844c580d83d8466c161a0e3979b3902d0d9100)
---
 ffmpeg.c |  139 +++--
 1 files changed, 80 insertions(+), 59 deletions(-)

diff --git a/ffmpeg.c b/ffmpeg.c
index 5ab3c7a..448de7c 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -167,7 +167,6 @@ static int loop_output = AVFMT_NOOUTPUTLOOP;
 static int qp_hist = 0;
 #if CONFIG_AVFILTER
 static char *vfilters = NULL;
-static AVFilterGraph *graph = NULL;
 #endif
 
 static int intra_only = 0;
@@ -298,6 +297,14 @@ typedef struct AVOutputStream {
 AVFifoBuffer *fifo; /* for compression: one audio fifo per codec */
 FILE *logfile;
 
+#if CONFIG_AVFILTER
+AVFilterContext *output_video_filter;
+AVFilterContext *input_video_filter;
+AVFilterBufferRef *picref;
+char *avfilter;
+AVFilterGraph *graph;
+#endif
+
int sws_flags;
 } AVOutputStream;
 
@@ -321,11 +328,8 @@ typedef struct AVInputStream {
 int showed_multi_packet_warning;
 int is_past_recording_time;
 #if CONFIG_AVFILTER
-AVFilterContext *output_video_filter;
-AVFilterContext *input_video_filter;
 AVFrame *filter_frame;
 int has_filter_frame;
-AVFilterBufferRef *picref;
 #endif
 } AVInputStream;
 
@@ -349,7 +353,7 @@ static int configure_video_filters(AVInputStream *ist, 
AVOutputStream *ost)
 char args[255];
 int ret;
 
-graph = avfilter_graph_alloc();
+ost->graph = avfilter_graph_alloc();
 
 if (ist->st->sample_aspect_ratio.num){
 sample_aspect_ratio = ist->st->sample_aspect_ratio;
@@ -360,15 +364,15 @@ static int configure_video_filters(AVInputStream *ist, 
AVOutputStream *ost)
  ist->st->codec->height, ist->st->codec->pix_fmt, 1, AV_TIME_BASE,
  sample_aspect_ratio.num, sample_aspect_ratio.den);
 
-ret = avfilter_graph_create_filter(&ist->input_video_filter, 
avfilter_get_by_name("buffer"),
-   "src", args, NULL, graph);
+ret = avfilter_graph_create_filter(&ost->input_video_filter, 
avfilter_get_by_name("buffer"),
+   "src", args, NULL, ost->graph);
 if (ret < 0)
 return ret;
-ret = avfilter_graph_create_filter(&ist->output_video_filter, &ffsink,
-   "out", NULL, &ffsink_ctx, graph);
+ret = avfilter_graph_create_filter(&ost->output_video_filter, &ffsink,
+   "out", NULL, &ffsink_ctx, ost->graph);
 if (ret < 0)
 return ret;
-last_filter = ist->input_video_filter;
+last_filter = ost->input_video_filter;
 
 if (codec->width  != icodec->width || codec->height != icodec->height) {
 snprintf(args, 255, "%d:%d:flags=0x%X",
@@ -376,7 +380,7 @@ static int configure_video_filters(AVInputStream *ist, 
AVOutputStream *ost)
  codec->height,
  ost->sws_flags);
 if ((ret = avfilter_graph_create_filter(&filter, 
avfilter_get_by_name("scale"),
-NULL, args, NULL, graph)) < 0)
+NULL, args, NULL, ost->graph)) 
< 0)
 return ret;
 if ((ret = avfilter_link(last_filter, 0, filter, 0)) < 0)
 return ret;
@@ -384,9 +388,9 @@ static int configure_video_filters(AVInputStream *ist, 
AVOutputStream *ost)
 }
 
 snprintf(args, sizeof(args), "flags=0x%X", ost->sws_flags);
-graph->scale_sws_opts = av_strdup(args);
+ost->graph->scale_sws_opts = av_strdup(args);
 
-if (vfilters) {
+if (ost->avfilter) {
 AVFilterInOut *outputs = av_malloc(sizeof(AVFilterInOut));
 AVFilterInOut *inputs  = av_malloc(sizeof(AVFilterInOut));
 
@@ -396,25 +400,25 @@ static int configure_video_filters(AVInputStream *ist, 
AVOutputStream *ost)
 outputs->next= NULL;
 
 inputs->name= av_strdup("out");
-inputs->filter_ctx = ist->output_video_filter;
+inputs->filter_ctx = ost->output_video_filter;
 inputs->pad_idx = 0;
 inputs->next= NULL;
 
-if ((ret = avfilter_graph_parse(graph, vfilters, inputs, outputs, 
NULL)) < 0)
+if ((ret = avfilter_graph_parse(ost->graph, ost->avfilter, inputs, 
outputs, NULL)) < 0)
 return ret;
-av_freep(&vfilters);
+av_freep(&ost->avfilter);
 } else {
-if ((ret = avfilter_link(last_filter, 0, ist->output_video_filter, 0)) 
< 0)
+if ((ret = avfilter_link(last_filter, 0, ost->output_video_filter, 0)) 
< 0)
 return ret;
 }
 
-if ((ret = avfilter_graph_config(graph, NULL)) < 0)
+if ((ret = avfilter_graph_config(ost->graph, NULL)) < 0)
 return ret;
 
-codec->width  = ist->output_video_filter->inputs[0]->w;
-codec->height = ist->out

Re: [libav-devel] [RFC] fix swscale for 9/10bit

2011-05-11 Thread Aℓex Converse
On Wed, May 11, 2011 at 10:20 AM, Ronald S. Bultje  wrote:
> Hi again,
>
> On Wed, May 11, 2011 at 12:07 PM, Ronald S. Bultje  wrote:
>> On Wed, May 11, 2011 at 11:59 AM, Ronald S. Bultje  
>> wrote:
>>> On Wed, May 11, 2011 at 11:26 AM, Ronald S. Bultje  
>>> wrote:
 attached is a RFC for fixing SWS for 9/10bit, as output by H264. It
 takes endianness in account and does some other stuff. As you can see,
 this stuff quickly gets hideous (e.g. planarCopyWrapper is a mess), so
 I'd like some advice on how people think we should do this.

 We need this fix so we can convert 10bitBE to 10bitLE and thereby fix
 10bit H264 on BE systems (e.g. PPC), which are now correct except that
 byte ordering for each word is inverted.
>>>
>>> Attached is one more that should fix fate (at least 10bit h264) on BE
>>> systems, along with the swscale hackery.
>>
>> And one more adding a missing if. We need someone to write tests for
>> these various colorspace conversions...
>
> And this one has fate tests added so that it doesn't break. I've
> tested all YUV8/9/10/16/RGB <-> 10/9bit conversions and they all
> produce images that are visibly correct, so all codepaths should be
> fine.
>
> Ronald
>

Be aware that the pixfmt.h changes break ABI.

On my limited best effort basis this seems ok.
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 2/2] ac3enc: put the counting of stereo rematrixing bits in the same place to make the code easier to understand.

2011-05-11 Thread Ronald S. Bultje
Hi,

On Wed, May 11, 2011 at 2:47 PM, Justin Ruggles
 wrote:
> On 05/01/2011 01:35 PM, Justin Ruggles wrote:
>> ---
>>  libavcodec/ac3enc.c |   11 ---
>>  1 files changed, 4 insertions(+), 7 deletions(-)
>
> ping.

OK.

Ronald
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 1/2] ac3enc: clean up count_frame_bits() and count_frame_bits_fixed()

2011-05-11 Thread Ronald S. Bultje
Hi,

On Wed, May 11, 2011 at 2:47 PM, Justin Ruggles
 wrote:
> On 05/01/2011 01:35 PM, Justin Ruggles wrote:
>> ---
>>  libavcodec/ac3enc.c |   66 
>> +++---
>>  1 files changed, 46 insertions(+), 20 deletions(-)
>
> ping

Looks OK.

Ronald
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 1/2] lavfi: print key-frame and picture type information in ff_dlog_ref()

2011-05-11 Thread Alex Converse
From: Stefano Sabatini 

Signed-off-by: Stefano Sabatini 
(cherry picked from commit f7bdffb09da597c5d6afff5359523370470ad072)
---
 libavfilter/avfilter.c |6 --
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index 82350d1..0291503 100644
--- a/libavfilter/avfilter.c
+++ b/libavfilter/avfilter.c
@@ -237,11 +237,13 @@ static void ff_dlog_ref(void *ctx, AVFilterBufferRef 
*ref, int end)
 ref->pts, ref->pos);
 
 if (ref->video) {
-av_dlog(ctx, " a:%d/%d s:%dx%d i:%c",
+av_dlog(ctx, " a:%d/%d s:%dx%d i:%c iskey:%d type:%c",
 ref->video->pixel_aspect.num, ref->video->pixel_aspect.den,
 ref->video->w, ref->video->h,
 !ref->video->interlaced ? 'P' : /* Progressive  */
-ref->video->top_field_first ? 'T' : 'B');   /* Top / Bottom */
+ref->video->top_field_first ? 'T' : 'B',/* Top / Bottom */
+ref->video->key_frame,
+av_get_picture_type_char(ref->video->pict_type));
 }
 if (ref->audio) {
 av_dlog(ctx, " cl:%"PRId64"d sn:%d s:%d sr:%d p:%d",
-- 
1.7.3.1

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 2/2] ffplay: remove audio_write_get_buf_size() forward declaration

2011-05-11 Thread Alex Converse
From: Stefano Sabatini 

Move up the definition of audio_write_get_buf_size(), so that it is
defined before it is used. Simplify.
(cherry picked from commit 8776f3d22e401e30d17856e341f6cabbbefa92f7)
---
 ffplay.c |   16 +++-
 1 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/ffplay.c b/ffplay.c
index 07727b6..75b98d7 100644
--- a/ffplay.c
+++ b/ffplay.c
@@ -220,7 +220,6 @@ typedef struct VideoState {
 } VideoState;
 
 static void show_help(void);
-static int audio_write_get_buf_size(VideoState *is);
 
 /* options specified by the user */
 static AVInputFormat *file_iformat;
@@ -770,6 +769,13 @@ static void video_image_display(VideoState *is)
 }
 }
 
+/* get the current audio output buffer size, in samples. With SDL, we
+   cannot have a precise information */
+static int audio_write_get_buf_size(VideoState *is)
+{
+return is->audio_buf_size - is->audio_buf_index;
+}
+
 static inline int compute_mod(int a, int b)
 {
 a = a % b;
@@ -2148,14 +2154,6 @@ static int audio_decode_frame(VideoState *is, double 
*pts_ptr)
 }
 }
 
-/* get the current audio output buffer size, in samples. With SDL, we
-   cannot have a precise information */
-static int audio_write_get_buf_size(VideoState *is)
-{
-return is->audio_buf_size - is->audio_buf_index;
-}
-
-
 /* prepare a new audio buffer */
 static void sdl_audio_callback(void *opaque, Uint8 *stream, int len)
 {
-- 
1.7.3.1

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [RFC] Fix asfdec "regression"

2011-05-11 Thread Vladimir Pantelic

On 05/11/2011 07:54 PM, Uoti Urpala wrote:

On Tue, 2011-05-10 at 15:02 +0200, Vladimir Pantelic wrote:

Uoti Urpala wrote:

Disabling the utils.c fallback for asf should be enough. I'm not posting



attached are 2 patches that both solve the issue, one makes ASF cleanup
after util.c falls back to binary search,


This makes little sense IMO. The seek method of the asf demuxer already
uses binary seeking machinery itself when appropriate. Trying to support
outside binary search calls that are known to have only negative effects
seems wrong.


atm the asf logic is:

if( index_exists ) {
index = search_by_index()   
if( index < 0 ) {
return -1;
}
// index success
} else {
try binary search
...
}

maybe it should be:

if( index_exists ) {
index = search_by_index()   
if( index >= 0 ) {
// index success
...
return ...;
}
}
// no index or index search fail, try binary
try binary search
...

and of course, no more fallback from util.c as in patch #2


  the other one introduces a new
flag that prevents util.c from doing so.


But it still calls av_seek_frame_generic(). Is that really any more
appropriate, even if it doesn't happen to trigger visible problems now?


right, I was about to also add a AVFMT_NOGENSEARCH flag but then left it
out to have a "minimal" patch. the generic search again falls back to 
the index and fails as much as the index search inside asf...


or one flag that disables both fallbacks.

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 1/2] mdec.c: fix overread.

2011-05-11 Thread Ronald S. Bultje
Hi,

On Wed, May 11, 2011 at 3:00 PM, Justin Ruggles
 wrote:
> On 05/11/2011 02:49 PM, Ronald S. Bultje wrote:
>> On Wed, May 11, 2011 at 2:46 PM, Justin Ruggles
>>  wrote:
>>> On 05/10/2011 11:29 AM, Ronald S. Bultje wrote:
 ---
  libavcodec/mdec.c |    3 ++-
  1 files changed, 2 insertions(+), 1 deletions(-)

 diff --git a/libavcodec/mdec.c b/libavcodec/mdec.c
 index 545b919..9b6e6b6 100644
 --- a/libavcodec/mdec.c
 +++ b/libavcodec/mdec.c
 @@ -125,7 +125,8 @@ static inline int decode_mb(MDECContext *a, DCTELEM 
 block[6][64]){
      a->dsp.clear_blocks(block[0]);

      for(i=0; i<6; i++){
 -        if( mdec_decode_block_intra(a, block[ block_index[i] ], 
 block_index[i]) < 0)
 +        if( mdec_decode_block_intra(a, block[ block_index[i] ], 
 block_index[i]) < 0 ||
 +            get_bits_left(&a->gb) < 0)
              return -1;
      }
      return 0;
>>>
>>> If get_bits_left() < 0 doesn't that mean that it has already overread?
>>> How much can it have possibly overread by at this point, and is that <=
>>> FF_INPUT_BUFFER_PADDING_SIZE?
>>
>> When I had a look at it, it seemed to always be <
>> FF_INPUT_BUFFER_PADDING_SIZE, yes.
>
> probably ok then. was that a fuzzed file or just some random sample?

It's the fate sample...

Ronald
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 1/2] mdec.c: fix overread.

2011-05-11 Thread Justin Ruggles
On 05/11/2011 02:49 PM, Ronald S. Bultje wrote:

> Hi,
> 
> On Wed, May 11, 2011 at 2:46 PM, Justin Ruggles
>  wrote:
>> On 05/10/2011 11:29 AM, Ronald S. Bultje wrote:
>>> ---
>>>  libavcodec/mdec.c |3 ++-
>>>  1 files changed, 2 insertions(+), 1 deletions(-)
>>>
>>> diff --git a/libavcodec/mdec.c b/libavcodec/mdec.c
>>> index 545b919..9b6e6b6 100644
>>> --- a/libavcodec/mdec.c
>>> +++ b/libavcodec/mdec.c
>>> @@ -125,7 +125,8 @@ static inline int decode_mb(MDECContext *a, DCTELEM 
>>> block[6][64]){
>>>  a->dsp.clear_blocks(block[0]);
>>>
>>>  for(i=0; i<6; i++){
>>> -if( mdec_decode_block_intra(a, block[ block_index[i] ], 
>>> block_index[i]) < 0)
>>> +if( mdec_decode_block_intra(a, block[ block_index[i] ], 
>>> block_index[i]) < 0 ||
>>> +get_bits_left(&a->gb) < 0)
>>>  return -1;
>>>  }
>>>  return 0;
>>
>> If get_bits_left() < 0 doesn't that mean that it has already overread?
>> How much can it have possibly overread by at this point, and is that <=
>> FF_INPUT_BUFFER_PADDING_SIZE?
> 
> When I had a look at it, it seemed to always be <
> FF_INPUT_BUFFER_PADDING_SIZE, yes.


probably ok then. was that a fuzzed file or just some random sample?

-Justin
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 1/2] mdec.c: fix overread.

2011-05-11 Thread Ronald S. Bultje
Hi,

On Wed, May 11, 2011 at 2:46 PM, Justin Ruggles
 wrote:
> On 05/10/2011 11:29 AM, Ronald S. Bultje wrote:
>> ---
>>  libavcodec/mdec.c |    3 ++-
>>  1 files changed, 2 insertions(+), 1 deletions(-)
>>
>> diff --git a/libavcodec/mdec.c b/libavcodec/mdec.c
>> index 545b919..9b6e6b6 100644
>> --- a/libavcodec/mdec.c
>> +++ b/libavcodec/mdec.c
>> @@ -125,7 +125,8 @@ static inline int decode_mb(MDECContext *a, DCTELEM 
>> block[6][64]){
>>      a->dsp.clear_blocks(block[0]);
>>
>>      for(i=0; i<6; i++){
>> -        if( mdec_decode_block_intra(a, block[ block_index[i] ], 
>> block_index[i]) < 0)
>> +        if( mdec_decode_block_intra(a, block[ block_index[i] ], 
>> block_index[i]) < 0 ||
>> +            get_bits_left(&a->gb) < 0)
>>              return -1;
>>      }
>>      return 0;
>
> If get_bits_left() < 0 doesn't that mean that it has already overread?
> How much can it have possibly overread by at this point, and is that <=
> FF_INPUT_BUFFER_PADDING_SIZE?

When I had a look at it, it seemed to always be <
FF_INPUT_BUFFER_PADDING_SIZE, yes.

Ronald
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 2/2] ac3enc: put the counting of stereo rematrixing bits in the same place to make the code easier to understand.

2011-05-11 Thread Justin Ruggles
On 05/01/2011 01:35 PM, Justin Ruggles wrote:

> ---
>  libavcodec/ac3enc.c |   11 ---
>  1 files changed, 4 insertions(+), 7 deletions(-)


ping.
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 1/2] ac3enc: clean up count_frame_bits() and count_frame_bits_fixed()

2011-05-11 Thread Justin Ruggles
On 05/01/2011 01:35 PM, Justin Ruggles wrote:

> ---
>  libavcodec/ac3enc.c |   66 +++---
>  1 files changed, 46 insertions(+), 20 deletions(-)


ping
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 1/2] mdec.c: fix overread.

2011-05-11 Thread Justin Ruggles
On 05/10/2011 11:29 AM, Ronald S. Bultje wrote:

> ---
>  libavcodec/mdec.c |3 ++-
>  1 files changed, 2 insertions(+), 1 deletions(-)
> 
> diff --git a/libavcodec/mdec.c b/libavcodec/mdec.c
> index 545b919..9b6e6b6 100644
> --- a/libavcodec/mdec.c
> +++ b/libavcodec/mdec.c
> @@ -125,7 +125,8 @@ static inline int decode_mb(MDECContext *a, DCTELEM 
> block[6][64]){
>  a->dsp.clear_blocks(block[0]);
>  
>  for(i=0; i<6; i++){
> -if( mdec_decode_block_intra(a, block[ block_index[i] ], 
> block_index[i]) < 0)
> +if( mdec_decode_block_intra(a, block[ block_index[i] ], 
> block_index[i]) < 0 ||
> +get_bits_left(&a->gb) < 0)
>  return -1;
>  }
>  return 0;


If get_bits_left() < 0 doesn't that mean that it has already overread?
How much can it have possibly overread by at this point, and is that <=
FF_INPUT_BUFFER_PADDING_SIZE?

-Justin
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] oggdec: fix number of stream being incremented at format context level

2011-05-11 Thread Clément Bœsch
On Thu, Apr 28, 2011 at 06:23:23PM +0200, Luca Barbato wrote:
> On 04/28/2011 02:35 PM, Clément Bœsch wrote:
> > Sure. The best way to notice the issue is changing the modified line in
> > the patch with av_dump_format(s, 0, s->filename, 0) and you'll notice that
> > kind of stuff after a few track switches (if it's a continuous bitstream):
> > 
> > Stream #0.1: Invalid Codec type -1
> > Stream #0.2: Invalid Codec type -1
> > Stream #0.3: Invalid Codec type -1
> > Stream #0.4: Invalid Codec type -1
> > Stream #0.5: Invalid Codec type -1
> 
> The patch is ok, thank you for giving me more insight =)

A better patch is proposed in:

[PATCH 1/5] oggdec: fix memleak with continuous streams.

Please refer to that one.

Best regards,

-- 
Clément B.


pgpHT6Eq2yUMB.pgp
Description: PGP signature
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 5/5] oggdec: use explicit AVInputFormat struct initializers

2011-05-11 Thread Clément Bœsch
---
 libavformat/oggdec.c |   22 +++---
 1 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c
index b5420f8..6767805 100644
--- a/libavformat/oggdec.c
+++ b/libavformat/oggdec.c
@@ -637,15 +637,15 @@ static int ogg_probe(AVProbeData *p)
 }
 
 AVInputFormat ff_ogg_demuxer = {
-"ogg",
-NULL_IF_CONFIG_SMALL("Ogg"),
-sizeof (struct ogg),
-ogg_probe,
-ogg_read_header,
-ogg_read_packet,
-ogg_read_close,
-ogg_read_seek,
-ogg_read_timestamp,
-.extensions = "ogg",
-.flags = AVFMT_GENERIC_INDEX,
+.name   = "ogg",
+.long_name  = NULL_IF_CONFIG_SMALL("Ogg"),
+.priv_data_size = sizeof(struct ogg),
+.read_probe = ogg_probe,
+.read_header= ogg_read_header,
+.read_packet= ogg_read_packet,
+.read_close = ogg_read_close,
+.read_seek  = ogg_read_seek,
+.read_timestamp = ogg_read_timestamp,
+.extensions = "ogg",
+.flags  = AVFMT_GENERIC_INDEX,
 };
-- 
1.7.5.1

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 4/5] oggdec: simplify ogg_probe

2011-05-11 Thread Clément Bœsch
---
 libavformat/oggdec.c |7 ++-
 1 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c
index ffc3b39..b5420f8 100644
--- a/libavformat/oggdec.c
+++ b/libavformat/oggdec.c
@@ -631,12 +631,9 @@ static int ogg_read_seek(AVFormatContext *s, int 
stream_index,
 
 static int ogg_probe(AVProbeData *p)
 {
-if (p->buf[0] == 'O' && p->buf[1] == 'g' &&
-p->buf[2] == 'g' && p->buf[3] == 'S' &&
-p->buf[4] == 0x0 && p->buf[5] <= 0x7 )
+if (!memcmp("OggS", p->buf, 5) && p->buf[5] <= 0x7)
 return AVPROBE_SCORE_MAX;
-else
-return 0;
+return 0;
 }
 
 AVInputFormat ff_ogg_demuxer = {
-- 
1.7.5.1

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 3/5] Cosmetics: fix prototypes in oggdec

2011-05-11 Thread Clément Bœsch
---
 libavformat/oggdec.c |   51 +
 1 files changed, 18 insertions(+), 33 deletions(-)

diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c
index 5818031..ffc3b39 100644
--- a/libavformat/oggdec.c
+++ b/libavformat/oggdec.c
@@ -55,8 +55,7 @@ static const struct ogg_codec * const ogg_codecs[] = {
 };
 
 //FIXME We could avoid some structure duplication
-static int
-ogg_save (AVFormatContext * s)
+static int ogg_save(AVFormatContext *s)
 {
 struct ogg *ogg = s->priv_data;
 struct ogg_state *ost =
@@ -80,8 +79,7 @@ ogg_save (AVFormatContext * s)
 return 0;
 }
 
-static int
-ogg_restore (AVFormatContext * s, int discard)
+static int ogg_restore(AVFormatContext *s, int discard)
 {
 struct ogg *ogg = s->priv_data;
 AVIOContext *bc = s->pb;
@@ -109,8 +107,7 @@ ogg_restore (AVFormatContext * s, int discard)
 return 0;
 }
 
-static int
-ogg_reset (struct ogg * ogg)
+static int ogg_reset(struct ogg *ogg)
 {
 int i;
 
@@ -134,8 +131,7 @@ ogg_reset (struct ogg * ogg)
 return 0;
 }
 
-static const struct ogg_codec *
-ogg_find_codec (uint8_t * buf, int size)
+static const struct ogg_codec *ogg_find_codec(uint8_t *buf, int size)
 {
 int i;
 
@@ -147,8 +143,7 @@ ogg_find_codec (uint8_t * buf, int size)
 return NULL;
 }
 
-static int
-ogg_new_stream (AVFormatContext *s, uint32_t serial, int new_avstream)
+static int ogg_new_stream(AVFormatContext *s, uint32_t serial, int 
new_avstream)
 {
 
 struct ogg *ogg = s->priv_data;
@@ -176,8 +171,7 @@ ogg_new_stream (AVFormatContext *s, uint32_t serial, int 
new_avstream)
 return idx;
 }
 
-static int
-ogg_new_buf(struct ogg *ogg, int idx)
+static int ogg_new_buf(struct ogg *ogg, int idx)
 {
 struct ogg_stream *os = ogg->streams + idx;
 uint8_t *nb = av_malloc(os->bufsize);
@@ -193,8 +187,7 @@ ogg_new_buf(struct ogg *ogg, int idx)
 return 0;
 }
 
-static int
-ogg_read_page (AVFormatContext * s, int *str)
+static int ogg_read_page(AVFormatContext *s, int *str)
 {
 AVIOContext *bc = s->pb;
 struct ogg *ogg = s->priv_data;
@@ -311,8 +304,8 @@ ogg_read_page (AVFormatContext * s, int *str)
 return 0;
 }
 
-static int
-ogg_packet (AVFormatContext * s, int *str, int *dstart, int *dsize, int64_t 
*fpos)
+static int ogg_packet(AVFormatContext *s, int *str, int *dstart, int *dsize,
+  int64_t *fpos)
 {
 struct ogg *ogg = s->priv_data;
 int idx, i;
@@ -439,8 +432,7 @@ ogg_packet (AVFormatContext * s, int *str, int *dstart, int 
*dsize, int64_t *fpo
 return 0;
 }
 
-static int
-ogg_get_headers (AVFormatContext * s)
+static int ogg_get_headers(AVFormatContext *s)
 {
 struct ogg *ogg = s->priv_data;
 
@@ -454,8 +446,7 @@ ogg_get_headers (AVFormatContext * s)
 return 0;
 }
 
-static int
-ogg_get_length (AVFormatContext * s)
+static int ogg_get_length(AVFormatContext *s)
 {
 struct ogg *ogg = s->priv_data;
 int i;
@@ -491,9 +482,7 @@ ogg_get_length (AVFormatContext * s)
 return 0;
 }
 
-
-static int
-ogg_read_header (AVFormatContext * s, AVFormatParameters * ap)
+static int ogg_read_header(AVFormatContext *s, AVFormatParameters *ap)
 {
 struct ogg *ogg = s->priv_data;
 int i;
@@ -544,8 +533,7 @@ static int64_t ogg_calc_pts(AVFormatContext *s, int idx, 
int64_t *dts)
 return pts;
 }
 
-static int
-ogg_read_packet (AVFormatContext * s, AVPacket * pkt)
+static int ogg_read_packet(AVFormatContext *s, AVPacket *pkt)
 {
 struct ogg *ogg;
 struct ogg_stream *os;
@@ -585,9 +573,7 @@ retry:
 return psize;
 }
 
-
-static int
-ogg_read_close (AVFormatContext * s)
+static int ogg_read_close(AVFormatContext *s)
 {
 struct ogg *ogg = s->priv_data;
 int i;
@@ -600,10 +586,8 @@ ogg_read_close (AVFormatContext * s)
 return 0;
 }
 
-
-static int64_t
-ogg_read_timestamp (AVFormatContext * s, int stream_index, int64_t * pos_arg,
-int64_t pos_limit)
+static int64_t ogg_read_timestamp(AVFormatContext *s, int stream_index,
+  int64_t *pos_arg, int64_t pos_limit)
 {
 struct ogg *ogg = s->priv_data;
 struct ogg_stream *os = ogg->streams + stream_index;
@@ -626,7 +610,8 @@ ogg_read_timestamp (AVFormatContext * s, int stream_index, 
int64_t * pos_arg,
 return pts;
 }
 
-static int ogg_read_seek(AVFormatContext *s, int stream_index, int64_t 
timestamp, int flags)
+static int ogg_read_seek(AVFormatContext *s, int stream_index,
+ int64_t timestamp, int flags)
 {
 struct ogg *ogg = s->priv_data;
 struct ogg_stream *os = ogg->streams + stream_index;
-- 
1.7.5.1

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 2/5] oggdec: reindent after previous commit

2011-05-11 Thread Clément Bœsch
---
 libavformat/oggdec.c |8 
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c
index fbbba66..5818031 100644
--- a/libavformat/oggdec.c
+++ b/libavformat/oggdec.c
@@ -166,11 +166,11 @@ ogg_new_stream (AVFormatContext *s, uint32_t serial, int 
new_avstream)
 os->header = -1;
 
 if (new_avstream) {
-st = av_new_stream (s, idx);
-if (!st)
-return AVERROR(ENOMEM);
+st = av_new_stream(s, idx);
+if (!st)
+return AVERROR(ENOMEM);
 
-av_set_pts_info(st, 64, 1, 100);
+av_set_pts_info(st, 64, 1, 100);
 }
 
 return idx;
-- 
1.7.5.1

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 1/5] oggdec: fix memleak with continuous streams.

2011-05-11 Thread Clément Bœsch
This avoids the creation of a new AVStream instead of replacing it when
a stream reset occurs (track change with some webradios for example).
---
 libavformat/oggdec.c |8 ++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c
index 07969c8..fbbba66 100644
--- a/libavformat/oggdec.c
+++ b/libavformat/oggdec.c
@@ -148,7 +148,7 @@ ogg_find_codec (uint8_t * buf, int size)
 }
 
 static int
-ogg_new_stream (AVFormatContext * s, uint32_t serial)
+ogg_new_stream (AVFormatContext *s, uint32_t serial, int new_avstream)
 {
 
 struct ogg *ogg = s->priv_data;
@@ -165,11 +165,13 @@ ogg_new_stream (AVFormatContext * s, uint32_t serial)
 os->buf = av_malloc(os->bufsize);
 os->header = -1;
 
+if (new_avstream) {
 st = av_new_stream (s, idx);
 if (!st)
 return AVERROR(ENOMEM);
 
 av_set_pts_info(st, 64, 1, 100);
+}
 
 return idx;
 }
@@ -250,8 +252,10 @@ ogg_read_page (AVFormatContext * s, int *str)
 }
 ogg->curidx   = -1;
 ogg->nstreams = 0;
+idx = ogg_new_stream(s, serial, 0);
+} else {
+idx = ogg_new_stream(s, serial, 1);
 }
-idx = ogg_new_stream (s, serial);
 if (idx < 0)
 return -1;
 }
-- 
1.7.5.1

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [libav-commits] asfdec: fix assert failure on invalid files

2011-05-11 Thread Uoti Urpala
On Wed, 2011-05-04 at 04:38 +0200, Uoti Urpala wrote:
> Commit: 0bd433a916cd8d98fce47742fbf6d0f90ec941c4
> 
> Author:Uoti Urpala 
> Committer: Ronald S. Bultje 
> Date:  Sun Apr 24 07:21:30 2011 +0300
> 
> asfdec: fix assert failure on invalid files

> diff --git a/libavformat/asfdec.c b/libavformat/asfdec.c
> index 637ceed..77c8449 100644
> --- a/libavformat/asfdec.c
> +++ b/libavformat/asfdec.c
> @@ -864,6 +864,10 @@ static int asf_read_frame_header(AVFormatContext *s, 
> AVIOContext *pb){
>  }
>  //printf("Fragsize %d\n", asf->packet_frag_size);
>  } else {
> +if (rsize > asf->packet_size_left) {
> +av_log(s, AV_LOG_ERROR, "packet_replic_size is invalid\n");
> +return -1;

This modified version of my patch does not fix all the routes to assert
failure for huge rsize: the check is now only done inside the "else"
branch and all "big enough" values will still cause a failure in the
other branch. Ronald probably thought that the check he added there,
"if (asf->packet_frag_size > asf->packet_size_left - rsize + 
asf->packet_padsize) {",
would also protect against insane values. However, this doesn't work
because packet_frag_size is declared with an unsigned type, and thus all
large values of rsize will just make the right side of the comparison
wrap around instead of triggering the test.

I already mentioned this on IRC, but as it still isn't fixed I'm posting
here to reduce the probability of the issue being forgotten.

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] 10-bit H.264 x86 chroma v loopfilter asm

2011-05-11 Thread Jason Garrett-Glaser
On Wed, May 11, 2011 at 10:19 AM, Ronald S. Bultje  wrote:
> Hi,
>
> On Wed, May 11, 2011 at 1:15 PM, Jason Garrett-Glaser  wrote:
>> Also delete some unused deblock asm macros.
>> ---
>>  libavcodec/x86/h264_deblock.asm       |   41 -
>>  libavcodec/x86/h264_deblock_10bit.asm |  106 
>> +
>>  libavcodec/x86/h264dsp_mmx.c          |   16 +-
>>  3 files changed, 121 insertions(+), 42 deletions(-)
>
> Had a quick look (i.e. no detailed review), but looks sane enough. If
> it passes fate, LGTM.
>
> Ronald

Applied.

Jason
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [RFC] Fix asfdec "regression"

2011-05-11 Thread Uoti Urpala
On Tue, 2011-05-10 at 15:02 +0200, Vladimir Pantelic wrote:
> Uoti Urpala wrote:
> > Disabling the utils.c fallback for asf should be enough. I'm not posting

> attached are 2 patches that both solve the issue, one makes ASF cleanup
> after util.c falls back to binary search,

This makes little sense IMO. The seek method of the asf demuxer already
uses binary seeking machinery itself when appropriate. Trying to support
outside binary search calls that are known to have only negative effects
seems wrong.

>  the other one introduces a new
> flag that prevents util.c from doing so.

But it still calls av_seek_frame_generic(). Is that really any more
appropriate, even if it doesn't happen to trigger visible problems now?

How many demuxers are there that define their own seek method but do
still rely on the general code executing the fallbacks?

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [RFC] Fix asfdec "regression"

2011-05-11 Thread Ronald S. Bultje
Hi,

On Tue, May 10, 2011 at 9:02 AM, Vladimir Pantelic  wrote:
> Uoti Urpala wrote:
>>
>> Attached patch fixes an assertion failure that's fairly easy to trigger
>> with corrupt files.
>>
>> The asf seek regression triggered by the preroll changes (caused by
>> binary seek fallback) is still there, anyone going to fix that?
>
> yes, the preroll changes now expose that asf bug.
>
>> Disabling the utils.c fallback for asf should be enough. I'm not posting
>> a patch for that one as the method of disabling it is a matter of
>> opinion/style; I neither care what method libavformat uses for that nor
>> want to discuss it.
>
> attached are 2 patches that both solve the issue, one makes ASF cleanup
> after util.c falls back to binary search, the other one introduces a new
> flag that prevents util.c from doing so.
>
> comment welcome

I like patch #1.

Ronald
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 2/2] mdec: enable frame-level multithreading.

2011-05-11 Thread Ronald S. Bultje
On Tue, May 10, 2011 at 11:29 AM, Ronald S. Bultje  wrote:
> From: Alexander Strange 
>
> Signed-off-by: Ronald S. Bultje 
> ---
>  libavcodec/mdec.c |   20 +---
>  1 files changed, 17 insertions(+), 3 deletions(-)
>
> diff --git a/libavcodec/mdec.c b/libavcodec/mdec.c
> index 9b6e6b6..17671cf 100644
> --- a/libavcodec/mdec.c
> +++ b/libavcodec/mdec.c
> @@ -31,6 +31,7 @@
>  #include "dsputil.h"
>  #include "mpegvideo.h"
>  #include "mpeg12.h"
> +#include "thread.h"
>
>  typedef struct MDECContext{
>     AVCodecContext *avctx;
> @@ -163,10 +164,10 @@ static int decode_frame(AVCodecContext *avctx,
>     int i;
>
>     if(p->data[0])
> -        avctx->release_buffer(avctx, p);
> +        ff_thread_release_buffer(avctx, p);
>
>     p->reference= 0;
> -    if(avctx->get_buffer(avctx, p) < 0){
> +    if(ff_thread_get_buffer(avctx, p) < 0){
>         av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
>         return -1;
>     }
> @@ -239,6 +240,18 @@ static av_cold int decode_init(AVCodecContext *avctx){
>     return 0;
>  }
>
> +static av_cold int decode_init_thread_copy(AVCodecContext *avctx){
> +    MDECContext * const a = avctx->priv_data;
> +    AVFrame *p = (AVFrame*)&a->picture;
> +
> +    avctx->coded_frame= p;
> +    a->avctx= avctx;
> +
> +    p->qscale_table= av_mallocz( a->mb_width);
> +
> +    return 0;
> +}
> +
>  static av_cold int decode_end(AVCodecContext *avctx){
>     MDECContext * const a = avctx->priv_data;
>
> @@ -260,7 +273,8 @@ AVCodec ff_mdec_decoder = {
>     NULL,
>     decode_end,
>     decode_frame,
> -    CODEC_CAP_DR1,
> +    CODEC_CAP_DR1 | CODEC_CAP_FRAME_THREADS,
>     .long_name= NULL_IF_CONFIG_SMALL("Sony PlayStation MDEC (Motion 
> DECoder)"),
> +    .init_thread_copy= ONLY_IF_THREADS_ENABLED(decode_init_thread_copy)
>  };

Ping.

Ronald
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 1/2] mdec.c: fix overread.

2011-05-11 Thread Ronald S. Bultje
On Tue, May 10, 2011 at 11:29 AM, Ronald S. Bultje  wrote:
> ---
>  libavcodec/mdec.c |    3 ++-
>  1 files changed, 2 insertions(+), 1 deletions(-)
>
> diff --git a/libavcodec/mdec.c b/libavcodec/mdec.c
> index 545b919..9b6e6b6 100644
> --- a/libavcodec/mdec.c
> +++ b/libavcodec/mdec.c
> @@ -125,7 +125,8 @@ static inline int decode_mb(MDECContext *a, DCTELEM 
> block[6][64]){
>     a->dsp.clear_blocks(block[0]);
>
>     for(i=0; i<6; i++){
> -        if( mdec_decode_block_intra(a, block[ block_index[i] ], 
> block_index[i]) < 0)
> +        if( mdec_decode_block_intra(a, block[ block_index[i] ], 
> block_index[i]) < 0 ||
> +            get_bits_left(&a->gb) < 0)
>             return -1;
>     }
>     return 0;

Ping.

Ronald
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [RFC] fix swscale for 9/10bit

2011-05-11 Thread Ronald S. Bultje
Hi again,

On Wed, May 11, 2011 at 12:07 PM, Ronald S. Bultje  wrote:
> On Wed, May 11, 2011 at 11:59 AM, Ronald S. Bultje  wrote:
>> On Wed, May 11, 2011 at 11:26 AM, Ronald S. Bultje  
>> wrote:
>>> attached is a RFC for fixing SWS for 9/10bit, as output by H264. It
>>> takes endianness in account and does some other stuff. As you can see,
>>> this stuff quickly gets hideous (e.g. planarCopyWrapper is a mess), so
>>> I'd like some advice on how people think we should do this.
>>>
>>> We need this fix so we can convert 10bitBE to 10bitLE and thereby fix
>>> 10bit H264 on BE systems (e.g. PPC), which are now correct except that
>>> byte ordering for each word is inverted.
>>
>> Attached is one more that should fix fate (at least 10bit h264) on BE
>> systems, along with the swscale hackery.
>
> And one more adding a missing if. We need someone to write tests for
> these various colorspace conversions...

And this one has fate tests added so that it doesn't break. I've
tested all YUV8/9/10/16/RGB <-> 10/9bit conversions and they all
produce images that are visibly correct, so all codepaths should be
fine.

Ronald
diff --git a/libavutil/pixfmt.h b/libavutil/pixfmt.h
index 533eb9f..d88775f 100644
--- a/libavutil/pixfmt.h
+++ b/libavutil/pixfmt.h
@@ -128,10 +128,10 @@ enum PixelFormat {
 PIX_FMT_VDPAU_MPEG4,  ///< MPEG4 HW decoding with VDPAU, data[0] contains 
a vdpau_render_state struct which contains the bitstream of the slices as well 
as various fields extracted from headers
 PIX_FMT_DXVA2_VLD,///< HW decoding through DXVA2, Picture.data[3] 
contains a LPDIRECT3DSURFACE9 pointer
 
-PIX_FMT_RGB444BE,  ///< packed RGB 4:4:4, 16bpp, (msb)4A 4R 4G 4B(lsb), 
big-endian, most significant bits to 0
 PIX_FMT_RGB444LE,  ///< packed RGB 4:4:4, 16bpp, (msb)4A 4R 4G 4B(lsb), 
little-endian, most significant bits to 0
-PIX_FMT_BGR444BE,  ///< packed BGR 4:4:4, 16bpp, (msb)4A 4B 4G 4R(lsb), 
big-endian, most significant bits to 1
+PIX_FMT_RGB444BE,  ///< packed RGB 4:4:4, 16bpp, (msb)4A 4R 4G 4B(lsb), 
big-endian, most significant bits to 0
 PIX_FMT_BGR444LE,  ///< packed BGR 4:4:4, 16bpp, (msb)4A 4B 4G 4R(lsb), 
little-endian, most significant bits to 1
+PIX_FMT_BGR444BE,  ///< packed BGR 4:4:4, 16bpp, (msb)4A 4B 4G 4R(lsb), 
big-endian, most significant bits to 1
 PIX_FMT_Y400A, ///< 8bit gray, 8bit alpha
 PIX_FMT_BGR48BE,   ///< packed RGB 16:16:16, 48bpp, 16B, 16G, 16R, the 
2-byte value for each R/G/B component is stored as big-endian
 PIX_FMT_BGR48LE,   ///< packed RGB 16:16:16, 48bpp, 16B, 16G, 16R, the 
2-byte value for each R/G/B component is stored as little-endian
diff --git a/libswscale/ppc/swscale_template.c 
b/libswscale/ppc/swscale_template.c
index 3e40c3f..e69656c 100644
--- a/libswscale/ppc/swscale_template.c
+++ b/libswscale/ppc/swscale_template.c
@@ -639,7 +639,7 @@ static int RENAME(swScale)(SwsContext *c, const uint8_t* 
src[], int srcStride[],
 } else if (isPlanarYUV(dstFormat) || dstFormat==PIX_FMT_GRAY8) { 
//YV12 like
 const int chrSkipMask= (1

Re: [libav-devel] [PATCH] 10-bit H.264 x86 chroma v loopfilter asm

2011-05-11 Thread Ronald S. Bultje
Hi,

On Wed, May 11, 2011 at 1:15 PM, Jason Garrett-Glaser  wrote:
> Also delete some unused deblock asm macros.
> ---
>  libavcodec/x86/h264_deblock.asm       |   41 -
>  libavcodec/x86/h264_deblock_10bit.asm |  106 
> +
>  libavcodec/x86/h264dsp_mmx.c          |   16 +-
>  3 files changed, 121 insertions(+), 42 deletions(-)

Had a quick look (i.e. no detailed review), but looks sane enough. If
it passes fate, LGTM.

Ronald
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH] 10-bit H.264 x86 chroma v loopfilter asm

2011-05-11 Thread Jason Garrett-Glaser
Also delete some unused deblock asm macros.
---
 libavcodec/x86/h264_deblock.asm   |   41 -
 libavcodec/x86/h264_deblock_10bit.asm |  106 +
 libavcodec/x86/h264dsp_mmx.c  |   16 +-
 3 files changed, 121 insertions(+), 42 deletions(-)

diff --git a/libavcodec/x86/h264_deblock.asm b/libavcodec/x86/h264_deblock.asm
index 3786681..0cf013f 100644
--- a/libavcodec/x86/h264_deblock.asm
+++ b/libavcodec/x86/h264_deblock.asm
@@ -106,47 +106,6 @@ cextern pb_A1
 TRANSPOSE4x8_LOAD bw, wd, dq, %1, %2, %3, %4, %5, %6, %7, %8
 %endmacro
 
-%macro TRANSPOSE4x8W_LOAD 8
-%if mmsize==16
-TRANSPOSE4x8_LOAD wd, dq, qdq, %1, %2, %3, %4, %5, %6, %7, %8
-%else
-SWAP  1, 4, 2, 3
-mova  m0, [t5]
-mova  m1, [t5+r1]
-mova  m2, [t5+r1*2]
-mova  m3, [t5+t6]
-TRANSPOSE4x4W 0, 1, 2, 3, 4
-%endif
-%endmacro
-
-%macro TRANSPOSE8x2W_STORE 8
-punpckhwd  m0, m1, m2
-punpcklwd  m1, m2
-%if mmsize==8
-movd   %3, m0
-movd   %1, m1
-psrlq  m1, 32
-psrlq  m0, 32
-movd   %2, m1
-movd   %4, m0
-%else
-movd   %5, m0
-movd   %1, m1
-psrldq m1, 4
-psrldq m0, 4
-movd   %2, m1
-movd   %6, m0
-psrldq m1, 4
-psrldq m0, 4
-movd   %3, m1
-movd   %7, m0
-psrldq m1, 4
-psrldq m0, 4
-movd   %4, m1
-movd   %8, m0
-%endif
-%endmacro
-
 %macro SBUTTERFLY3 4
 punpckh%1  %4, %2, %3
 punpckl%1  %2, %3
diff --git a/libavcodec/x86/h264_deblock_10bit.asm 
b/libavcodec/x86/h264_deblock_10bit.asm
index 402ed9b..c253d02 100644
--- a/libavcodec/x86/h264_deblock_10bit.asm
+++ b/libavcodec/x86/h264_deblock_10bit.asm
@@ -34,6 +34,7 @@ pw_pixel_max: times 8 dw ((1 << 10)-1)
 SECTION .text
 
 cextern pw_2
+cextern pw_3
 cextern pw_4
 
 ; out: %4 = |%1-%2|-%3
@@ -802,3 +803,108 @@ INIT_AVX
 DEBLOCK_LUMA avx
 DEBLOCK_LUMA_INTRA avx
 %endif
+
+; in: %1=p0, %2=q0, %3=p1, %4=q1, %5=mask, %6=tmp, %7=tmp
+; out: %1=p0', %2=q0'
+%macro CHROMA_DEBLOCK_P0_Q0_INTRA 7
+mova%6, [pw_2]
+paddw   %6, %3
+paddw   %6, %4
+paddw   %7, %6, %2
+paddw   %6, %1
+paddw   %6, %3
+paddw   %7, %4
+psraw   %6, 2
+psraw   %7, 2
+psubw   %6, %1
+psubw   %7, %2
+pand%6, %5
+pand%7, %5
+paddw   %1, %6
+paddw   %2, %7
+%endmacro
+
+%macro CHROMA_V_LOAD 1
+movam0, [r0]; p1
+movam1, [r0+r1] ; p0
+movam2, [%1]; q0
+movam3, [%1+r1] ; q1
+%endmacro
+
+%macro CHROMA_V_STORE 0
+mova [r0+1*r1], m1
+mova [r0+2*r1], m2
+%endmacro
+
+%macro DEBLOCK_CHROMA 1
+;-
+; void deblock_v_chroma( uint16_t *pix, int stride, int alpha, int beta, 
int8_t *tc0 )
+;-
+cglobal deblock_v_chroma_10_%1, 5,7-(mmsize/16),8*(mmsize/16)
+mov r5, r0
+sub r0, r1
+sub r0, r1
+shlr2d, 2
+shlr3d, 2
+%if mmsize < 16
+mov r6, 16/mmsize
+.loop:
+%endif
+CHROMA_V_LOAD r5
+LOAD_AB m4, m5, r2, r3
+LOAD_MASK   m0, m1, m2, m3, m4, m5, m7, m6, m4
+pxorm4, m4
+LOAD_TC m6, r4
+psubw   m6, [pw_3]
+pmaxsw  m6, m4
+pandm7, m6
+DEBLOCK_P0_Q0 m1, m2, m0, m3, m7, m5, m6
+CHROMA_V_STORE
+%if mmsize < 16
+add r0, mmsize
+add r5, mmsize
+add r4, mmsize/8
+dec r6
+jg .loop
+REP_RET
+%else
+RET
+%endif
+
+;-
+; void deblock_v_chroma_intra( uint16_t *pix, int stride, int alpha, int beta )
+;-
+cglobal deblock_v_chroma_intra_10_%1, 4,6-(mmsize/16),8*(mmsize/16)
+mov r4, r0
+sub r0, r1
+sub r0, r1
+shlr2d, 2
+shlr3d, 2
+%if mmsize < 16
+mov r5, 16/mmsize
+.loop:
+%endif
+CHROMA_V_LOAD r4
+LOAD_AB m4, m5, r2, r3
+LOAD_MASK   m0, m1, m2, m3, m4, m5, m7, m6, m4
+CHROMA_DEBLOCK_P0_Q0_INTRA m1, m2, m0, m3, m7, m5, m6
+CHROMA_V_STORE
+%if mmsize < 16
+add r0, mmsize
+add r4, mmsize
+dec r5
+jg .loop
+REP_RET
+%else
+RET
+%endif
+%endmacro
+
+%ifndef ARCH_X86_64
+INIT_MMX
+DEBLOCK_CHROMA mmxext
+%endif
+INIT_XMM
+DEBLOCK_CHROMA sse2
+INIT_AVX
+DEBLOCK_CHROMA avx
diff --git a/libavcodec/x86/h264dsp_mmx.c b/libavcodec/x86/h264dsp_mmx.c
index 42dae93..01b1116 100644
--- a/libavcodec/x86/h264dsp_mmx.c
+++ b/libavcodec/x86/h264dsp_mmx.c
@@ -236,10 +236,18 @@ LF_FUNC (h,  luma, depth, sse2)\
 LF_IFUNC(h,  luma_intra,   depth, sse2)\
 LF_FUNC (v,  luma, depth, sse2)\
 LF_IFUNC(v,  luma_intra,   depth, sse2)\
+LF_FUNC (h,  chroma,   

[libav-devel] [PATCH 2/2] Eliminate _DARWIN_C_SOURCE.

2011-05-11 Thread Diego Biurrun
---
 libavformat/os_support.c |1 -
 libavformat/udp.c|2 +-
 libswscale/utils.c   |2 +-
 3 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/libavformat/os_support.c b/libavformat/os_support.c
index 05577b7..a0fcd6c 100644
--- a/libavformat/os_support.c
+++ b/libavformat/os_support.c
@@ -22,7 +22,6 @@
 
 /* needed by inet_aton() */
 #define _SVID_SOURCE
-#define _DARWIN_C_SOURCE
 
 #include "config.h"
 #include "avformat.h"
diff --git a/libavformat/udp.c b/libavformat/udp.c
index 62c1c7c..d6522bf 100644
--- a/libavformat/udp.c
+++ b/libavformat/udp.c
@@ -25,7 +25,7 @@
  */
 
 #define _BSD_SOURCE /* Needed for using struct ip_mreq with recent glibc */
-#define _DARWIN_C_SOURCE /* Needed for using IP_MULTICAST_TTL on OS X */
+
 #include "avformat.h"
 #include "avio_internal.h"
 #include "libavutil/parseutils.h"
diff --git a/libswscale/utils.c b/libswscale/utils.c
index 4f9f269..1d758f6 100644
--- a/libswscale/utils.c
+++ b/libswscale/utils.c
@@ -19,7 +19,7 @@
  */
 
 #define _SVID_SOURCE //needed for MAP_ANONYMOUS
-#define _DARWIN_C_SOURCE // needed for MAP_ANON
+
 #include 
 #include 
 #include 
-- 
1.7.1

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 1/2] configure: Add -D_POSIX_C_SOURCE for each system individually.

2011-05-11 Thread Diego Biurrun
---
 configure|4 ++--
 doc/general.texi |8 
 ffmpeg.c |3 ---
 ffplay.c |2 --
 ffserver.c   |2 --
 libavcodec/libxvidff.c   |3 ---
 libavdevice/bktr.c   |4 
 libavdevice/x11grab.c|2 --
 libavformat/applehttp.c  |1 -
 libavformat/applehttpproto.c |1 -
 libavformat/avio.c   |3 +--
 libavformat/rtpdec.c |3 ---
 libavutil/ppc/cpu.c  |2 --
 13 files changed, 3 insertions(+), 35 deletions(-)

diff --git a/configure b/configure
index 955a568..04952b1 100755
--- a/configure
+++ b/configure
@@ -2316,7 +2316,7 @@ if test "$?" != 0; then
 die "C compiler test failed."
 fi
 
-add_cppflags -D_ISOC99_SOURCE -D_POSIX_C_SOURCE=200112
+add_cppflags -D_ISOC99_SOURCE
 check_cflags -std=c99
 check_cc -D_FILE_OFFSET_BITS=64 <
@@ -2364,7 +2364,6 @@ case $target_os in
 disable symver
 oss_indev_extralibs="-lossaudio"
 oss_outdev_extralibs="-lossaudio"
-add_cppflags -D_XOPEN_SOURCE=600
 ;;
 openbsd)
 enable malloc_aligned
@@ -2457,6 +2456,7 @@ case $target_os in
 enable dos_paths
 ;;
 linux)
+add_cppflags -D_XOPEN_SOURCE=600 -D_POSIX_C_SOURCE=200112
 enable dv1394
 ;;
 irix*)
diff --git a/doc/general.texi b/doc/general.texi
index 598b9bc..bbc8e56 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -784,14 +784,6 @@ to configure.
 BSD make will not build Libav, you need to install and use GNU Make
 (@file{gmake}).
 
-@subsubsection FreeBSD, DragonFly BSD
-
-These systems will not compile out-of-the-box due to broken system headers.
-Passing @code{--extra-cflags=-D__BSD_VISIBLE} to configure will work
-around the problem. This may have unexpected sideeffects, so use it at
-your own risk. If you care about FreeBSD, please make an attempt at
-getting the system headers fixed.
-
 @subsection (Open)Solaris
 
 GNU Make is required to build Libav, so you have to invoke (@file{gmake}),
diff --git a/ffmpeg.c b/ffmpeg.c
index 5ab3c7a..b5ff4cf 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -19,9 +19,6 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-/* needed for usleep() */
-#define _XOPEN_SOURCE 600
-
 #include "config.h"
 #include 
 #include 
diff --git a/ffplay.c b/ffplay.c
index 07727b6..e820c60 100644
--- a/ffplay.c
+++ b/ffplay.c
@@ -19,8 +19,6 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#define _XOPEN_SOURCE 600
-
 #include "config.h"
 #include 
 #include 
diff --git a/ffserver.c b/ffserver.c
index fe030b9..b4613af 100644
--- a/ffserver.c
+++ b/ffserver.c
@@ -19,8 +19,6 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#define _XOPEN_SOURCE 600
-
 #include "config.h"
 #if !HAVE_CLOSESOCKET
 #define closesocket close
diff --git a/libavcodec/libxvidff.c b/libavcodec/libxvidff.c
index 96ce848..1e887a2 100644
--- a/libavcodec/libxvidff.c
+++ b/libavcodec/libxvidff.c
@@ -25,9 +25,6 @@
  * @author Adam Thayer (krev...@comcast.net)
  */
 
-/* needed for mkstemp() */
-#define _XOPEN_SOURCE 600
-
 #include 
 #include 
 #include "avcodec.h"
diff --git a/libavdevice/bktr.c b/libavdevice/bktr.c
index ab70a1b..dad5c83 100644
--- a/libavdevice/bktr.c
+++ b/libavdevice/bktr.c
@@ -24,10 +24,6 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#define _BSD_SOURCE 1
-#define _NETBSD_SOURCE
-#define _XOPEN_SOURCE 600
-
 #include "libavformat/avformat.h"
 #if HAVE_DEV_BKTR_IOCTL_METEOR_H && HAVE_DEV_BKTR_IOCTL_BT848_H
 # include 
diff --git a/libavdevice/x11grab.c b/libavdevice/x11grab.c
index aaad729..0e63d09 100644
--- a/libavdevice/x11grab.c
+++ b/libavdevice/x11grab.c
@@ -35,8 +35,6 @@
  * and Edouard Gomez .
  */
 
-#define _XOPEN_SOURCE 600
-
 #include "config.h"
 #include "libavformat/avformat.h"
 #include 
diff --git a/libavformat/applehttp.c b/libavformat/applehttp.c
index 822d80b..e3b1500 100644
--- a/libavformat/applehttp.c
+++ b/libavformat/applehttp.c
@@ -25,7 +25,6 @@
  * http://tools.ietf.org/html/draft-pantos-http-live-streaming
  */
 
-#define _XOPEN_SOURCE 600
 #include "libavutil/avstring.h"
 #include "libavutil/intreadwrite.h"
 #include "libavutil/opt.h"
diff --git a/libavformat/applehttpproto.c b/libavformat/applehttpproto.c
index 37b289a..85f3cfc 100644
--- a/libavformat/applehttpproto.c
+++ b/libavformat/applehttpproto.c
@@ -25,7 +25,6 @@
  * http://tools.ietf.org/html/draft-pantos-http-live-streaming
  */
 
-#define _XOPEN_SOURCE 600
 #include "libavutil/avstring.h"
 #include "avformat.h"
 #include "internal.h"
diff --git a/libavformat/avio.c b/libavformat/avio.c
index 0702aff..8881f26 100644
--- a/libavformat/avio.c
+++ b/libavformat/avio.c
@@ -19,9 +19,8 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-/* needed for usle

Re: [libav-devel] [PATCH] aac: workaround for compilation on cygwin

2011-05-11 Thread Alex Converse
On Wed, May 11, 2011 at 8:42 AM, Reinhard Tartler  wrote:
> On Wed, May 11, 2011 at 17:25:50 (CEST), Alex Converse wrote:
>
>> On Wed, May 11, 2011 at 5:45 AM, Reinhard Tartler  
>> wrote:
>>> On Wed, May 11, 2011 at 14:23:14 (CEST), Luca Barbato wrote:
>>>
 On 5/11/11 1:51 PM, Reinhard Tartler wrote:
> On cygwin, math.h needs to be included before float.h because of a bug
> in the system headers. Including libavutil/libm.h first works around
> this issue.
>
> Longer discussion of the topic:
> http://thread.gmane.org/gmane.comp.video.ffmpeg.devel/128582

 If there isn't a saner solution ok. We should notify cygwin about that
 though.
>>>
>>> http://article.gmane.org/gmane.comp.video.ffmpeg.devel/128658
>>>
>>> Probably that's this 'discussion':
>>>
>>> http://thread.gmane.org/gmane.os.cygwin/125314/focus=125323
>>>
>>
>> I'm having problems following that discussion:
>>
>> From: Matthias Andree  gmx.de>
>>> On Wed, 02 Mar 2011, Víctor Paesa wrote:
>>>
>>> > Hi,
>>> >
>>> > In 1.7.7, log2f() is defined in math.h as
>>> >
>>> > extern float log2f _PARAMS((float));
>>> > #if !defined(__cplusplus)
>>> > #define log2f(x) (logf (x) / (float) _M_LOG2_E)
>>> > #endif
>>> >
>>> > In 1.7.8, log2f() is defined in math.h as
>>> >
>>> > extern float log2f _PARAMS((float));
>>> > #if !defined(__cplusplus)
>>> > #define log2f(x) (logf (x) / (float_t) _M_LOG2_E)
>>> > #endif
>>> >
>>> > This change broke the compilation of ffmpeg.
>>> >
>>> > Would it be possible to use again "float", instead of "float_t" ?
>>>
>>> Why? Fix ffmpeg instead. #include  should suffice:
>>>
>>
>> A definition in math.h changed so the solution is to include 
>> where does  come into this mess...
>
> I'm surprised as well.
>
> What I did was to play around with the #includes, and made these
> observations:
>
>  - libavuti/libm.h was included last
>  - libavuti/libm.h #includes 
>  - inserting a #include before the #include  directive
>   fixes compilation (the ffmpeg 'solution')
>
> With this, I've came up with the now pushed patch.
>

And does c99 require  to be included before ?

Should this file not compile:

#include 
#include 
float a(float b) {
return log2f(b);
}
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [RFC] fix swscale for 9/10bit

2011-05-11 Thread Ronald S. Bultje
Hi,

On Wed, May 11, 2011 at 11:59 AM, Ronald S. Bultje  wrote:
> On Wed, May 11, 2011 at 11:26 AM, Ronald S. Bultje  wrote:
>> attached is a RFC for fixing SWS for 9/10bit, as output by H264. It
>> takes endianness in account and does some other stuff. As you can see,
>> this stuff quickly gets hideous (e.g. planarCopyWrapper is a mess), so
>> I'd like some advice on how people think we should do this.
>>
>> We need this fix so we can convert 10bitBE to 10bitLE and thereby fix
>> 10bit H264 on BE systems (e.g. PPC), which are now correct except that
>> byte ordering for each word is inverted.
>
> Attached is one more that should fix fate (at least 10bit h264) on BE
> systems, along with the swscale hackery.

And one more adding a missing if. We need someone to write tests for
these various colorspace conversions...

Ronald
diff --git a/libavutil/pixfmt.h b/libavutil/pixfmt.h
index 533eb9f..d88775f 100644
--- a/libavutil/pixfmt.h
+++ b/libavutil/pixfmt.h
@@ -128,10 +128,10 @@ enum PixelFormat {
 PIX_FMT_VDPAU_MPEG4,  ///< MPEG4 HW decoding with VDPAU, data[0] contains 
a vdpau_render_state struct which contains the bitstream of the slices as well 
as various fields extracted from headers
 PIX_FMT_DXVA2_VLD,///< HW decoding through DXVA2, Picture.data[3] 
contains a LPDIRECT3DSURFACE9 pointer
 
-PIX_FMT_RGB444BE,  ///< packed RGB 4:4:4, 16bpp, (msb)4A 4R 4G 4B(lsb), 
big-endian, most significant bits to 0
 PIX_FMT_RGB444LE,  ///< packed RGB 4:4:4, 16bpp, (msb)4A 4R 4G 4B(lsb), 
little-endian, most significant bits to 0
-PIX_FMT_BGR444BE,  ///< packed BGR 4:4:4, 16bpp, (msb)4A 4B 4G 4R(lsb), 
big-endian, most significant bits to 1
+PIX_FMT_RGB444BE,  ///< packed RGB 4:4:4, 16bpp, (msb)4A 4R 4G 4B(lsb), 
big-endian, most significant bits to 0
 PIX_FMT_BGR444LE,  ///< packed BGR 4:4:4, 16bpp, (msb)4A 4B 4G 4R(lsb), 
little-endian, most significant bits to 1
+PIX_FMT_BGR444BE,  ///< packed BGR 4:4:4, 16bpp, (msb)4A 4B 4G 4R(lsb), 
big-endian, most significant bits to 1
 PIX_FMT_Y400A, ///< 8bit gray, 8bit alpha
 PIX_FMT_BGR48BE,   ///< packed RGB 16:16:16, 48bpp, 16B, 16G, 16R, the 
2-byte value for each R/G/B component is stored as big-endian
 PIX_FMT_BGR48LE,   ///< packed RGB 16:16:16, 48bpp, 16B, 16G, 16R, the 
2-byte value for each R/G/B component is stored as little-endian
diff --git a/libswscale/swscale.c b/libswscale/swscale.c
index 2830f26..d3eaf36 100644
--- a/libswscale/swscale.c
+++ b/libswscale/swscale.c
@@ -212,10 +212,11 @@ DECLARE_ALIGNED(8, const uint8_t, dither_8x8_220)[8][8]={
 static av_always_inline void yuv2yuvX16inC_template(const int16_t *lumFilter, 
const int16_t **lumSrc, int lumFilterSize,
 const int16_t *chrFilter, 
const int16_t **chrSrc, int chrFilterSize,
 const int16_t **alpSrc, 
uint16_t *dest, uint16_t *uDest, uint16_t *vDest, uint16_t *aDest,
-int dstW, int chrDstW, int 
big_endian)
+int dstW, int chrDstW, int 
big_endian, int output_bits)
 {
 //FIXME Optimize (just quickly written not optimized..)
 int i;
+int shift = 11 + 16 - output_bits;
 
 for (i = 0; i < dstW; i++) {
 int val = 1 << 10;
@@ -225,9 +226,9 @@ static av_always_inline void yuv2yuvX16inC_template(const 
int16_t *lumFilter, co
 val += lumSrc[j][i] * lumFilter[j];
 
 if (big_endian) {
-AV_WB16(&dest[i], av_clip_uint16(val >> 11));
+AV_WB16(&dest[i], av_clip_uint16(val >> shift));
 } else {
-AV_WL16(&dest[i], av_clip_uint16(val >> 11));
+AV_WL16(&dest[i], av_clip_uint16(val >> shift));
 }
 }
 
@@ -243,11 +244,11 @@ static av_always_inline void yuv2yuvX16inC_template(const 
int16_t *lumFilter, co
 }
 
 if (big_endian) {
-AV_WB16(&uDest[i], av_clip_uint16(u >> 11));
-AV_WB16(&vDest[i], av_clip_uint16(v >> 11));
+AV_WB16(&uDest[i], av_clip_uint16(u >> shift));
+AV_WB16(&vDest[i], av_clip_uint16(v >> shift));
 } else {
-AV_WL16(&uDest[i], av_clip_uint16(u >> 11));
-AV_WL16(&vDest[i], av_clip_uint16(v >> 11));
+AV_WL16(&uDest[i], av_clip_uint16(u >> shift));
+AV_WL16(&vDest[i], av_clip_uint16(v >> shift));
 }
 }
 }
@@ -261,9 +262,9 @@ static av_always_inline void yuv2yuvX16inC_template(const 
int16_t *lumFilter, co
 val += alpSrc[j][i] * lumFilter[j];
 
 if (big_endian) {
-AV_WB16(&aDest[i], av_clip_uint16(val >> 11));
+AV_WB16(&aDest[i], av_clip_uint16(val >> shift));
 } else {
-AV_WL16(&aDest[i], av_clip_uint16(val >> 11));
+AV_WL16(&aDest[i], av_clip_uint16(val >>

Re: [libav-devel] [RFC] fix swscale for 9/10bit

2011-05-11 Thread Ronald S. Bultje
Hi,

On Wed, May 11, 2011 at 11:26 AM, Ronald S. Bultje  wrote:
> attached is a RFC for fixing SWS for 9/10bit, as output by H264. It
> takes endianness in account and does some other stuff. As you can see,
> this stuff quickly gets hideous (e.g. planarCopyWrapper is a mess), so
> I'd like some advice on how people think we should do this.
>
> We need this fix so we can convert 10bitBE to 10bitLE and thereby fix
> 10bit H264 on BE systems (e.g. PPC), which are now correct except that
> byte ordering for each word is inverted.

Attached is one more that should fix fate (at least 10bit h264) on BE
systems, along with the swscale hackery.

Ronald
diff --git a/libavutil/pixfmt.h b/libavutil/pixfmt.h
index 533eb9f..d88775f 100644
--- a/libavutil/pixfmt.h
+++ b/libavutil/pixfmt.h
@@ -128,10 +128,10 @@ enum PixelFormat {
 PIX_FMT_VDPAU_MPEG4,  ///< MPEG4 HW decoding with VDPAU, data[0] contains 
a vdpau_render_state struct which contains the bitstream of the slices as well 
as various fields extracted from headers
 PIX_FMT_DXVA2_VLD,///< HW decoding through DXVA2, Picture.data[3] 
contains a LPDIRECT3DSURFACE9 pointer
 
-PIX_FMT_RGB444BE,  ///< packed RGB 4:4:4, 16bpp, (msb)4A 4R 4G 4B(lsb), 
big-endian, most significant bits to 0
 PIX_FMT_RGB444LE,  ///< packed RGB 4:4:4, 16bpp, (msb)4A 4R 4G 4B(lsb), 
little-endian, most significant bits to 0
-PIX_FMT_BGR444BE,  ///< packed BGR 4:4:4, 16bpp, (msb)4A 4B 4G 4R(lsb), 
big-endian, most significant bits to 1
+PIX_FMT_RGB444BE,  ///< packed RGB 4:4:4, 16bpp, (msb)4A 4R 4G 4B(lsb), 
big-endian, most significant bits to 0
 PIX_FMT_BGR444LE,  ///< packed BGR 4:4:4, 16bpp, (msb)4A 4B 4G 4R(lsb), 
little-endian, most significant bits to 1
+PIX_FMT_BGR444BE,  ///< packed BGR 4:4:4, 16bpp, (msb)4A 4B 4G 4R(lsb), 
big-endian, most significant bits to 1
 PIX_FMT_Y400A, ///< 8bit gray, 8bit alpha
 PIX_FMT_BGR48BE,   ///< packed RGB 16:16:16, 48bpp, 16B, 16G, 16R, the 
2-byte value for each R/G/B component is stored as big-endian
 PIX_FMT_BGR48LE,   ///< packed RGB 16:16:16, 48bpp, 16B, 16G, 16R, the 
2-byte value for each R/G/B component is stored as little-endian
diff --git a/libswscale/swscale.c b/libswscale/swscale.c
index 2830f26..d3eaf36 100644
--- a/libswscale/swscale.c
+++ b/libswscale/swscale.c
@@ -212,10 +212,11 @@ DECLARE_ALIGNED(8, const uint8_t, dither_8x8_220)[8][8]={
 static av_always_inline void yuv2yuvX16inC_template(const int16_t *lumFilter, 
const int16_t **lumSrc, int lumFilterSize,
 const int16_t *chrFilter, 
const int16_t **chrSrc, int chrFilterSize,
 const int16_t **alpSrc, 
uint16_t *dest, uint16_t *uDest, uint16_t *vDest, uint16_t *aDest,
-int dstW, int chrDstW, int 
big_endian)
+int dstW, int chrDstW, int 
big_endian, int output_bits)
 {
 //FIXME Optimize (just quickly written not optimized..)
 int i;
+int shift = 11 + 16 - output_bits;
 
 for (i = 0; i < dstW; i++) {
 int val = 1 << 10;
@@ -225,9 +226,9 @@ static av_always_inline void yuv2yuvX16inC_template(const 
int16_t *lumFilter, co
 val += lumSrc[j][i] * lumFilter[j];
 
 if (big_endian) {
-AV_WB16(&dest[i], av_clip_uint16(val >> 11));
+AV_WB16(&dest[i], av_clip_uint16(val >> shift));
 } else {
-AV_WL16(&dest[i], av_clip_uint16(val >> 11));
+AV_WL16(&dest[i], av_clip_uint16(val >> shift));
 }
 }
 
@@ -243,11 +244,11 @@ static av_always_inline void yuv2yuvX16inC_template(const 
int16_t *lumFilter, co
 }
 
 if (big_endian) {
-AV_WB16(&uDest[i], av_clip_uint16(u >> 11));
-AV_WB16(&vDest[i], av_clip_uint16(v >> 11));
+AV_WB16(&uDest[i], av_clip_uint16(u >> shift));
+AV_WB16(&vDest[i], av_clip_uint16(v >> shift));
 } else {
-AV_WL16(&uDest[i], av_clip_uint16(u >> 11));
-AV_WL16(&vDest[i], av_clip_uint16(v >> 11));
+AV_WL16(&uDest[i], av_clip_uint16(u >> shift));
+AV_WL16(&vDest[i], av_clip_uint16(v >> shift));
 }
 }
 }
@@ -261,9 +262,9 @@ static av_always_inline void yuv2yuvX16inC_template(const 
int16_t *lumFilter, co
 val += alpSrc[j][i] * lumFilter[j];
 
 if (big_endian) {
-AV_WB16(&aDest[i], av_clip_uint16(val >> 11));
+AV_WB16(&aDest[i], av_clip_uint16(val >> shift));
 } else {
-AV_WL16(&aDest[i], av_clip_uint16(val >> 11));
+AV_WL16(&aDest[i], av_clip_uint16(val >> shift));
 }
 }
 }
@@ -274,19 +275,28 @@ static inline void yuv2yuvX16inC(const int16_t 
*lumFilter, const int16_t **lumSr
  con

Re: [libav-devel] [PATCH] aac: workaround for compilation on cygwin

2011-05-11 Thread Reinhard Tartler
On Wed, May 11, 2011 at 17:25:50 (CEST), Alex Converse wrote:

> On Wed, May 11, 2011 at 5:45 AM, Reinhard Tartler  wrote:
>> On Wed, May 11, 2011 at 14:23:14 (CEST), Luca Barbato wrote:
>>
>>> On 5/11/11 1:51 PM, Reinhard Tartler wrote:
 On cygwin, math.h needs to be included before float.h because of a bug
 in the system headers. Including libavutil/libm.h first works around
 this issue.

 Longer discussion of the topic:
 http://thread.gmane.org/gmane.comp.video.ffmpeg.devel/128582
>>>
>>> If there isn't a saner solution ok. We should notify cygwin about that
>>> though.
>>
>> http://article.gmane.org/gmane.comp.video.ffmpeg.devel/128658
>>
>> Probably that's this 'discussion':
>>
>> http://thread.gmane.org/gmane.os.cygwin/125314/focus=125323
>>
>
> I'm having problems following that discussion:
>
> From: Matthias Andree  gmx.de>
>> On Wed, 02 Mar 2011, Víctor Paesa wrote:
>>
>> > Hi,
>> >
>> > In 1.7.7, log2f() is defined in math.h as
>> >
>> > extern float log2f _PARAMS((float));
>> > #if !defined(__cplusplus)
>> > #define log2f(x) (logf (x) / (float) _M_LOG2_E)
>> > #endif
>> >
>> > In 1.7.8, log2f() is defined in math.h as
>> >
>> > extern float log2f _PARAMS((float));
>> > #if !defined(__cplusplus)
>> > #define log2f(x) (logf (x) / (float_t) _M_LOG2_E)
>> > #endif
>> >
>> > This change broke the compilation of ffmpeg.
>> >
>> > Would it be possible to use again "float", instead of "float_t" ?
>>
>> Why? Fix ffmpeg instead. #include  should suffice:
>>
>
> A definition in math.h changed so the solution is to include 
> where does  come into this mess...

I'm surprised as well.

What I did was to play around with the #includes, and made these
observations:

 - libavuti/libm.h was included last
 - libavuti/libm.h #includes 
 - inserting a #include before the #include  directive
   fixes compilation (the ffmpeg 'solution')

With this, I've came up with the now pushed patch.

-- 
Gruesse/greetings,
Reinhard Tartler, KeyID 945348A4
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] Port SMPTE S302M audio decoder from FFmbc 0.3.

2011-05-11 Thread Diego Biurrun
On Mon, May 09, 2011 at 09:45:51AM -0700, Aℓex Converse wrote:
> On Mon, May 9, 2011 at 7:02 AM, Diego Biurrun  wrote:
> > On Mon, May 09, 2011 at 03:34:03PM +0200, Diego Biurrun wrote:
> >> On Thu, May 05, 2011 at 09:41:27AM -0700, Aℓex Converse wrote:
> >> > On Thu, May 5, 2011 at 2:39 AM, Diego Biurrun  wrote:
> >> > > Please trim your quotes, thank you.
> >> >
> >> > Maybe if you sent a patch on top of the patch you hijacked there would
> >> > be less to trim.
> >>
> >> For your perusal I attached the output of
> >>
> >>   git diff -w s302m_alex:libavcodec/s302m.c s302m:libavcodec/s302m.c
> >
> > Scratch that broken one, here comes the real deal.
> >
> 
> >  const uint8_t *buf = avpkt->data;
> > -int frame_size, buf_size = avpkt->size;
> > +int buf_size   = avpkt->size, frame_size;
> >
> > frame_size = s302m_parse_frame_header(avctx, buf, buf_size);
> 
> I really don't think this is any more readable. In fact I think it's
> arguably less readable.

Changed to

   const uint8_t *buf = avpkt->data;
   int buf_size   = avpkt->size;

   int frame_size = s302m_parse_frame_header(avctx, buf, buf_size);

and pushed.

Thanks for your patience, Diego
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [RFC] fix swscale for 9/10bit

2011-05-11 Thread Ronald S. Bultje
Hi,

attached is a RFC for fixing SWS for 9/10bit, as output by H264. It
takes endianness in account and does some other stuff. As you can see,
this stuff quickly gets hideous (e.g. planarCopyWrapper is a mess), so
I'd like some advice on how people think we should do this.

We need this fix so we can convert 10bitBE to 10bitLE and thereby fix
10bit H264 on BE systems (e.g. PPC), which are now correct except that
byte ordering for each word is inverted.

Ronald
diff --git a/libavutil/pixfmt.h b/libavutil/pixfmt.h
index 533eb9f..d88775f 100644
--- a/libavutil/pixfmt.h
+++ b/libavutil/pixfmt.h
@@ -128,10 +128,10 @@ enum PixelFormat {
 PIX_FMT_VDPAU_MPEG4,  ///< MPEG4 HW decoding with VDPAU, data[0] contains 
a vdpau_render_state struct which contains the bitstream of the slices as well 
as various fields extracted from headers
 PIX_FMT_DXVA2_VLD,///< HW decoding through DXVA2, Picture.data[3] 
contains a LPDIRECT3DSURFACE9 pointer
 
-PIX_FMT_RGB444BE,  ///< packed RGB 4:4:4, 16bpp, (msb)4A 4R 4G 4B(lsb), 
big-endian, most significant bits to 0
 PIX_FMT_RGB444LE,  ///< packed RGB 4:4:4, 16bpp, (msb)4A 4R 4G 4B(lsb), 
little-endian, most significant bits to 0
-PIX_FMT_BGR444BE,  ///< packed BGR 4:4:4, 16bpp, (msb)4A 4B 4G 4R(lsb), 
big-endian, most significant bits to 1
+PIX_FMT_RGB444BE,  ///< packed RGB 4:4:4, 16bpp, (msb)4A 4R 4G 4B(lsb), 
big-endian, most significant bits to 0
 PIX_FMT_BGR444LE,  ///< packed BGR 4:4:4, 16bpp, (msb)4A 4B 4G 4R(lsb), 
little-endian, most significant bits to 1
+PIX_FMT_BGR444BE,  ///< packed BGR 4:4:4, 16bpp, (msb)4A 4B 4G 4R(lsb), 
big-endian, most significant bits to 1
 PIX_FMT_Y400A, ///< 8bit gray, 8bit alpha
 PIX_FMT_BGR48BE,   ///< packed RGB 16:16:16, 48bpp, 16B, 16G, 16R, the 
2-byte value for each R/G/B component is stored as big-endian
 PIX_FMT_BGR48LE,   ///< packed RGB 16:16:16, 48bpp, 16B, 16G, 16R, the 
2-byte value for each R/G/B component is stored as little-endian
diff --git a/libswscale/swscale.c b/libswscale/swscale.c
index 2830f26..7a0a9a7 100644
--- a/libswscale/swscale.c
+++ b/libswscale/swscale.c
@@ -1669,25 +1669,124 @@ static int planarCopyWrapper(SwsContext *c, const 
uint8_t* src[], int srcStride[
 length*=2;
 fillPlane(dst[plane], dstStride[plane], length, height, y, 
(plane==3) ? 255 : 128);
 } else {
-if(isNBPS(c->srcFormat)) {
-const int depth = 
av_pix_fmt_descriptors[c->srcFormat].comp[plane].depth_minus1+1;
-uint16_t *srcPtr2 = (uint16_t*)srcPtr;
+if(is9_OR_10BPS(c->srcFormat)) {
+const int src_depth = 
av_pix_fmt_descriptors[c->srcFormat].comp[plane].depth_minus1+1;
+const int dst_depth = 
av_pix_fmt_descriptors[c->dstFormat].comp[plane].depth_minus1+1;
+const uint16_t *srcPtr2 = (const uint16_t*)srcPtr;
 
 if (is16BPS(c->dstFormat)) {
 uint16_t *dstPtr2 = (uint16_t*)dstPtr;
-for (i = 0; i < height; i++) {
-for (j = 0; j < length; j++)
-dstPtr2[j] = (srcPtr2[j]<<(16-depth)) | 
(srcPtr2[j]>>(2*depth-16));
-dstPtr2 += dstStride[plane]/2;
-srcPtr2 += srcStride[plane]/2;
+#define COPY9_OR_10TO16(rfunc, wfunc) \
+for (i = 0; i < height; i++) { \
+for (j = 0; j < length; j++) { \
+int srcpx = rfunc(&srcPtr2[j]); \
+wfunc(&dstPtr2[j], (srcpx<<(16-src_depth)) | 
(srcpx>>(2*src_depth-16))); \
+} \
+dstPtr2 += dstStride[plane]/2; \
+srcPtr2 += srcStride[plane]/2; \
+}
+if (isBE(c->dstFormat)) {
+if (isBE(c->srcFormat)) {
+COPY9_OR_10TO16(AV_RB16, AV_WB16);
+} else {
+COPY9_OR_10TO16(AV_RL16, AV_WB16);
+}
+} else {
+if (isBE(c->srcFormat)) {
+COPY9_OR_10TO16(AV_RB16, AV_WL16);
+} else {
+COPY9_OR_10TO16(AV_RL16, AV_WL16);
+}
+}
+} else if (is9_OR_10BPS(c->dstFormat)) {
+uint16_t *dstPtr2 = (uint16_t*)dstPtr;
+#define COPY9_OR_10TO9_OR_10(loop) \
+for (i = 0; i < height; i++) { \
+for (j = 0; j < length; j++) { \
+loop; \
+} \
+dstPtr2 += dstStride[plane]/2; \
+srcPtr2 += srcStride[plane]/2; \
+}
+#define COPY9_OR_10TO9_OR_10_2(rfunc, wfunc) \
+if (dst_depth > src_depth) { \
+  

Re: [libav-devel] [PATCH] aac: workaround for compilation on cygwin

2011-05-11 Thread Alex Converse
On Wed, May 11, 2011 at 5:45 AM, Reinhard Tartler  wrote:
> On Wed, May 11, 2011 at 14:23:14 (CEST), Luca Barbato wrote:
>
>> On 5/11/11 1:51 PM, Reinhard Tartler wrote:
>>> On cygwin, math.h needs to be included before float.h because of a bug
>>> in the system headers. Including libavutil/libm.h first works around
>>> this issue.
>>>
>>> Longer discussion of the topic:
>>> http://thread.gmane.org/gmane.comp.video.ffmpeg.devel/128582
>>
>> If there isn't a saner solution ok. We should notify cygwin about that
>> though.
>
> http://article.gmane.org/gmane.comp.video.ffmpeg.devel/128658
>
> Probably that's this 'discussion':
>
> http://thread.gmane.org/gmane.os.cygwin/125314/focus=125323
>

I'm having problems following that discussion:

From: Matthias Andree  gmx.de>
> On Wed, 02 Mar 2011, Víctor Paesa wrote:
>
> > Hi,
> >
> > In 1.7.7, log2f() is defined in math.h as
> >
> > extern float log2f _PARAMS((float));
> > #if !defined(__cplusplus)
> > #define log2f(x) (logf (x) / (float) _M_LOG2_E)
> > #endif
> >
> > In 1.7.8, log2f() is defined in math.h as
> >
> > extern float log2f _PARAMS((float));
> > #if !defined(__cplusplus)
> > #define log2f(x) (logf (x) / (float_t) _M_LOG2_E)
> > #endif
> >
> > This change broke the compilation of ffmpeg.
> >
> > Would it be possible to use again "float", instead of "float_t" ?
>
> Why? Fix ffmpeg instead. #include  should suffice:
>

A definition in math.h changed so the solution is to include 
where does  come into this mess...
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] Fix crash of interlaced MPEG2 decoding

2011-05-11 Thread Ronald S. Bultje
Hi,

On Sun, Mar 27, 2011 at 3:41 PM, Reinhard Tartler  wrote:
> From: Anatoly Nenashev 
>
> Problem description, preliminary review discussion at
> http://thread.gmane.org/gmane.comp.video.ffmpeg.devel/127731
> ---
>  libavcodec/mpegvideo.c |    9 +++--
>  1 files changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
> index 1c5ff27..1fb2522 100644
> --- a/libavcodec/mpegvideo.c
> +++ b/libavcodec/mpegvideo.c
> @@ -991,8 +991,13 @@ int MPV_frame_start(MpegEncContext *s, AVCodecContext 
> *avctx)
>         s->pict_type, s->dropable);*/
>
>     if(s->codec_id != CODEC_ID_H264){
> -        if((s->last_picture_ptr==NULL || s->last_picture_ptr->data[0]==NULL) 
> && s->pict_type!=FF_I_TYPE){
> -            av_log(avctx, AV_LOG_ERROR, "warning: first frame is no 
> keyframe\n");
> +        if((s->last_picture_ptr==NULL || s->last_picture_ptr->data[0]==NULL) 
> &&
> +           (s->pict_type!=FF_I_TYPE || s->picture_structure != PICT_FRAME)){
> +            if (s->pict_type != FF_I_TYPE)
> +                av_log(avctx, AV_LOG_ERROR, "warning: first frame is no 
> keyframe\n");
> +            else if (s->picture_structure != PICT_FRAME)
> +                av_log(avctx, AV_LOG_INFO, "allocate dummy last picture for 
> field based first keyframe\n");

I think this is OK.

Ronald
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] upload.libav.org is down

2011-05-11 Thread aviad rozenhek
On Wed, May 11, 2011 at 15:28, Luca Barbato  wrote:

> On 5/11/11 11:53 AM, aviad rozenhek wrote:
>
>> samples for bug reports cannot be uploaded :-(
>>
>>
> The replacement box isn't set with that ip yet =|
>
> meantime please use roundup and tell me if there are problems uploading
> larger files.
>
> lu


is it possible to upload a 100mb file to roundup?
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 1/3] lavc: deprecate named constants for deprecated antialias_algo.

2011-05-11 Thread Anton Khirnov
On Wed, 11 May 2011 09:05:50 -0400, "Ronald S. Bultje"  
wrote:
> Hi,
> 
> On Wed, May 11, 2011 at 7:57 AM, Anton Khirnov  wrote:
> > ---
> > ??libavcodec/options.c | ?? ??2 +-
> > ??1 files changed, 1 insertions(+), 1 deletions(-)
> >
> > diff --git a/libavcodec/options.c b/libavcodec/options.c
> > index b22e53d..9c714fb 100644
> > --- a/libavcodec/options.c
> > +++ b/libavcodec/options.c
> > @@ -305,11 +305,11 @@ static const AVOption options[]={
> > ??{"error", NULL, OFFSET(error_rate), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, 
> > INT_MIN, INT_MAX, V|E},
> > ??#if FF_API_ANTIALIAS_ALGO
> > ??{"antialias", "MP3 antialias algorithm", OFFSET(antialias_algo), 
> > FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|D, "aa"},
> > -#endif
> > ??{"auto", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_AA_AUTO }, INT_MIN, 
> > INT_MAX, V|D, "aa"},
> > ??{"fastint", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_AA_FASTINT }, INT_MIN, 
> > INT_MAX, V|D, "aa"},
> > ??{"int", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_AA_INT }, INT_MIN, 
> > INT_MAX, V|D, "aa"},
> > ??{"float", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_AA_FLOAT }, INT_MIN, 
> > INT_MAX, V|D, "aa"},
> > +#endif
> 
> Do these options do anything? I mean, you could simply remove them if
> they don't do anything, maybe.o

It might be considered incompatible for some values of incompatible.
Anyway, there's no harm in keeping them until the main option is
removed.

--
Anton Khirnov
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 1/3] lavc: deprecate named constants for deprecated antialias_algo.

2011-05-11 Thread Ronald S. Bultje
Hi,

On Wed, May 11, 2011 at 7:57 AM, Anton Khirnov  wrote:
> ---
>  libavcodec/options.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/libavcodec/options.c b/libavcodec/options.c
> index b22e53d..9c714fb 100644
> --- a/libavcodec/options.c
> +++ b/libavcodec/options.c
> @@ -305,11 +305,11 @@ static const AVOption options[]={
>  {"error", NULL, OFFSET(error_rate), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, 
> INT_MIN, INT_MAX, V|E},
>  #if FF_API_ANTIALIAS_ALGO
>  {"antialias", "MP3 antialias algorithm", OFFSET(antialias_algo), 
> FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|D, "aa"},
> -#endif
>  {"auto", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_AA_AUTO }, INT_MIN, INT_MAX, 
> V|D, "aa"},
>  {"fastint", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_AA_FASTINT }, INT_MIN, 
> INT_MAX, V|D, "aa"},
>  {"int", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_AA_INT }, INT_MIN, INT_MAX, 
> V|D, "aa"},
>  {"float", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_AA_FLOAT }, INT_MIN, 
> INT_MAX, V|D, "aa"},
> +#endif

Do these options do anything? I mean, you could simply remove them if
they don't do anything, maybe.

But regardless, OK.

Ronald
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 2/3] flacenc: use proper initializers for AVOption default values.

2011-05-11 Thread Ronald S. Bultje
Hi,

On Wed, May 11, 2011 at 7:57 AM, Anton Khirnov  wrote:
> default_val was recently changes from double to a union, current code
> wasn't updated for that.
> ---
>  libavcodec/flacenc.c |   32 
>  1 files changed, 16 insertions(+), 16 deletions(-)

OK.

Ronald
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 3/3] doc/APIchanges: fill in missing hashes and dates.

2011-05-11 Thread Ronald S. Bultje
Hi,

On Wed, May 11, 2011 at 7:57 AM, Anton Khirnov  wrote:
> ---
>  doc/APIchanges |    8 
>  1 files changed, 4 insertions(+), 4 deletions(-)

OK, thanks.

Ronald
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] h264pred: fix one more aliasing violation.

2011-05-11 Thread Måns Rullgård
"Ronald S. Bultje"  writes:

> ---
>  libavcodec/h264pred_template.c |6 --
>  1 files changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/libavcodec/h264pred_template.c b/libavcodec/h264pred_template.c
> index c600133..1c1fe0b 100644
> --- a/libavcodec/h264pred_template.c
> +++ b/libavcodec/h264pred_template.c
> @@ -695,10 +695,12 @@ static void FUNCC(pred8x8l_horizontal)(uint8_t *_src, 
> int has_topleft, int has_t
>  {
>  pixel *src = (pixel*)_src;
>  int stride = _stride/sizeof(pixel);
> +pixel4 a;
>  
>  PREDICT_8x8_LOAD_LEFT;
> -#define ROW(y) ((pixel4*)(src+y*stride))[0] =\
> -   ((pixel4*)(src+y*stride))[1] = PIXEL_SPLAT_X4(l##y)
> +#define ROW(y) a = PIXEL_SPLAT_X4(l##y); \
> +   AV_WN4PA(src+y*stride, a); \
> +   AV_WN4PA(src+y*stride+4, a);
>  ROW(0); ROW(1); ROW(2); ROW(3); ROW(4); ROW(5); ROW(6); ROW(7);
>  #undef ROW
>  }
> -- 

Looks OK.

-- 
Måns Rullgård
m...@mansr.com
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH] Avoid divide by zero in compute_avg_bitrate()

2011-05-11 Thread Tomas Härdin

Hi

The attached patch fixes a possibility for movenc.c to SIGFPE if 
trackDuration is zero when writing esds. This can happen if the user 
manages to mux a single AAC packet with dts = 0 and duration = 0.


/Tomas
>From 7dbf9ac26ca677fc664a4569601bb0204e8410be Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tomas=20H=C3=A4rdin?= 
Date: Wed, 11 May 2011 09:47:50 +0200
Subject: [PATCH] Avoid divide by zero in compute_avg_bitrate()

This can happen if muxing a single AAC packet with duration = 0
---
 libavformat/movenc.c |4 
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index a3d470a..d950664 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -261,6 +261,10 @@ static unsigned compute_avg_bitrate(MOVTrack *track)
 {
 uint64_t size = 0;
 int i;
+
+if (!track->trackDuration)
+return 0;
+
 for (i = 0; i < track->entry; i++)
 size += track->cluster[i].size;
 return size * 8 * track->timescale / track->trackDuration;
-- 
1.7.1

___
ffmpeg-devel mailing list
ffmpeg-de...@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] aac: workaround for compilation on cygwin

2011-05-11 Thread Reinhard Tartler
On Wed, May 11, 2011 at 14:23:14 (CEST), Luca Barbato wrote:

> On 5/11/11 1:51 PM, Reinhard Tartler wrote:
>> On cygwin, math.h needs to be included before float.h because of a bug
>> in the system headers. Including libavutil/libm.h first works around
>> this issue.
>>
>> Longer discussion of the topic:
>> http://thread.gmane.org/gmane.comp.video.ffmpeg.devel/128582
>
> If there isn't a saner solution ok. We should notify cygwin about that
> though.

http://article.gmane.org/gmane.comp.video.ffmpeg.devel/128658

Probably that's this 'discussion':

http://thread.gmane.org/gmane.os.cygwin/125314/focus=125323

-- 
Gruesse/greetings,
Reinhard Tartler, KeyID 945348A4
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] PIX_FMT_422P10 support

2011-05-11 Thread Luca Barbato

On 5/11/11 10:11 AM, Reinhard Tartler wrote:

I guess the commit message is too terse, suggestions welcome.

This should unbreak mplayer compilation.



swscale: extend YUV422p support to 10bits depth

This should unbreak mplayer

lu
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH] h264pred: fix one more aliasing violation.

2011-05-11 Thread Ronald S. Bultje
---
 libavcodec/h264pred_template.c |6 --
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/libavcodec/h264pred_template.c b/libavcodec/h264pred_template.c
index c600133..1c1fe0b 100644
--- a/libavcodec/h264pred_template.c
+++ b/libavcodec/h264pred_template.c
@@ -695,10 +695,12 @@ static void FUNCC(pred8x8l_horizontal)(uint8_t *_src, int 
has_topleft, int has_t
 {
 pixel *src = (pixel*)_src;
 int stride = _stride/sizeof(pixel);
+pixel4 a;
 
 PREDICT_8x8_LOAD_LEFT;
-#define ROW(y) ((pixel4*)(src+y*stride))[0] =\
-   ((pixel4*)(src+y*stride))[1] = PIXEL_SPLAT_X4(l##y)
+#define ROW(y) a = PIXEL_SPLAT_X4(l##y); \
+   AV_WN4PA(src+y*stride, a); \
+   AV_WN4PA(src+y*stride+4, a);
 ROW(0); ROW(1); ROW(2); ROW(3); ROW(4); ROW(5); ROW(6); ROW(7);
 #undef ROW
 }
-- 
1.7.2.1

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] upload.libav.org is down

2011-05-11 Thread Luca Barbato

On 5/11/11 11:53 AM, aviad rozenhek wrote:

samples for bug reports cannot be uploaded :-(



The replacement box isn't set with that ip yet =|

meantime please use roundup and tell me if there are problems uploading 
larger files.


lu
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] aac: workaround for compilation on cygwin

2011-05-11 Thread Luca Barbato

On 5/11/11 1:51 PM, Reinhard Tartler wrote:

On cygwin, math.h needs to be included before float.h because of a bug
in the system headers. Including libavutil/libm.h first works around
this issue.

Longer discussion of the topic:
http://thread.gmane.org/gmane.comp.video.ffmpeg.devel/128582


If there isn't a saner solution ok. We should notify cygwin about that 
though.


lu
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] ffmpeg: Simplify decode loop condition to not use next_pts

2011-05-11 Thread Luca Barbato

On 5/11/11 1:03 PM, Ronald S. Bultje wrote:

make THREADS=9 fate with your mpeg/h264 changes applied does
definitely change (for the better).

I can try to explain, but really all it comes down to is that the
timestamping code is broken (mixing {,next_,prev_}{dts,pts}). Nobody
wants to hear that.



We could make a list of long-standing issues we should tackle for the 
0.9, so far for me one is swscale the other is getting timestamps better.


lu
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] tiff: add support for inverted FillOrder for uncompressed data

2011-05-11 Thread Diego Biurrun
On Wed, May 11, 2011 at 12:22:14PM +0200, Stefano Sabatini wrote:
> On date Wednesday 2011-05-11 11:47:14 +0200, Kostya encoded:
> > On Mon, May 09, 2011 at 09:59:20PM +0200, Stefano Sabatini wrote:
> > > Fix decoding of file b.tif, trac issue #168.
> > > --- a/libavcodec/tiff.c
> > > +++ b/libavcodec/tiff.c
> > > @@ -162,13 +162,20 @@ static int tiff_unpack_strip(TiffContext *s, 
> > > uint8_t* dst, int stride, const uin
> > >  return ret;
> > >  }
> > >  for(line = 0; line < lines; line++){
> > > +int i;
> > > +
> > >  if(src - ssrc > size){
> > >  av_log(s->avctx, AV_LOG_ERROR, "Source data overread\n");
> > >  return -1;
> > >  }
> > >  switch(s->compr){
> > >  case TIFF_RAW:
> > > -memcpy(dst, src, width);
> > > +if (!s->fill_order) {
> > > +memcpy(dst, src, width);
> > > +} else {
> > > +for (i = 0; i < width; i++)
> > > +dst[i] = av_reverse[src[i]];
> > > +}
> > >  src += width;
> > >  break;
> > >  case TIFF_PACKBITS:
> > > -- 
> > 
> > looks ok (though you can move "int i;" declaration inside else{} block IMO)
> 
> Sure, updated.

Pushed - thanks Stefano.

Diego
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 2/3] flacenc: use proper initializers for AVOption default values.

2011-05-11 Thread Anton Khirnov
default_val was recently changes from double to a union, current code
wasn't updated for that.
---
 libavcodec/flacenc.c |   32 
 1 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/libavcodec/flacenc.c b/libavcodec/flacenc.c
index 7685ff6..8624a6d 100644
--- a/libavcodec/flacenc.c
+++ b/libavcodec/flacenc.c
@@ -1330,22 +1330,22 @@ static av_cold int flac_encode_close(AVCodecContext 
*avctx)
 
 #define FLAGS AV_OPT_FLAG_ENCODING_PARAM | AV_OPT_FLAG_AUDIO_PARAM
 static const AVOption options[] = {
-{ "lpc_coeff_precision", "LPC coefficient precision", 
offsetof(FlacEncodeContext, options.lpc_coeff_precision), FF_OPT_TYPE_INT, 15, 
0, MAX_LPC_PRECISION, FLAGS },
-{ "lpc_type", "LPC algorithm", offsetof(FlacEncodeContext, options.lpc_type), 
FF_OPT_TYPE_INT, FF_LPC_TYPE_DEFAULT, FF_LPC_TYPE_DEFAULT, FF_LPC_TYPE_NB-1, 
FLAGS, "lpc_type" },
-{ "none", NULL, 0, FF_OPT_TYPE_CONST, FF_LPC_TYPE_NONE, INT_MIN, 
INT_MAX, FLAGS, "lpc_type" },
-{ "fixed",NULL, 0, FF_OPT_TYPE_CONST, FF_LPC_TYPE_FIXED,INT_MIN, 
INT_MAX, FLAGS, "lpc_type" },
-{ "levinson", NULL, 0, FF_OPT_TYPE_CONST, FF_LPC_TYPE_LEVINSON, INT_MIN, 
INT_MAX, FLAGS, "lpc_type" },
-{ "cholesky", NULL, 0, FF_OPT_TYPE_CONST, FF_LPC_TYPE_CHOLESKY, INT_MIN, 
INT_MAX, FLAGS, "lpc_type" },
-{ "lpc_passes", "Number of passes to use for Cholesky factorization during LPC 
analysis", offsetof(FlacEncodeContext, options.lpc_passes),  FF_OPT_TYPE_INT, 
-1, INT_MIN, INT_MAX, FLAGS },
-{ "min_partition_order",  NULL, offsetof(FlacEncodeContext, 
options.min_partition_order),  FF_OPT_TYPE_INT, -1,  -1, 
MAX_PARTITION_ORDER, FLAGS },
-{ "max_partition_order",  NULL, offsetof(FlacEncodeContext, 
options.max_partition_order),  FF_OPT_TYPE_INT, -1,  -1, 
MAX_PARTITION_ORDER, FLAGS },
-{ "prediction_order_method", "Search method for selecting prediction order", 
offsetof(FlacEncodeContext, options.prediction_order_method), FF_OPT_TYPE_INT, 
-1, -1, ORDER_METHOD_LOG, FLAGS, "predm" },
-{ "estimation", NULL, 0, FF_OPT_TYPE_CONST, ORDER_METHOD_EST,INT_MIN, 
INT_MAX, FLAGS, "predm" },
-{ "2level", NULL, 0, FF_OPT_TYPE_CONST, ORDER_METHOD_2LEVEL, INT_MIN, 
INT_MAX, FLAGS, "predm" },
-{ "4level", NULL, 0, FF_OPT_TYPE_CONST, ORDER_METHOD_4LEVEL, INT_MIN, 
INT_MAX, FLAGS, "predm" },
-{ "8level", NULL, 0, FF_OPT_TYPE_CONST, ORDER_METHOD_8LEVEL, INT_MIN, 
INT_MAX, FLAGS, "predm" },
-{ "search", NULL, 0, FF_OPT_TYPE_CONST, ORDER_METHOD_SEARCH, INT_MIN, 
INT_MAX, FLAGS, "predm" },
-{ "log",NULL, 0, FF_OPT_TYPE_CONST, ORDER_METHOD_LOG,INT_MIN, 
INT_MAX, FLAGS, "predm" },
+{ "lpc_coeff_precision", "LPC coefficient precision", 
offsetof(FlacEncodeContext, options.lpc_coeff_precision), FF_OPT_TYPE_INT, 
{.dbl = 15 }, 0, MAX_LPC_PRECISION, FLAGS },
+{ "lpc_type", "LPC algorithm", offsetof(FlacEncodeContext, options.lpc_type), 
FF_OPT_TYPE_INT, {.dbl = FF_LPC_TYPE_DEFAULT }, FF_LPC_TYPE_DEFAULT, 
FF_LPC_TYPE_NB-1, FLAGS, "lpc_type" },
+{ "none", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_LPC_TYPE_NONE }, 
INT_MIN, INT_MAX, FLAGS, "lpc_type" },
+{ "fixed",NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_LPC_TYPE_FIXED },
INT_MIN, INT_MAX, FLAGS, "lpc_type" },
+{ "levinson", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_LPC_TYPE_LEVINSON }, 
INT_MIN, INT_MAX, FLAGS, "lpc_type" },
+{ "cholesky", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_LPC_TYPE_CHOLESKY }, 
INT_MIN, INT_MAX, FLAGS, "lpc_type" },
+{ "lpc_passes", "Number of passes to use for Cholesky factorization during LPC 
analysis", offsetof(FlacEncodeContext, options.lpc_passes),  FF_OPT_TYPE_INT, 
{.dbl = -1 }, INT_MIN, INT_MAX, FLAGS },
+{ "min_partition_order",  NULL, offsetof(FlacEncodeContext, 
options.min_partition_order),  FF_OPT_TYPE_INT, {.dbl = -1 },  -1, 
MAX_PARTITION_ORDER, FLAGS },
+{ "max_partition_order",  NULL, offsetof(FlacEncodeContext, 
options.max_partition_order),  FF_OPT_TYPE_INT, {.dbl = -1 },  -1, 
MAX_PARTITION_ORDER, FLAGS },
+{ "prediction_order_method", "Search method for selecting prediction order", 
offsetof(FlacEncodeContext, options.prediction_order_method), FF_OPT_TYPE_INT, 
{.dbl = -1 }, -1, ORDER_METHOD_LOG, FLAGS, "predm" },
+{ "estimation", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = ORDER_METHOD_EST },
INT_MIN, INT_MAX, FLAGS, "predm" },
+{ "2level", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = ORDER_METHOD_2LEVEL }, 
INT_MIN, INT_MAX, FLAGS, "predm" },
+{ "4level", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = ORDER_METHOD_4LEVEL }, 
INT_MIN, INT_MAX, FLAGS, "predm" },
+{ "8level", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = ORDER_METHOD_8LEVEL }, 
INT_MIN, INT_MAX, FLAGS, "predm" },
+{ "search", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = ORDER_METHOD_SEARCH }, 
INT_MIN, INT_MAX, FLAGS, "predm" },
+{ "log",NULL, 0, FF_OPT_TYPE_CONST, {.dbl = ORDER_METHOD_LOG },
INT_MIN, INT_MAX, FLAGS, "predm" },
 { NULL },
 };
 
-- 
1.7.5.1

___
libav-devel mailing list
libav-devel@libav

[libav-devel] [PATCH 3/3] doc/APIchanges: fill in missing hashes and dates.

2011-05-11 Thread Anton Khirnov
---
 doc/APIchanges |8 
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 0995b19..ee96ddf 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -13,21 +13,21 @@ libavutil:   2011-04-18
 
 API changes, most recent first:
 
-2011-05-10 - xxx - lavc 53.3.0 - avcodec.h
+2011-05-10 - 188dea1 - lavc 53.3.0 - avcodec.h
   Deprecate AVLPCType and the following fields in
   AVCodecContext: lpc_coeff_precision, prediction_order_method,
   min_partition_order, max_partition_order, lpc_type, lpc_passes.
   Corresponding FLAC encoder options should be used instead.
 
-2011-04-XX - bebe72f - lavu 51.1.0 - avutil.h
+2011-04-26 - bebe72f - lavu 51.1.0 - avutil.h
   Add AVPictureType enum and av_get_picture_type_char(), deprecate
   FF_*_TYPE defines and av_get_pict_type_char() defined in
   libavcodec/avcodec.h.
 
-2011-04-xx - 10d3940 - lavfi 2.3.0 - avfilter.h
+2011-04-26 - 10d3940 - lavfi 2.3.0 - avfilter.h
   Add pict_type and key_frame fields to AVFilterBufferRefVideo.
 
-2011-04-xx - 7a11c82 - lavfi 2.2.0 - vsrc_buffer
+2011-04-26 - 7a11c82 - lavfi 2.2.0 - vsrc_buffer
   Add sample_aspect_ratio fields to vsrc_buffer arguments
 
 2011-04-21 - 94f7451 - lavc 53.1.0 - avcodec.h
-- 
1.7.5.1

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 1/3] lavc: deprecate named constants for deprecated antialias_algo.

2011-05-11 Thread Anton Khirnov
---
 libavcodec/options.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/libavcodec/options.c b/libavcodec/options.c
index b22e53d..9c714fb 100644
--- a/libavcodec/options.c
+++ b/libavcodec/options.c
@@ -305,11 +305,11 @@ static const AVOption options[]={
 {"error", NULL, OFFSET(error_rate), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, 
INT_MIN, INT_MAX, V|E},
 #if FF_API_ANTIALIAS_ALGO
 {"antialias", "MP3 antialias algorithm", OFFSET(antialias_algo), 
FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|D, "aa"},
-#endif
 {"auto", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_AA_AUTO }, INT_MIN, INT_MAX, 
V|D, "aa"},
 {"fastint", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_AA_FASTINT }, INT_MIN, 
INT_MAX, V|D, "aa"},
 {"int", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_AA_INT }, INT_MIN, INT_MAX, 
V|D, "aa"},
 {"float", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_AA_FLOAT }, INT_MIN, INT_MAX, 
V|D, "aa"},
+#endif
 {"qns", "quantizer noise shaping", OFFSET(quantizer_noise_shaping), 
FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E},
 {"threads", NULL, OFFSET(thread_count), FF_OPT_TYPE_INT, {.dbl = 1 }, INT_MIN, 
INT_MAX, V|E|D},
 {"me_threshold", "motion estimaton threshold", OFFSET(me_threshold), 
FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX},
-- 
1.7.5.1

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH] aac: workaround for compilation on cygwin

2011-05-11 Thread Reinhard Tartler
On cygwin, math.h needs to be included before float.h because of a bug
in the system headers. Including libavutil/libm.h first works around
this issue.

Longer discussion of the topic:
http://thread.gmane.org/gmane.comp.video.ffmpeg.devel/128582
---
 libavcodec/aaccoder.c |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/libavcodec/aaccoder.c b/libavcodec/aaccoder.c
index 15fe430..83d3734 100644
--- a/libavcodec/aaccoder.c
+++ b/libavcodec/aaccoder.c
@@ -30,13 +30,14 @@
  * add sane pulse detection
  ***/
 
+#include "libavutil/libm.h" // brought forward to work around cygwin header 
breakage
+
 #include 
 #include "avcodec.h"
 #include "put_bits.h"
 #include "aac.h"
 #include "aacenc.h"
 #include "aactab.h"
-#include "libavutil/libm.h"
 
 /** bits needed to code codebook run value for long windows */
 static const uint8_t run_value_bits_long[64] = {
-- 
1.7.4.1

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 2/2] Eliminate BSD hacks.

2011-05-11 Thread Måns Rullgård
Diego Biurrun  writes:

> These hacks are no longer necessary now that _XOPEN_SOURCE is added
> unconditionally to CPPFLAGS.
> ---
>  libavdevice/bktr.c  |3 ---
>  libavutil/ppc/cpu.c |2 --
>  2 files changed, 0 insertions(+), 5 deletions(-)
>
> diff --git a/libavdevice/bktr.c b/libavdevice/bktr.c
> index 3e705a0..dad5c83 100644
> --- a/libavdevice/bktr.c
> +++ b/libavdevice/bktr.c
> @@ -24,9 +24,6 @@
>   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 
> USA
>   */
>  
> -#define _BSD_SOURCE 1
> -#define _NETBSD_SOURCE
> -
>  #include "libavformat/avformat.h"
>  #if HAVE_DEV_BKTR_IOCTL_METEOR_H && HAVE_DEV_BKTR_IOCTL_BT848_H
>  # include 
> diff --git a/libavutil/ppc/cpu.c b/libavutil/ppc/cpu.c
> index 6b122ed..0025711 100644
> --- a/libavutil/ppc/cpu.c
> +++ b/libavutil/ppc/cpu.c
> @@ -17,10 +17,8 @@
>   */
>  
>  #ifdef __APPLE__
> -#undef _POSIX_C_SOURCE
>  #include 
>  #elif defined(__OpenBSD__)
> -#undef _POSIX_C_SOURCE
>  #include 
>  #include 
>  #include 
> -- 

Should be OK.

-- 
Måns Rullgård
m...@mansr.com
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] don't require yasm on cygwin

2011-05-11 Thread Måns Rullgård
Reinhard Tartler  writes:

> seems that cygwin doesn't ship a yasm package
> ---
>  configure |9 ++---
>  1 files changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/configure b/configure
> index 955a568..fce0cf2 100755
> --- a/configure
> +++ b/configure
> @@ -2440,6 +2440,7 @@ case $target_os in
>  add_cppflags -U__STRICT_ANSI__
>  ;;
>  cygwin*)
> +enable cygwin
>  target_os=cygwin
>  shlibdir_default="$bindir_default"
>  SLIBPREF="cyg"
> @@ -2719,9 +2720,11 @@ EOF
>  elf*) enabled debug && append YASMFLAGS $yasm_debug ;;
>  esac
>  
> -check_yasm "pextrd [eax], xmm0, 1" && enable yasm ||
> -die "yasm not found, use --disable-yasm for a crippled build"
> -check_yasm "vpaddw xmm0, xmm0, xmm0" || disable avx
> +if ! enabled cygwin; then
> +check_yasm "pextrd [eax], xmm0, 1" && enable yasm ||
> +die "yasm not found, use --disable-yasm for a crippled build"
> +check_yasm "vpaddw xmm0, xmm0, xmm0" || disable avx
> +fi
>  fi
>  
>  case "$cpu" in
> -- 

Summarily rejected.

-- 
Måns Rullgård
m...@mansr.com
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 1/2] configure: Add -D_XOPEN_SOURCE=600 to global CPPFLAGS.

2011-05-11 Thread Måns Rullgård
Diego Biurrun  writes:

> We already require this XSI standard in many files in Libav.
> Furthermore enabling this globally should expose necessary
> functionality that gets hidden on some (BSD) systems if
> _POSIX_C_SOURCE is enabled without _XOPEN_SOURCE.
> ---
>  configure|3 +--
>  doc/general.texi |8 
>  ffmpeg.c |3 ---
>  ffplay.c |2 --
>  ffserver.c   |2 --
>  libavcodec/libxvidff.c   |3 ---
>  libavdevice/bktr.c   |1 -
>  libavdevice/x11grab.c|2 --
>  libavformat/applehttp.c  |1 -
>  libavformat/applehttpproto.c |1 -
>  libavformat/avio.c   |3 +--
>  libavformat/rtpdec.c |3 ---
>  12 files changed, 2 insertions(+), 30 deletions(-)
>
> diff --git a/configure b/configure
> index 955a568..1eebce9 100755
> --- a/configure
> +++ b/configure
> @@ -2316,7 +2316,7 @@ if test "$?" != 0; then
>  die "C compiler test failed."
>  fi
>  
> -add_cppflags -D_ISOC99_SOURCE -D_POSIX_C_SOURCE=200112
> +add_cppflags -D_ISOC99_SOURCE -D_XOPEN_SOURCE=600 -D_POSIX_C_SOURCE=200112

Adding at the end of the line would put them in alphabetical order.

Rest of patch seems OK.

-- 
Måns Rullgård
m...@mansr.com
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] don't require yasm on cygwin

2011-05-11 Thread Ronald S. Bultje
Hi,

On Wed, May 11, 2011 at 7:39 AM, Reinhard Tartler  wrote:
> seems that cygwin doesn't ship a yasm package
> ---
>  configure |    9 ++---
>  1 files changed, 6 insertions(+), 3 deletions(-)

No, they should install it manually or --disable-yasm. You don't want
people to think we suck whereas in reality, they crippled their build.

(IMO.)

Ronald
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH] don't require yasm on cygwin

2011-05-11 Thread Reinhard Tartler
seems that cygwin doesn't ship a yasm package
---
 configure |9 ++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/configure b/configure
index 955a568..fce0cf2 100755
--- a/configure
+++ b/configure
@@ -2440,6 +2440,7 @@ case $target_os in
 add_cppflags -U__STRICT_ANSI__
 ;;
 cygwin*)
+enable cygwin
 target_os=cygwin
 shlibdir_default="$bindir_default"
 SLIBPREF="cyg"
@@ -2719,9 +2720,11 @@ EOF
 elf*) enabled debug && append YASMFLAGS $yasm_debug ;;
 esac
 
-check_yasm "pextrd [eax], xmm0, 1" && enable yasm ||
-die "yasm not found, use --disable-yasm for a crippled build"
-check_yasm "vpaddw xmm0, xmm0, xmm0" || disable avx
+if ! enabled cygwin; then
+check_yasm "pextrd [eax], xmm0, 1" && enable yasm ||
+die "yasm not found, use --disable-yasm for a crippled build"
+check_yasm "vpaddw xmm0, xmm0, xmm0" || disable avx
+fi
 fi
 
 case "$cpu" in
-- 
1.7.4.1

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [RFC] don't require yasm on cygwin

2011-05-11 Thread Reinhard Tartler

I'm undicded myself about this patch. WDY.
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 2/2] Eliminate BSD hacks.

2011-05-11 Thread Diego Biurrun
These hacks are no longer necessary now that _XOPEN_SOURCE is added
unconditionally to CPPFLAGS.
---
 libavdevice/bktr.c  |3 ---
 libavutil/ppc/cpu.c |2 --
 2 files changed, 0 insertions(+), 5 deletions(-)

diff --git a/libavdevice/bktr.c b/libavdevice/bktr.c
index 3e705a0..dad5c83 100644
--- a/libavdevice/bktr.c
+++ b/libavdevice/bktr.c
@@ -24,9 +24,6 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#define _BSD_SOURCE 1
-#define _NETBSD_SOURCE
-
 #include "libavformat/avformat.h"
 #if HAVE_DEV_BKTR_IOCTL_METEOR_H && HAVE_DEV_BKTR_IOCTL_BT848_H
 # include 
diff --git a/libavutil/ppc/cpu.c b/libavutil/ppc/cpu.c
index 6b122ed..0025711 100644
--- a/libavutil/ppc/cpu.c
+++ b/libavutil/ppc/cpu.c
@@ -17,10 +17,8 @@
  */
 
 #ifdef __APPLE__
-#undef _POSIX_C_SOURCE
 #include 
 #elif defined(__OpenBSD__)
-#undef _POSIX_C_SOURCE
 #include 
 #include 
 #include 
-- 
1.7.1

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 1/2] configure: Add -D_XOPEN_SOURCE=600 to global CPPFLAGS.

2011-05-11 Thread Diego Biurrun
We already require this XSI standard in many files in Libav.
Furthermore enabling this globally should expose necessary
functionality that gets hidden on some (BSD) systems if
_POSIX_C_SOURCE is enabled without _XOPEN_SOURCE.
---
 configure|3 +--
 doc/general.texi |8 
 ffmpeg.c |3 ---
 ffplay.c |2 --
 ffserver.c   |2 --
 libavcodec/libxvidff.c   |3 ---
 libavdevice/bktr.c   |1 -
 libavdevice/x11grab.c|2 --
 libavformat/applehttp.c  |1 -
 libavformat/applehttpproto.c |1 -
 libavformat/avio.c   |3 +--
 libavformat/rtpdec.c |3 ---
 12 files changed, 2 insertions(+), 30 deletions(-)

diff --git a/configure b/configure
index 955a568..1eebce9 100755
--- a/configure
+++ b/configure
@@ -2316,7 +2316,7 @@ if test "$?" != 0; then
 die "C compiler test failed."
 fi
 
-add_cppflags -D_ISOC99_SOURCE -D_POSIX_C_SOURCE=200112
+add_cppflags -D_ISOC99_SOURCE -D_XOPEN_SOURCE=600 -D_POSIX_C_SOURCE=200112
 check_cflags -std=c99
 check_cc -D_FILE_OFFSET_BITS=64 <
@@ -2364,7 +2364,6 @@ case $target_os in
 disable symver
 oss_indev_extralibs="-lossaudio"
 oss_outdev_extralibs="-lossaudio"
-add_cppflags -D_XOPEN_SOURCE=600
 ;;
 openbsd)
 enable malloc_aligned
diff --git a/doc/general.texi b/doc/general.texi
index 598b9bc..bbc8e56 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -784,14 +784,6 @@ to configure.
 BSD make will not build Libav, you need to install and use GNU Make
 (@file{gmake}).
 
-@subsubsection FreeBSD, DragonFly BSD
-
-These systems will not compile out-of-the-box due to broken system headers.
-Passing @code{--extra-cflags=-D__BSD_VISIBLE} to configure will work
-around the problem. This may have unexpected sideeffects, so use it at
-your own risk. If you care about FreeBSD, please make an attempt at
-getting the system headers fixed.
-
 @subsection (Open)Solaris
 
 GNU Make is required to build Libav, so you have to invoke (@file{gmake}),
diff --git a/ffmpeg.c b/ffmpeg.c
index 5ab3c7a..b5ff4cf 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -19,9 +19,6 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-/* needed for usleep() */
-#define _XOPEN_SOURCE 600
-
 #include "config.h"
 #include 
 #include 
diff --git a/ffplay.c b/ffplay.c
index 07727b6..e820c60 100644
--- a/ffplay.c
+++ b/ffplay.c
@@ -19,8 +19,6 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#define _XOPEN_SOURCE 600
-
 #include "config.h"
 #include 
 #include 
diff --git a/ffserver.c b/ffserver.c
index fe030b9..b4613af 100644
--- a/ffserver.c
+++ b/ffserver.c
@@ -19,8 +19,6 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#define _XOPEN_SOURCE 600
-
 #include "config.h"
 #if !HAVE_CLOSESOCKET
 #define closesocket close
diff --git a/libavcodec/libxvidff.c b/libavcodec/libxvidff.c
index 96ce848..1e887a2 100644
--- a/libavcodec/libxvidff.c
+++ b/libavcodec/libxvidff.c
@@ -25,9 +25,6 @@
  * @author Adam Thayer (krev...@comcast.net)
  */
 
-/* needed for mkstemp() */
-#define _XOPEN_SOURCE 600
-
 #include 
 #include 
 #include "avcodec.h"
diff --git a/libavdevice/bktr.c b/libavdevice/bktr.c
index ab70a1b..3e705a0 100644
--- a/libavdevice/bktr.c
+++ b/libavdevice/bktr.c
@@ -26,7 +26,6 @@
 
 #define _BSD_SOURCE 1
 #define _NETBSD_SOURCE
-#define _XOPEN_SOURCE 600
 
 #include "libavformat/avformat.h"
 #if HAVE_DEV_BKTR_IOCTL_METEOR_H && HAVE_DEV_BKTR_IOCTL_BT848_H
diff --git a/libavdevice/x11grab.c b/libavdevice/x11grab.c
index aaad729..0e63d09 100644
--- a/libavdevice/x11grab.c
+++ b/libavdevice/x11grab.c
@@ -35,8 +35,6 @@
  * and Edouard Gomez .
  */
 
-#define _XOPEN_SOURCE 600
-
 #include "config.h"
 #include "libavformat/avformat.h"
 #include 
diff --git a/libavformat/applehttp.c b/libavformat/applehttp.c
index 822d80b..e3b1500 100644
--- a/libavformat/applehttp.c
+++ b/libavformat/applehttp.c
@@ -25,7 +25,6 @@
  * http://tools.ietf.org/html/draft-pantos-http-live-streaming
  */
 
-#define _XOPEN_SOURCE 600
 #include "libavutil/avstring.h"
 #include "libavutil/intreadwrite.h"
 #include "libavutil/opt.h"
diff --git a/libavformat/applehttpproto.c b/libavformat/applehttpproto.c
index 37b289a..85f3cfc 100644
--- a/libavformat/applehttpproto.c
+++ b/libavformat/applehttpproto.c
@@ -25,7 +25,6 @@
  * http://tools.ietf.org/html/draft-pantos-http-live-streaming
  */
 
-#define _XOPEN_SOURCE 600
 #include "libavutil/avstring.h"
 #include "avformat.h"
 #include "internal.h"
diff --git a/libavformat/avio.c b/libavformat/avio.c
index 0702aff..8881f26 100644
--- a/libavformat/avio.c
+++ b/libavformat/avio.c
@@ -19,9 +19,8 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-/* needed for usleep() */
-#define _XOPEN_SOURCE 600
 #include 
+
 #include "libavutil/avstring

Re: [libav-devel] [PATCH] tiff: add support to TIFF_SAMPLES_PER_PIXEL case in tiff_decode_tag()

2011-05-11 Thread Kostya
On Wed, May 11, 2011 at 01:10:19PM +0200, Stefano Sabatini wrote:
> On date Wednesday 2011-05-11 12:42:17 +0200, Kostya encoded:
> > On Wed, May 11, 2011 at 12:13:40PM +0200, Stefano Sabatini wrote:
> > > On date Wednesday 2011-05-11 11:41:53 +0200, Kostya encoded:
> > > > On Wed, May 11, 2011 at 11:29:04AM +0200, Stefano Sabatini wrote:
> > > > > On date Wednesday 2011-05-11 10:38:22 +0200, Kostya encoded:
> > > > > > On Wed, May 11, 2011 at 09:28:42AM +0200, Stefano Sabatini wrote:
> > > > > > > On date Wednesday 2011-05-11 07:39:07 +0200, Kostya encoded:
> > > > > > > > On Mon, May 09, 2011 at 12:51:24PM +0200, Stefano Sabatini 
> > > > > > > > wrote:
> > > > > > > > > Also add support for bits per component storage.
> > > > > > > > > 
> > > > > > > > > Fix decoding of file 11.tiff, trac issue number #167.
> > > > > > > > > 
> > > > > > > > > Based on a patch by Kostya Shishkov 
> > > > > > > > > .
> > > > > > > > > ---
> > > > > > > > >  libavcodec/tiff.c |  138 
> > > > > > > > > -
> > > > > > > > >  1 files changed, 73 insertions(+), 65 deletions(-)
> > > > > > > > 
> > > > > > > > Personally I don't understand that patch - why it assigns new 
> > > > > > > > meaning to bpp,
> > > > > > > > why it saves all bits per component (I don't see it being used 
> > > > > > > > elsewhere) and
> > > > > > > > what it does beside that.
> > > > > > > 
> > > > > > > I'm trying to handle the cases:
> > > > > > > 
> > > > > > > 1) BitsPerSample = { 8, 8, 8 }, SamplesPerPixel unspecifid
> > > > > > >If SamplesPerPixel is unspecified, the number of components is 
> > > > > > > based on
> > > > > > >the number of components specified in the BitsPerSample tag.
> > > > > > >File b.tif, FFmpeg trac issue #168. 
> > > > > > 
> > > > > 
> > > > > > It's decoded the same (wrong) way with or without your patch, but 
> > > > > > has issues
> > > > > > if my old patch is applied indeed.
> > > > > 
> > > > > Yes there is another issue, I have another patch for that.
> > > > >   
> > > > > > > 2) BitsPerSample = { 8 }, SamplesPerPixel = 3
> > > > > > >File 11.tiff, FFmpeg trac issue #167.
> > > > > > > 
> > > > > > > In both cases totalbpp is computed with:
> > > > > > > s->totalbpp = 0;
> > > > > > > for (i = 0; i < s->bppcount; i++)
> > > > > > > s->totalbpp += s->bpp[i] ? s->bpp[i] : s->bpp[0];
> > > > > > > 
> > > > > > > which issues the correct value in both cases.
> > > > > > 
> > > > > > Yes, you have a point, I just find your approach a bit strange.
> > > > > > See my attempt on it which does the same in a bit simplier way 
> > > > > > (IMO).
> > > > > 
> > > > > > From 71732ec8ae89a791c740fd173b5249dd84d8a9f5 Mon Sep 17 00:00:00 
> > > > > > 2001
> > > > > > From: Kostya Shishkov 
> > > > > > Date: Wed, 11 May 2011 10:27:57 +0200
> > > > > > Subject: [PATCH] make TIFF decoder handle samples per pixel tag
> > > > > > 
> > > > > > ---
> > > > > >  libavcodec/tiff.c |   97 
> > > > > > -
> > > > > >  1 files changed, 59 insertions(+), 38 deletions(-)
> > > > [...]
> > > > > 
> > > > > What happens if BitsPerSample or SamplesPerPixel are specified more
> > > > > than once, or SamplesPerPixel is processed before BitsPerSample?
> > > > 
> > > > TIFF specification says that entries should be sorted in ascending 
> > > > order by
> > > > Tag, having multiple entries with the same ID is also probably wrong.
> > > >  
> > > > > That's why I prefer to init_image() just after all the tags have been
> > > > > read, and bits-per-pixel-components and samples-per-pixel information
> > > > > has been already collected.
> > > > 
> > > > Good approach, but in this case it's not needed since it's all ordered.
> > > 
> > > For example with 11.tiff this patch is working by chance, we have:
> > > 
> > > => BitsPerSample = { 8 }
> > > bpp = 8, bppcount = 1
> > > 
> > > init_image() doesn't fail just because the image is recognized as a
> > > PAL8 image
> > > 
> > > => SamplesPerPixel = 3
> > > bpp = 24, bppcount = 3
> > > 
> > > init_image() correctly detects the right format
> > 
> > You're right, and having init_image() after all those tags are parsed is
> > better (I cannot argue with that), but I still think it's better to operate
> > with sum of pixels per component from the beginning, so the flow would be:
> > 
> > => BitsPerSample = { 8 }
> > => SamplesPerPixel = 3
> > bpp = 8, bppcount = 1, spp = 3
> > 
> > since bppcount == 1 multiply bpp by spp, so final bpp = 8 * 3 = 24
> > 
> > => BitsPerSample = { 8, 8, 8 }
> > => no SamplesPerPixel or = 3
> > 
> > bpp = 24, bppcount = 3, spp = 1 (default setting) or 3
> > since bppcount != 1, ignore spp (optionally check if bppcount != 1 && spp !=
> >  bppcount and complain then)
> > final bpp is unchanged and is 24
> > 
> > What do you think?
> 
> Still doesn't work in the illegal case when we have more than one
> SamplesPerPixel

Re: [libav-devel] [PATCH] tiff: add support to TIFF_SAMPLES_PER_PIXEL case in tiff_decode_tag()

2011-05-11 Thread Stefano Sabatini
On date Wednesday 2011-05-11 12:42:17 +0200, Kostya encoded:
> On Wed, May 11, 2011 at 12:13:40PM +0200, Stefano Sabatini wrote:
> > On date Wednesday 2011-05-11 11:41:53 +0200, Kostya encoded:
> > > On Wed, May 11, 2011 at 11:29:04AM +0200, Stefano Sabatini wrote:
> > > > On date Wednesday 2011-05-11 10:38:22 +0200, Kostya encoded:
> > > > > On Wed, May 11, 2011 at 09:28:42AM +0200, Stefano Sabatini wrote:
> > > > > > On date Wednesday 2011-05-11 07:39:07 +0200, Kostya encoded:
> > > > > > > On Mon, May 09, 2011 at 12:51:24PM +0200, Stefano Sabatini wrote:
> > > > > > > > Also add support for bits per component storage.
> > > > > > > > 
> > > > > > > > Fix decoding of file 11.tiff, trac issue number #167.
> > > > > > > > 
> > > > > > > > Based on a patch by Kostya Shishkov .
> > > > > > > > ---
> > > > > > > >  libavcodec/tiff.c |  138 
> > > > > > > > -
> > > > > > > >  1 files changed, 73 insertions(+), 65 deletions(-)
> > > > > > > 
> > > > > > > Personally I don't understand that patch - why it assigns new 
> > > > > > > meaning to bpp,
> > > > > > > why it saves all bits per component (I don't see it being used 
> > > > > > > elsewhere) and
> > > > > > > what it does beside that.
> > > > > > 
> > > > > > I'm trying to handle the cases:
> > > > > > 
> > > > > > 1) BitsPerSample = { 8, 8, 8 }, SamplesPerPixel unspecifid
> > > > > >If SamplesPerPixel is unspecified, the number of components is 
> > > > > > based on
> > > > > >the number of components specified in the BitsPerSample tag.
> > > > > >File b.tif, FFmpeg trac issue #168. 
> > > > > 
> > > > 
> > > > > It's decoded the same (wrong) way with or without your patch, but has 
> > > > > issues
> > > > > if my old patch is applied indeed.
> > > > 
> > > > Yes there is another issue, I have another patch for that.
> > > >   
> > > > > > 2) BitsPerSample = { 8 }, SamplesPerPixel = 3
> > > > > >File 11.tiff, FFmpeg trac issue #167.
> > > > > > 
> > > > > > In both cases totalbpp is computed with:
> > > > > > s->totalbpp = 0;
> > > > > > for (i = 0; i < s->bppcount; i++)
> > > > > > s->totalbpp += s->bpp[i] ? s->bpp[i] : s->bpp[0];
> > > > > > 
> > > > > > which issues the correct value in both cases.
> > > > > 
> > > > > Yes, you have a point, I just find your approach a bit strange.
> > > > > See my attempt on it which does the same in a bit simplier way (IMO).
> > > > 
> > > > > From 71732ec8ae89a791c740fd173b5249dd84d8a9f5 Mon Sep 17 00:00:00 2001
> > > > > From: Kostya Shishkov 
> > > > > Date: Wed, 11 May 2011 10:27:57 +0200
> > > > > Subject: [PATCH] make TIFF decoder handle samples per pixel tag
> > > > > 
> > > > > ---
> > > > >  libavcodec/tiff.c |   97 
> > > > > -
> > > > >  1 files changed, 59 insertions(+), 38 deletions(-)
> > > [...]
> > > > 
> > > > What happens if BitsPerSample or SamplesPerPixel are specified more
> > > > than once, or SamplesPerPixel is processed before BitsPerSample?
> > > 
> > > TIFF specification says that entries should be sorted in ascending order 
> > > by
> > > Tag, having multiple entries with the same ID is also probably wrong.
> > >  
> > > > That's why I prefer to init_image() just after all the tags have been
> > > > read, and bits-per-pixel-components and samples-per-pixel information
> > > > has been already collected.
> > > 
> > > Good approach, but in this case it's not needed since it's all ordered.
> > 
> > For example with 11.tiff this patch is working by chance, we have:
> > 
> > => BitsPerSample = { 8 }
> > bpp = 8, bppcount = 1
> > 
> > init_image() doesn't fail just because the image is recognized as a
> > PAL8 image
> > 
> > => SamplesPerPixel = 3
> > bpp = 24, bppcount = 3
> > 
> > init_image() correctly detects the right format
> 
> You're right, and having init_image() after all those tags are parsed is
> better (I cannot argue with that), but I still think it's better to operate
> with sum of pixels per component from the beginning, so the flow would be:
> 
> => BitsPerSample = { 8 }
> => SamplesPerPixel = 3
> bpp = 8, bppcount = 1, spp = 3
> 
> since bppcount == 1 multiply bpp by spp, so final bpp = 8 * 3 = 24
> 
> => BitsPerSample = { 8, 8, 8 }
> => no SamplesPerPixel or = 3
> 
> bpp = 24, bppcount = 3, spp = 1 (default setting) or 3
> since bppcount != 1, ignore spp (optionally check if bppcount != 1 && spp !=
>  bppcount and complain then)
> final bpp is unchanged and is 24
> 
> What do you think?

Still doesn't work in the illegal case when we have more than one
SamplesPerPixel tags, but that's not a very likely case, so if you
prefer this approach I'm fine with it.
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] ffmpeg: Simplify decode loop condition to not use next_pts

2011-05-11 Thread Ronald S. Bultje
Hi,

On Tue, May 10, 2011 at 10:26 PM, Alexander Strange
 wrote:
> On May 10, 2011, at 6:57 AM, Ronald S. Bultje wrote:
>> On Tue, May 10, 2011 at 1:53 AM, Alexander Strange
>>  wrote:
>>> ---
>>>  ffmpeg.c |   15 ---
>>>  1 files changed, 8 insertions(+), 7 deletions(-)
>>
>> I've tested this for a while locally already, and this improves output
>> of terminal frames with MT enabled. Definitely OK for me.
>>
>> Ronald
>
> I hope not… this is just a cosmetics patch. It makes the EOF condition 
> mortally understandable, but shouldn't have changed it.
> make fate output doesn't change.

make THREADS=9 fate with your mpeg/h264 changes applied does
definitely change (for the better).

I can try to explain, but really all it comes down to is that the
timestamping code is broken (mixing {,next_,prev_}{dts,pts}). Nobody
wants to hear that.

Ronald
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] Remove unused softfloat implementation.

2011-05-11 Thread Kostya
On Wed, May 11, 2011 at 11:42:32AM +0100, Måns Rullgård wrote:
> Diego Biurrun  writes:
> 
> > The softfloat functionality is unused, not installed and incomplete.
> > On platforms without floating point units, the compiler provides a softfloat
> > implementation so there is no point in carrying this code around locally.
> > ---
> >  doc/avutil.txt|1 -
> >  libavutil/Makefile|2 +-
> >  libavutil/softfloat.c |   72 
> >  libavutil/softfloat.h |  126 
> > -
> >  4 files changed, 1 insertions(+), 200 deletions(-)
> >  delete mode 100644 libavutil/softfloat.c
> >  delete mode 100644 libavutil/softfloat.h
> 
> Seems like an excellent idea.

And it's also useless even for Lagarith, so yes, drop it.
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] Remove unused softfloat implementation.

2011-05-11 Thread Måns Rullgård
Diego Biurrun  writes:

> The softfloat functionality is unused, not installed and incomplete.
> On platforms without floating point units, the compiler provides a softfloat
> implementation so there is no point in carrying this code around locally.
> ---
>  doc/avutil.txt|1 -
>  libavutil/Makefile|2 +-
>  libavutil/softfloat.c |   72 
>  libavutil/softfloat.h |  126 
> -
>  4 files changed, 1 insertions(+), 200 deletions(-)
>  delete mode 100644 libavutil/softfloat.c
>  delete mode 100644 libavutil/softfloat.h

Seems like an excellent idea.

-- 
Måns Rullgård
m...@mansr.com
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] tiff: add support to TIFF_SAMPLES_PER_PIXEL case in tiff_decode_tag()

2011-05-11 Thread Kostya
On Wed, May 11, 2011 at 12:13:40PM +0200, Stefano Sabatini wrote:
> On date Wednesday 2011-05-11 11:41:53 +0200, Kostya encoded:
> > On Wed, May 11, 2011 at 11:29:04AM +0200, Stefano Sabatini wrote:
> > > On date Wednesday 2011-05-11 10:38:22 +0200, Kostya encoded:
> > > > On Wed, May 11, 2011 at 09:28:42AM +0200, Stefano Sabatini wrote:
> > > > > On date Wednesday 2011-05-11 07:39:07 +0200, Kostya encoded:
> > > > > > On Mon, May 09, 2011 at 12:51:24PM +0200, Stefano Sabatini wrote:
> > > > > > > Also add support for bits per component storage.
> > > > > > > 
> > > > > > > Fix decoding of file 11.tiff, trac issue number #167.
> > > > > > > 
> > > > > > > Based on a patch by Kostya Shishkov .
> > > > > > > ---
> > > > > > >  libavcodec/tiff.c |  138 
> > > > > > > -
> > > > > > >  1 files changed, 73 insertions(+), 65 deletions(-)
> > > > > > 
> > > > > > Personally I don't understand that patch - why it assigns new 
> > > > > > meaning to bpp,
> > > > > > why it saves all bits per component (I don't see it being used 
> > > > > > elsewhere) and
> > > > > > what it does beside that.
> > > > > 
> > > > > I'm trying to handle the cases:
> > > > > 
> > > > > 1) BitsPerSample = { 8, 8, 8 }, SamplesPerPixel unspecifid
> > > > >If SamplesPerPixel is unspecified, the number of components is 
> > > > > based on
> > > > >the number of components specified in the BitsPerSample tag.
> > > > >File b.tif, FFmpeg trac issue #168. 
> > > > 
> > > 
> > > > It's decoded the same (wrong) way with or without your patch, but has 
> > > > issues
> > > > if my old patch is applied indeed.
> > > 
> > > Yes there is another issue, I have another patch for that.
> > >   
> > > > > 2) BitsPerSample = { 8 }, SamplesPerPixel = 3
> > > > >File 11.tiff, FFmpeg trac issue #167.
> > > > > 
> > > > > In both cases totalbpp is computed with:
> > > > > s->totalbpp = 0;
> > > > > for (i = 0; i < s->bppcount; i++)
> > > > > s->totalbpp += s->bpp[i] ? s->bpp[i] : s->bpp[0];
> > > > > 
> > > > > which issues the correct value in both cases.
> > > > 
> > > > Yes, you have a point, I just find your approach a bit strange.
> > > > See my attempt on it which does the same in a bit simplier way (IMO).
> > > 
> > > > From 71732ec8ae89a791c740fd173b5249dd84d8a9f5 Mon Sep 17 00:00:00 2001
> > > > From: Kostya Shishkov 
> > > > Date: Wed, 11 May 2011 10:27:57 +0200
> > > > Subject: [PATCH] make TIFF decoder handle samples per pixel tag
> > > > 
> > > > ---
> > > >  libavcodec/tiff.c |   97 
> > > > -
> > > >  1 files changed, 59 insertions(+), 38 deletions(-)
> > [...]
> > > 
> > > What happens if BitsPerSample or SamplesPerPixel are specified more
> > > than once, or SamplesPerPixel is processed before BitsPerSample?
> > 
> > TIFF specification says that entries should be sorted in ascending order by
> > Tag, having multiple entries with the same ID is also probably wrong.
> >  
> > > That's why I prefer to init_image() just after all the tags have been
> > > read, and bits-per-pixel-components and samples-per-pixel information
> > > has been already collected.
> > 
> > Good approach, but in this case it's not needed since it's all ordered.
> 
> For example with 11.tiff this patch is working by chance, we have:
> 
> => BitsPerSample = { 8 }
> bpp = 8, bppcount = 1
> 
> init_image() doesn't fail just because the image is recognized as a
> PAL8 image
> 
> => SamplesPerPixel = 3
> bpp = 24, bppcount = 3
> 
> init_image() correctly detects the right format

You're right, and having init_image() after all those tags are parsed is
better (I cannot argue with that), but I still think it's better to operate
with sum of pixels per component from the beginning, so the flow would be:

=> BitsPerSample = { 8 }
=> SamplesPerPixel = 3
bpp = 8, bppcount = 1, spp = 3

since bppcount == 1 multiply bpp by spp, so final bpp = 8 * 3 = 24

=> BitsPerSample = { 8, 8, 8 }
=> no SamplesPerPixel or = 3

bpp = 24, bppcount = 3, spp = 1 (default setting) or 3
since bppcount != 1, ignore spp (optionally check if bppcount != 1 && spp !=
 bppcount and complain then)
final bpp is unchanged and is 24

What do you think?
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] tiff: add support for inverted FillOrder for uncompressed data

2011-05-11 Thread Kostya
On Mon, May 09, 2011 at 09:59:20PM +0200, Stefano Sabatini wrote:
> Fix decoding of file b.tif, trac issue #168.
> ---
>  libavcodec/tiff.c |8 +++-
>  1 files changed, 7 insertions(+), 1 deletions(-)
> 
> diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
> index 9a94e86..ef3a8df 100644
> --- a/libavcodec/tiff.c
> +++ b/libavcodec/tiff.c
> @@ -168,7 +168,13 @@ static int tiff_unpack_strip(TiffContext *s, uint8_t* 
> dst, int stride, const uin
>  }
>  switch(s->compr){
>  case TIFF_RAW:
> -memcpy(dst, src, width);
> +if (!s->fill_order) {
> +memcpy(dst, src, width);
> +} else {
> +int i;
> +for (i = 0; i < width; i++)
> +dst[i] = av_reverse[src[i]];
> +}
>  src += width;
>  break;
>  case TIFF_PACKBITS:
> -- 

ok and thanks for the patch
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH] Remove unused softfloat implementation.

2011-05-11 Thread Diego Biurrun
The softfloat functionality is unused, not installed and incomplete.
On platforms without floating point units, the compiler provides a softfloat
implementation so there is no point in carrying this code around locally.
---
 doc/avutil.txt|1 -
 libavutil/Makefile|2 +-
 libavutil/softfloat.c |   72 
 libavutil/softfloat.h |  126 -
 4 files changed, 1 insertions(+), 200 deletions(-)
 delete mode 100644 libavutil/softfloat.c
 delete mode 100644 libavutil/softfloat.h

diff --git a/doc/avutil.txt b/doc/avutil.txt
index 210bd07..0847683 100644
--- a/doc/avutil.txt
+++ b/doc/avutil.txt
@@ -19,7 +19,6 @@ integer.c   128bit integer math
 lls.c
 mathematics.c   greatest common divisor, integer sqrt, integer log2, 
...
 mem.c   memory allocation routines with guaranteed alignment
-softfloat.c
 
 Headers:
 bswap.h big/little/native-endian conversion code
diff --git a/libavutil/Makefile b/libavutil/Makefile
index 8c3cc60..1386ebb 100644
--- a/libavutil/Makefile
+++ b/libavutil/Makefile
@@ -75,7 +75,7 @@ OBJS-$(ARCH_ARM) += arm/cpu.o
 OBJS-$(ARCH_PPC) += ppc/cpu.o
 OBJS-$(ARCH_X86) += x86/cpu.o
 
-TESTPROGS = adler32 aes base64 cpu crc des lls md5 pca sha softfloat tree
+TESTPROGS = adler32 aes base64 cpu crc des lls md5 pca sha tree
 TESTPROGS-$(HAVE_LZO1X_999_COMPRESS) += lzo
 
 DIRS = arm bfin sh4 x86
diff --git a/libavutil/softfloat.c b/libavutil/softfloat.c
deleted file mode 100644
index 55969fb..000
--- a/libavutil/softfloat.c
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * copyright (c) 2006 Michael Niedermayer 
- *
- * This file is part of Libav.
- *
- * Libav 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.
- *
- * Libav 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 Libav; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include 
-#include 
-#include 
-#include "softfloat.h"
-#include "common.h"
-#include "log.h"
-
-#undef printf
-
-int main(void){
-SoftFloat one= av_int2sf(1, 0);
-SoftFloat sf1, sf2;
-double d1, d2;
-int i, j;
-av_log_set_level(AV_LOG_DEBUG);
-
-d1= 1;
-for(i= 0; i<10; i++){
-d1= 1/(d1+1);
-}
-printf("test1 double=%d\n", (int)(d1 * (1<<24)));
-
-sf1= one;
-for(i= 0; i<10; i++){
-sf1= av_div_sf(one, av_normalize_sf(av_add_sf(one, sf1)));
-}
-printf("test1 sf=%d\n", av_sf2int(sf1, 24));
-
-
-for(i= 0; i<100; i++){
-START_TIMER
-d1= i;
-d2= i/100.0;
-for(j= 0; j<1000; j++){
-d1= (d1+1)*d2;
-}
-STOP_TIMER("float add mul")
-}
-printf("test2 double=%d\n", (int)(d1 * (1<<24)));
-
-for(i= 0; i<100; i++){
-START_TIMER
-sf1= av_int2sf(i, 0);
-sf2= av_div_sf(av_int2sf(i, 2), av_int2sf(200, 3));
-for(j= 0; j<1000; j++){
-sf1= av_mul_sf(av_add_sf(sf1, one),sf2);
-}
-STOP_TIMER("softfloat add mul")
-}
-printf("test2 sf=%d (%d %d)\n", av_sf2int(sf1, 24), sf1.exp, sf1.mant);
-return 0;
-}
diff --git a/libavutil/softfloat.h b/libavutil/softfloat.h
deleted file mode 100644
index 3078bd7..000
--- a/libavutil/softfloat.h
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Copyright (c) 2006 Michael Niedermayer 
- *
- * This file is part of Libav.
- *
- * Libav 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.
- *
- * Libav 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 Libav; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef AVUTIL_SOFTFLOAT_H
-#define AVUTIL_SOFTFLOAT_H
-
-#include 
-#include "common.h"
-
-#define MIN_EXP -126
-#define MAX_EXP  126
-#define ONE_BITS 29
-
-typedef struct SoftFloat{
-int32_t  exp;
-int32_t mant;
-}SoftFloat;
-
-static av_const SoftFloat av_normalize_sf(SoftFloat a){
-if(a.mant){
-#if 1
-while((a.m

  1   2   >