mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
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>
This commit is contained in:
commit
6716e6892b
@ -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;
|
||||
|
@ -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"),
|
||||
};
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user