[FFmpeg-cvslog] avcodec/mediacodecdec: add debug logging around hw buffer lifecycle
ffmpeg | branch: master | Aman Gupta | Sat Mar 10 23:43:42 2018 -0800| [936312d18c985335d8e90b04bb15b4227bce7b31] | committer: Aman Gupta avcodec/mediacodecdec: add debug logging around hw buffer lifecycle Some Android devices are very finicky about how quicky output buffers are returned back to the decoder, especially when they are associated with a Surface. This commit adds a new counter that keeps track of exactly how many hw output buffers are being retained by the user, along with DEBUG level logging that makes it easy to track the lifecycle of these buffers. Signed-off-by: Aman Gupta Signed-off-by: Matthieu Bouron > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=936312d18c985335d8e90b04bb15b4227bce7b31 --- libavcodec/mediacodec.c | 7 --- libavcodec/mediacodecdec_common.c | 11 +++ libavcodec/mediacodecdec_common.h | 1 + 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/libavcodec/mediacodec.c b/libavcodec/mediacodec.c index 3ddd303c97..b0aae43a87 100644 --- a/libavcodec/mediacodec.c +++ b/libavcodec/mediacodec.c @@ -92,9 +92,10 @@ int av_mediacodec_release_buffer(AVMediaCodecBuffer *buffer, int render) int released = atomic_fetch_add(&buffer->released, 1); if (!released && (ctx->delay_flush || buffer->serial == atomic_load(&ctx->serial))) { -av_log(ctx->avctx, AV_LOG_TRACE, - "Releasing output buffer %zd ts=%"PRId64" render=%d\n", - buffer->index, buffer->pts, render); +atomic_fetch_sub(&ctx->hw_buffer_count, 1); +av_log(ctx->avctx, AV_LOG_DEBUG, + "Releasing output buffer %zd (%p) ts=%"PRId64" with render=%d [%d pending]\n", + buffer->index, buffer, buffer->pts, render, atomic_load(&ctx->hw_buffer_count)); return ff_AMediaCodec_releaseOutputBuffer(ctx->codec, buffer->index, render); } diff --git a/libavcodec/mediacodecdec_common.c b/libavcodec/mediacodecdec_common.c index 5064809cf6..2697af3d08 100644 --- a/libavcodec/mediacodecdec_common.c +++ b/libavcodec/mediacodecdec_common.c @@ -179,6 +179,10 @@ static void mediacodec_buffer_release(void *opaque, uint8_t *data) int released = atomic_load(&buffer->released); if (!released && (ctx->delay_flush || buffer->serial == atomic_load(&ctx->serial))) { +atomic_fetch_sub(&ctx->hw_buffer_count, 1); +av_log(ctx->avctx, AV_LOG_DEBUG, + "Releasing output buffer %zd (%p) ts=%"PRId64" on free() [%d pending]\n", + buffer->index, buffer, buffer->pts, atomic_load(&ctx->hw_buffer_count)); ff_AMediaCodec_releaseOutputBuffer(ctx->codec, buffer->index, 0); } @@ -246,6 +250,11 @@ FF_ENABLE_DEPRECATION_WARNINGS frame->data[3] = (uint8_t *)buffer; +atomic_fetch_add(&s->hw_buffer_count, 1); +av_log(avctx, AV_LOG_DEBUG, +"Wrapping output buffer %zd (%p) ts=%"PRId64" [%d pending]\n", +buffer->index, buffer, buffer->pts, atomic_load(&s->hw_buffer_count)); + return 0; fail: av_freep(buffer); @@ -429,6 +438,7 @@ static int mediacodec_dec_flush_codec(AVCodecContext *avctx, MediaCodecDecContex s->flushing = 0; s->eos = 0; atomic_fetch_add(&s->serial, 1); +atomic_init(&s->hw_buffer_count, 0); status = ff_AMediaCodec_flush(codec); if (status < 0) { @@ -454,6 +464,7 @@ int ff_mediacodec_dec_init(AVCodecContext *avctx, MediaCodecDecContext *s, s->avctx = avctx; atomic_init(&s->refcount, 1); +atomic_init(&s->hw_buffer_count, 0); atomic_init(&s->serial, 1); pix_fmt = ff_get_format(avctx, pix_fmts); diff --git a/libavcodec/mediacodecdec_common.h b/libavcodec/mediacodecdec_common.h index 3fd2412a65..4f3b4f9fa5 100644 --- a/libavcodec/mediacodecdec_common.h +++ b/libavcodec/mediacodecdec_common.h @@ -38,6 +38,7 @@ typedef struct MediaCodecDecContext { AVCodecContext *avctx; atomic_int refcount; +atomic_int hw_buffer_count; char *codec_name; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avcodec/mediacodecdec_common: make INFO_TRY_AGAIN trace messages more consistent
ffmpeg | branch: master | Matthieu Bouron | Mon Mar 12 09:10:57 2018 +0100| [41d7c4d3813b71d0feefb19c69f6a246ea2bdcee] | committer: Matthieu Bouron avcodec/mediacodecdec_common: make INFO_TRY_AGAIN trace messages more consistent Signed-off-by: Aman Gupta Signed-off-by: Matthieu Bouron > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=41d7c4d3813b71d0feefb19c69f6a246ea2bdcee --- libavcodec/mediacodecdec_common.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/mediacodecdec_common.c b/libavcodec/mediacodecdec_common.c index 2697af3d08..635ee73486 100644 --- a/libavcodec/mediacodecdec_common.c +++ b/libavcodec/mediacodecdec_common.c @@ -579,7 +579,7 @@ int ff_mediacodec_dec_send(AVCodecContext *avctx, MediaCodecDecContext *s, index = ff_AMediaCodec_dequeueInputBuffer(codec, input_dequeue_timeout_us); if (ff_AMediaCodec_infoTryAgainLater(codec, index)) { -av_log(avctx, AV_LOG_TRACE, "Failed to dequeue input buffer, try again later..\n"); +av_log(avctx, AV_LOG_TRACE, "No input buffer available, try again later\n"); break; } @@ -743,7 +743,7 @@ int ff_mediacodec_dec_receive(AVCodecContext *avctx, MediaCodecDecContext *s, "while draining remaining frames, output will probably lack frames\n", output_dequeue_timeout_us / 1000); } else { -av_log(avctx, AV_LOG_DEBUG, "No output buffer available, try again later\n"); +av_log(avctx, AV_LOG_TRACE, "No output buffer available, try again later\n"); } } else { av_log(avctx, AV_LOG_ERROR, "Failed to dequeue output buffer (status=%zd)\n", index); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avformat/hlsenc: fix for zero EXTINF tag duration
ffmpeg | branch: master | Vishwanath Dixit | Mon Mar 12 23:17:58 2018 +0800| [9c249110ea974ce213840fde5ee5a3d842fa088d] | committer: Steven Liu avformat/hlsenc: fix for zero EXTINF tag duration This is the fix for bug https://trac.ffmpeg.org/ticket/7073 Tested-by: Brainiarc7 Reviewed-by: Steven Liu > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9c249110ea974ce213840fde5ee5a3d842fa088d --- libavformat/hlsenc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c index 08fe0aa7a0..7d9512b664 100644 --- a/libavformat/hlsenc.c +++ b/libavformat/hlsenc.c @@ -2501,7 +2501,7 @@ static int hls_init(AVFormatContext *s) /* Get one video stream to reference for split segments * so use the first video stream index. */ if ((vs->has_video == 1) && (vs->streams[j]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)) { -vs->reference_stream_index = j; +vs->reference_stream_index = vs->streams[j]->index; } vs->has_subtitle += vs->streams[j]->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE; } ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] ffprobe: fix infinite loop in subtitle decoding
ffmpeg | branch: master | Marton Balint | Sun Mar 11 18:02:12 2018 +0100| [68f5384804fa86af2737f7b08799c9ca2c306db4] | committer: Marton Balint ffprobe: fix infinite loop in subtitle decoding Fixes a regression since 2a88ebd096f3c748a2d99ed1b60b22879b3c567c which caused an infinite loop in the subtitle decoding. Fixes ticket #6796. Signed-off-by: Marton Balint > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=68f5384804fa86af2737f7b08799c9ca2c306db4 --- fftools/ffprobe.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c index 967adbe30c..a4ac6972a2 100644 --- a/fftools/ffprobe.c +++ b/fftools/ffprobe.c @@ -2275,7 +2275,8 @@ static av_always_inline int process_frame(WriterContext *w, break; case AVMEDIA_TYPE_SUBTITLE: -ret = avcodec_decode_subtitle2(dec_ctx, &sub, &got_frame, pkt); +if (*packet_new) +ret = avcodec_decode_subtitle2(dec_ctx, &sub, &got_frame, pkt); *packet_new = 0; break; default: ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] h264_mp4toannexb_bsf: Fix start code size of parameter sets.
ffmpeg | branch: master | Yusuke Nakamura | Tue Feb 13 01:45:05 2018 +0900| [af7e953a595690caf4127957f42d639641035411] | committer: Michael Niedermayer h264_mp4toannexb_bsf: Fix start code size of parameter sets. Any parameter set shall have start code of at least 4 byte size. Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=af7e953a595690caf4127957f42d639641035411 --- libavcodec/h264_mp4toannexb_bsf.c| 22 +++--- tests/ref/fate/h264-bsf-mp4toannexb | 2 +- tests/ref/fate/h264_mp4toannexb_ticket2991 | 22 +++--- tests/ref/fate/h264_mp4toannexb_ticket5927 | 10 +- tests/ref/fate/h264_mp4toannexb_ticket5927_2 | 10 +- tests/ref/fate/segment-mp4-to-ts | 4 ++-- 6 files changed, 35 insertions(+), 35 deletions(-) diff --git a/libavcodec/h264_mp4toannexb_bsf.c b/libavcodec/h264_mp4toannexb_bsf.c index 163d0f59ce..292d106433 100644 --- a/libavcodec/h264_mp4toannexb_bsf.c +++ b/libavcodec/h264_mp4toannexb_bsf.c @@ -39,21 +39,21 @@ typedef struct H264BSFContext { static int alloc_and_copy(AVPacket *out, const uint8_t *sps_pps, uint32_t sps_pps_size, - const uint8_t *in, uint32_t in_size) + const uint8_t *in, uint32_t in_size, int ps) { uint32_t offset = out->size; -uint8_t nal_header_size = offset ? 3 : 4; +uint8_t start_code_size = offset == 0 || ps ? 4 : 3; int err; -err = av_grow_packet(out, sps_pps_size + in_size + nal_header_size); +err = av_grow_packet(out, sps_pps_size + in_size + start_code_size); if (err < 0) return err; if (sps_pps) memcpy(out->data + offset, sps_pps, sps_pps_size); -memcpy(out->data + sps_pps_size + nal_header_size + offset, in, in_size); -if (!offset) { -AV_WB32(out->data + sps_pps_size, 1); +memcpy(out->data + sps_pps_size + start_code_size + offset, in, in_size); +if (start_code_size == 4) { +AV_WB32(out->data + offset + sps_pps_size, 1); } else { (out->data + offset + sps_pps_size)[0] = (out->data + offset + sps_pps_size)[1] = 0; @@ -221,7 +221,7 @@ static int h264_mp4toannexb_filter(AVBSFContext *ctx, AVPacket *out) if ((ret = alloc_and_copy(out, ctx->par_out->extradata + s->sps_offset, s->pps_offset != -1 ? s->pps_offset : ctx->par_out->extradata_size - s->sps_offset, - buf, nal_size)) < 0) + buf, nal_size, 1)) < 0) goto fail; s->idr_sps_seen = 1; goto next_nal; @@ -239,21 +239,21 @@ static int h264_mp4toannexb_filter(AVBSFContext *ctx, AVPacket *out) if (s->new_idr && unit_type == 5 && !s->idr_sps_seen && !s->idr_pps_seen) { if ((ret=alloc_and_copy(out, ctx->par_out->extradata, ctx->par_out->extradata_size, - buf, nal_size)) < 0) + buf, nal_size, 1)) < 0) goto fail; s->new_idr = 0; /* if only SPS has been seen, also insert PPS */ } else if (s->new_idr && unit_type == 5 && s->idr_sps_seen && !s->idr_pps_seen) { if (s->pps_offset == -1) { av_log(ctx, AV_LOG_WARNING, "PPS not present in the stream, nor in AVCC, stream may be unreadable\n"); -if ((ret = alloc_and_copy(out, NULL, 0, buf, nal_size)) < 0) +if ((ret = alloc_and_copy(out, NULL, 0, buf, nal_size, 0)) < 0) goto fail; } else if ((ret = alloc_and_copy(out, ctx->par_out->extradata + s->pps_offset, ctx->par_out->extradata_size - s->pps_offset, -buf, nal_size)) < 0) +buf, nal_size, 1)) < 0) goto fail; } else { -if ((ret=alloc_and_copy(out, NULL, 0, buf, nal_size)) < 0) +if ((ret=alloc_and_copy(out, NULL, 0, buf, nal_size, unit_type == 7 || unit_type == 8)) < 0) goto fail; if (!s->new_idr && unit_type == 1) { s->new_idr = 1; diff --git a/tests/ref/fate/h264-bsf-mp4toannexb b/tests/ref/fate/h264-bsf-mp4toannexb index 2049f39701..7cd086a268 100644 --- a/tests/ref/fate/h264-bsf-mp4toannexb +++ b/tests/ref/fate/h264-bsf-mp4toannexb @@ -1 +1 @@ -5f04c27cc6ee8625fe2405fb0f7da9a3 +f340e7ca9a46d437af4e96f6c8de221c diff --git a/tests/ref/fate/h264_mp4toannexb_ticket2991 b/tests/ref/fate/h264_mp4toannexb_ticket2991 index 76bdf3cae7..3245ef442c 100644 --- a/tests/ref/fate/h264_mp4toannexb_ticket2991 +++ b/tests/ref/fate/h264_mp4toannexb_ticket2991 @@ -1,12 +1,12 @@ -05d66e60a
[FFmpeg-cvslog] avformat/pcm: decrease delay when reading PCM streams.
ffmpeg | branch: master | Philipp M. Scholl | Sat Mar 10 15:50:06 2018 +0100| [040b28aeccce8bc3c2e109f8e0ea7f0ed4d3af08] | committer: Michael Niedermayer avformat/pcm: decrease delay when reading PCM streams. Thanks for the discussion. Here's the next version, now with /25 and removed ff_log2(). The blocksize of the PCM decoder is hard-coded. This creates unnecessary delay when reading low-rate (<100Hz) streams. This creates issues when multiplexing multiple streams, since other inputs are only opened/read after a low-rate input block was completely read. This patch decreases the blocksize for low-rate inputs, so approximately a block is read every 40ms. This decreases the startup delay when multiplexing inputs with different rates. Signed-off-by: Philipp M. Scholl Reviewed-by: Paul B Mahol Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=040b28aeccce8bc3c2e109f8e0ea7f0ed4d3af08 --- libavformat/pcm.c | 13 ++--- tests/ref/seek/lavf-alaw | 42 +- tests/ref/seek/lavf-mulaw | 42 +- 3 files changed, 52 insertions(+), 45 deletions(-) diff --git a/libavformat/pcm.c b/libavformat/pcm.c index 806f91b6b1..767bbd045a 100644 --- a/libavformat/pcm.c +++ b/libavformat/pcm.c @@ -28,13 +28,20 @@ int ff_pcm_read_packet(AVFormatContext *s, AVPacket *pkt) { +AVCodecParameters *par = s->streams[0]->codecpar; int ret, size; -size= RAW_SAMPLES*s->streams[0]->codecpar->block_align; -if (size <= 0) +if (par->block_align <= 0) return AVERROR(EINVAL); -ret= av_get_packet(s->pb, pkt, size); +/* + * Compute read size to complete a read every 62ms. + * Clamp to RAW_SAMPLES if larger. + */ +size = FFMAX(par->sample_rate/25, 1); +size = FFMIN(size, RAW_SAMPLES) * par->block_align; + +ret = av_get_packet(s->pb, pkt, size); pkt->flags &= ~AV_PKT_FLAG_CORRUPT; pkt->stream_index = 0; diff --git a/tests/ref/seek/lavf-alaw b/tests/ref/seek/lavf-alaw index 4b1f8fbc02..8d517fa2bb 100644 --- a/tests/ref/seek/lavf-alaw +++ b/tests/ref/seek/lavf-alaw @@ -1,53 +1,53 @@ -ret: 0 st: 0 flags:1 dts: 0.00 pts: 0.00 pos: 0 size: 1024 +ret: 0 st: 0 flags:1 dts: 0.00 pts: 0.00 pos: 0 size: 882 ret: 0 st:-1 flags:0 ts:-1.00 -ret: 0 st: 0 flags:1 dts: 0.00 pts: 0.00 pos: 0 size: 1024 +ret: 0 st: 0 flags:1 dts: 0.00 pts: 0.00 pos: 0 size: 882 ret: 0 st:-1 flags:1 ts: 1.894167 -ret: 0 st: 0 flags:1 dts: 1.894150 pts: 1.894150 pos: 41766 size: 1024 +ret: 0 st: 0 flags:1 dts: 1.894150 pts: 1.894150 pos: 41766 size: 882 ret: 0 st: 0 flags:0 ts: 0.788345 -ret: 0 st: 0 flags:1 dts: 0.788345 pts: 0.788345 pos: 17383 size: 1024 +ret: 0 st: 0 flags:1 dts: 0.788345 pts: 0.788345 pos: 17383 size: 882 ret: 0 st: 0 flags:1 ts:-0.317506 -ret: 0 st: 0 flags:1 dts: 0.00 pts: 0.00 pos: 0 size: 1024 +ret: 0 st: 0 flags:1 dts: 0.00 pts: 0.00 pos: 0 size: 882 ret: 0 st:-1 flags:0 ts: 2.576668 ret:-EOF ret: 0 st:-1 flags:1 ts: 1.470835 -ret: 0 st: 0 flags:1 dts: 1.470839 pts: 1.470839 pos: 32432 size: 1024 +ret: 0 st: 0 flags:1 dts: 1.470839 pts: 1.470839 pos: 32432 size: 882 ret: 0 st: 0 flags:0 ts: 0.364989 -ret: 0 st: 0 flags:1 dts: 0.364989 pts: 0.364989 pos: 8048 size: 1024 +ret: 0 st: 0 flags:1 dts: 0.364989 pts: 0.364989 pos: 8048 size: 882 ret: 0 st: 0 flags:1 ts:-0.740816 -ret: 0 st: 0 flags:1 dts: 0.00 pts: 0.00 pos: 0 size: 1024 +ret: 0 st: 0 flags:1 dts: 0.00 pts: 0.00 pos: 0 size: 882 ret: 0 st:-1 flags:0 ts: 2.153336 ret:-EOF ret: 0 st:-1 flags:1 ts: 1.047503 -ret: 0 st: 0 flags:1 dts: 1.047483 pts: 1.047483 pos: 23097 size: 1024 +ret: 0 st: 0 flags:1 dts: 1.047483 pts: 1.047483 pos: 23097 size: 882 ret: 0 st: 0 flags:0 ts:-0.058322 -ret: 0 st: 0 flags:1 dts: 0.00 pts: 0.00 pos: 0 size: 1024 +ret: 0 st: 0 flags:1 dts: 0.00 pts: 0.00 pos: 0 size: 882 ret: 0 st: 0 flags:1 ts: 2.835828 ret:-EOF ret: 0 st:-1 flags:0 ts: 1.730004 -ret: 0 st: 0 flags:1 dts: 1.730023 pts: 1.730023 pos: 38147 size: 1024 +ret: 0 st: 0 flags:1 dts: 1.730023 pts: 1.730023 pos: 38147 size: 882 ret: 0 st:-1 flags:1 ts: 0.624171 -ret: 0 st: 0 flags:1 dts: 0.624172 pts: 0.624172 pos: 13763 size: 1024 +ret: 0 st: 0 flags:1 dts: 0.624172 pts: 0.624172 pos: 13763 size: 882 ret: 0 st: 0 flags:0 ts:-0.481678 -ret: 0 st: 0 flags:1 dts: 0.00 pts: 0.00 pos: 0 size: 1024 +ret: 0 st: 0 flag
[FFmpeg-cvslog] vc2enc: properly promote operations to 64 bits
ffmpeg | branch: master | Rostislav Pehlivanov | Mon Mar 12 23:31:22 2018 +| [688060fbb7233d9212a92ce171e3b94784f95ca1] | committer: Rostislav Pehlivanov vc2enc: properly promote operations to 64 bits On Windows machines, the UL suffix still means 32 bits. The only parts that need 64 bits are (1ULL << (m + 32)) and (t*qf + qf). Hence, use the proper ULL suffix for the former and just increase the type of the qf constant for the latter. No overflows can happen as long as these are done in 64 bits and the quantization table doesn't change. Signed-off-by: Rostislav Pehlivanov > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=688060fbb7233d9212a92ce171e3b94784f95ca1 --- libavcodec/vc2enc.c | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libavcodec/vc2enc.c b/libavcodec/vc2enc.c index 2e480ba8d0..d0101e01e4 100644 --- a/libavcodec/vc2enc.c +++ b/libavcodec/vc2enc.c @@ -1163,14 +1163,14 @@ static av_cold int vc2_encode_init(AVCodecContext *avctx) goto alloc_fail; for (i = 0; i < 116; i++) { -const uint32_t qf = ff_dirac_qscale_tab[i]; -const int m = av_log2(qf); -const uint32_t t = (1UL << (m + 32)) / qf; -const uint32_t r = (t*qf + qf) & ((1UL << 32) - 1); +const uint64_t qf = ff_dirac_qscale_tab[i]; +const uint32_t m = av_log2(qf); +const uint32_t t = (1ULL << (m + 32)) / qf; +const uint32_t r = (t*qf + qf) & UINT32_MAX; if (!(qf & (qf - 1))) { s->qmagic_lut[i][0] = 0x; s->qmagic_lut[i][1] = 0x; -} else if (r <= 1UL << m) { +} else if (r <= 1 << m) { s->qmagic_lut[i][0] = t + 1; s->qmagic_lut[i][1] = 0; } else { ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog