summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-03-22 20:58:56 +0100
committerMichael Niedermayer <michaelni@gmx.at>2012-03-22 20:59:58 +0100
commit6716e6892baf0036f58d02011b8aac8c766970a4 (patch)
treef2c95e6ee685cbbfbb8238e2c0884fc7995f4ee3
parentb1a0d694ea973c4de91fbb1fb46858cff6f6e91b (diff)
parente9c0b12c2e6dd81d047669178719f68f18741f9c (diff)
downloadffmpeg-streaming-6716e6892baf0036f58d02011b8aac8c766970a4.zip
ffmpeg-streaming-6716e6892baf0036f58d02011b8aac8c766970a4.tar.gz
Merge remote-tracking branch 'qatar/master'
* qatar/master: FATE: Add ZeroCodec test oggparseogm: fix order of arguments of avpriv_set_pts_info(). pngenc: better upper bound for encoded frame size. aiffdec: set block_duration to 1 for PCM codecs that are supported in AIFF-C aiffdec: factor out handling of integer PCM for AIFF-C and plain AIFF aiffdec: use av_get_audio_frame_duration() to set block_duration for AIFF-C aiffdec: do not set bit rate if block duration is unknown wmall: output packet only if we have decoded some samples Conflicts: libavcodec/pngenc.c tests/fate/lossless-video.mak Merged-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--libavcodec/pngenc.c24
-rw-r--r--libavcodec/wmalosslessdec.c4
-rw-r--r--libavformat/aiffdec.c37
-rw-r--r--tests/fate/lossless-video.mak1
4 files changed, 37 insertions, 29 deletions
diff --git a/libavcodec/pngenc.c b/libavcodec/pngenc.c
index 0fd29ec..5b2c2e4 100644
--- a/libavcodec/pngenc.c
+++ b/libavcodec/pngenc.c
@@ -219,7 +219,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
PNGEncContext *s = avctx->priv_data;
AVFrame * const p= &s->picture;
int bit_depth, color_type, y, len, row_size, ret, is_progressive;
- int bits_per_pixel, pass_row_size, max_packet_size;
+ int bits_per_pixel, pass_row_size, enc_row_size, max_packet_size;
int compression_level;
uint8_t *ptr, *top;
uint8_t *crow_base = NULL, *crow_buf, *crow;
@@ -230,15 +230,6 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
p->pict_type= AV_PICTURE_TYPE_I;
p->key_frame= 1;
- max_packet_size = avctx->width * avctx->height * 9 + FF_MIN_BUFFER_SIZE;
- if ((ret = ff_alloc_packet2(avctx, pkt, max_packet_size)) < 0) {
- return ret;
- }
-
- s->bytestream_start =
- s->bytestream = pkt->data;
- s->bytestream_end = pkt->data + pkt->size;
-
is_progressive = !!(avctx->flags & CODEC_FLAG_INTERLACED_DCT);
switch(avctx->pix_fmt) {
case PIX_FMT_RGBA64BE:
@@ -293,6 +284,19 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
Z_DEFLATED, 15, 8, Z_DEFAULT_STRATEGY);
if (ret != Z_OK)
return -1;
+
+ enc_row_size = deflateBound(&s->zstream, row_size);
+ max_packet_size = avctx->height * (enc_row_size +
+ ((enc_row_size + IOBUF_SIZE - 1) / IOBUF_SIZE) * 12)
+ + FF_MIN_BUFFER_SIZE;
+ if ((ret = ff_alloc_packet2(avctx, pkt, max_packet_size)) < 0) {
+ return ret;
+ }
+
+ s->bytestream_start =
+ s->bytestream = pkt->data;
+ s->bytestream_end = pkt->data + pkt->size;
+
crow_base = av_malloc((row_size + 32) << (s->filter_type == PNG_FILTER_VALUE_MIXED));
if (!crow_base)
goto fail;
diff --git a/libavcodec/wmalosslessdec.c b/libavcodec/wmalosslessdec.c
index 326bfba..2137722 100644
--- a/libavcodec/wmalosslessdec.c
+++ b/libavcodec/wmalosslessdec.c
@@ -1229,7 +1229,7 @@ static int decode_packet(AVCodecContext *avctx, void *data, int *got_frame_ptr,
}
*(AVFrame *)data = s->frame;
- *got_frame_ptr = 1;
+ *got_frame_ptr = s->frame.nb_samples > 0;
s->packet_offset = get_bits_count(gb) & 7;
return (s->packet_loss) ? AVERROR_INVALIDDATA : get_bits_count(gb) >> 3;
@@ -1243,6 +1243,6 @@ AVCodec ff_wmalossless_decoder = {
.priv_data_size = sizeof(WmallDecodeCtx),
.init = decode_init,
.decode = decode_packet,
- .capabilities = CODEC_CAP_SUBFRAMES | CODEC_CAP_DR1,
+ .capabilities = CODEC_CAP_SUBFRAMES | CODEC_CAP_DR1 | CODEC_CAP_DELAY,
.long_name = NULL_IF_CONFIG_SMALL("Windows Media Audio Lossless"),
};
diff --git a/libavformat/aiffdec.c b/libavformat/aiffdec.c
index 1ee3726..212b330 100644
--- a/libavformat/aiffdec.c
+++ b/libavformat/aiffdec.c
@@ -112,47 +112,48 @@ static unsigned int get_aiff_header(AVFormatContext *s, int size,
codec->sample_rate = sample_rate;
size -= 18;
- /* Got an AIFF-C? */
+ /* get codec id for AIFF-C */
if (version == AIFF_C_VERSION1) {
codec->codec_tag = avio_rl32(pb);
codec->codec_id = ff_codec_get_id(ff_codec_aiff_tags, codec->codec_tag);
+ size -= 4;
+ }
+ if (version != AIFF_C_VERSION1 || codec->codec_id == CODEC_ID_PCM_S16BE) {
+ codec->codec_id = aiff_codec_get_id(codec->bits_per_coded_sample);
+ codec->bits_per_coded_sample = av_get_bits_per_sample(codec->codec_id);
+ aiff->block_duration = 1;
+ } else {
switch (codec->codec_id) {
- case CODEC_ID_PCM_S16BE:
- codec->codec_id = aiff_codec_get_id(codec->bits_per_coded_sample);
- codec->bits_per_coded_sample = av_get_bits_per_sample(codec->codec_id);
+ case CODEC_ID_PCM_F32BE:
+ case CODEC_ID_PCM_F64BE:
+ case CODEC_ID_PCM_S16LE:
+ case CODEC_ID_PCM_ALAW:
+ case CODEC_ID_PCM_MULAW:
aiff->block_duration = 1;
break;
case CODEC_ID_ADPCM_IMA_QT:
codec->block_align = 34*codec->channels;
- aiff->block_duration = 64;
break;
case CODEC_ID_MACE3:
codec->block_align = 2*codec->channels;
- aiff->block_duration = 6;
break;
case CODEC_ID_MACE6:
codec->block_align = 1*codec->channels;
- aiff->block_duration = 6;
break;
case CODEC_ID_GSM:
codec->block_align = 33;
- aiff->block_duration = 160;
break;
case CODEC_ID_QCELP:
codec->block_align = 35;
- aiff->block_duration = 160;
break;
default:
aiff->block_duration = 1;
break;
}
- size -= 4;
- } else {
- /* Need the codec type */
- codec->codec_id = aiff_codec_get_id(codec->bits_per_coded_sample);
- codec->bits_per_coded_sample = av_get_bits_per_sample(codec->codec_id);
- aiff->block_duration = 1;
+ if (codec->block_align > 0)
+ aiff->block_duration = av_get_audio_frame_duration(codec,
+ codec->block_align);
}
/* Block align needs to be computed in all cases, as the definition
@@ -160,8 +161,10 @@ static unsigned int get_aiff_header(AVFormatContext *s, int size,
if (!codec->block_align)
codec->block_align = (codec->bits_per_coded_sample * codec->channels) >> 3;
- codec->bit_rate = codec->sample_rate * (codec->block_align << 3) /
- aiff->block_duration;
+ if (aiff->block_duration) {
+ codec->bit_rate = codec->sample_rate * (codec->block_align << 3) /
+ aiff->block_duration;
+ }
/* Chunk is over */
if (size)
diff --git a/tests/fate/lossless-video.mak b/tests/fate/lossless-video.mak
index bf2df17..9293b96 100644
--- a/tests/fate/lossless-video.mak
+++ b/tests/fate/lossless-video.mak
@@ -24,3 +24,4 @@ fate-zerocodec: CMD = framecrc -i $(SAMPLES)/zerocodec/sample-zeco.avi
FATE_TESTS += $(FATE_LOSSLESS_VIDEO)
fate-lossless-video: $(FATE_LOSSLESS_VIDEO)
+
OpenPOWER on IntegriCloud