[FFmpeg-devel] Add Mediacodec audio decoders support
Hello, This patchset adds Mediacodec audio decoders support. Currently, only AAC, AMR, MP3, FLAC, VORBIS and OPUS are supported. This is mainly useful to avoid shipping Android builds of FFmpeg that are subjects to licensing/patents (due to AAC and AMR). Best regards, Matthieu ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 1/2] avcodec/mediacodecdec_common: ensure input buffer timestamp is positive
Submitting a buffer with a negative timestamp seems to stall the Mediacodec audio decoders. --- libavcodec/mediacodecdec_common.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavcodec/mediacodecdec_common.c b/libavcodec/mediacodecdec_common.c index d6f91e6e89..4d22db8ecf 100644 --- a/libavcodec/mediacodecdec_common.c +++ b/libavcodec/mediacodecdec_common.c @@ -658,6 +658,8 @@ int ff_mediacodec_dec_send(AVCodecContext *avctx, MediaCodecDecContext *s, if (pts && avctx->pkt_timebase.num && avctx->pkt_timebase.den) { pts = av_rescale_q(pts, avctx->pkt_timebase, AV_TIME_BASE_Q); } +if (pts < 0) +pts = 0; if (need_draining) { uint32_t flags = ff_AMediaCodec_getBufferFlagEndOfStream(codec); -- 2.45.2 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 2/2] avcodec: add Mediacodec audio decoders support
--- configure | 14 ++ libavcodec/Makefile | 7 + libavcodec/allcodecs.c| 7 + libavcodec/mediacodecdec.c| 215 ++- libavcodec/mediacodecdec_common.c | 333 +++--- 5 files changed, 545 insertions(+), 31 deletions(-) diff --git a/configure b/configure index 83284427df..d7de3b73ed 100755 --- a/configure +++ b/configure @@ -3321,14 +3321,22 @@ amf_deps_any="libdl LoadLibrary" nvenc_deps="ffnvcodec" nvenc_deps_any="libdl LoadLibrary" +aac_mediacodec_decoder_deps="mediacodec" +aac_mediacodec_decoder_select="aac_adtstoasc_bsf aac_parser" aac_mf_encoder_deps="mediafoundation" ac3_mf_encoder_deps="mediafoundation" +amrnb_mediacodec_decoder_deps="mediacodec" +amrnb_mediacodec_decoder_select="amr_parser" +amrwb_mediacodec_decoder_deps="mediacodec" +amrwb_mediacodec_decoder_select="amr_parser" av1_cuvid_decoder_deps="cuvid CUVIDAV1PICPARAMS" av1_mediacodec_decoder_deps="mediacodec" av1_mediacodec_encoder_deps="mediacodec" av1_mediacodec_encoder_select="extract_extradata_bsf" av1_nvenc_encoder_deps="nvenc NV_ENC_PIC_PARAMS_AV1" av1_nvenc_encoder_select="atsc_a53" +flac_mediacodec_decoder_deps="mediacodec" +flac_mediacodec_decoder_select="flac_parser" h263_v4l2m2m_decoder_deps="v4l2_m2m h263_v4l2_m2m" h263_v4l2m2m_encoder_deps="v4l2_m2m h263_v4l2_m2m" h264_amf_encoder_deps="amf" @@ -3377,6 +3385,8 @@ mjpeg_qsv_encoder_select="qsvenc" mjpeg_vaapi_encoder_deps="VAEncPictureParameterBufferJPEG" mjpeg_vaapi_encoder_select="cbs_jpeg jpegtables vaapi_encode" mp3_mf_encoder_deps="mediafoundation" +mp3_mediacodec_decoder_deps="mediacodec" +mp3_mediacodec_decoder_select="mpegaudioheader" mpeg1_cuvid_decoder_deps="cuvid" mpeg1_v4l2m2m_decoder_deps="v4l2_m2m mpeg1_v4l2_m2m" mpeg2_cuvid_decoder_deps="cuvid" @@ -3394,10 +3404,14 @@ mpeg4_mmal_decoder_deps="mmal" mpeg4_omx_encoder_deps="omx" mpeg4_v4l2m2m_decoder_deps="v4l2_m2m mpeg4_v4l2_m2m" mpeg4_v4l2m2m_encoder_deps="v4l2_m2m mpeg4_v4l2_m2m" +opus_mediacodec_decoder_deps="mediacodec" +opus_mediacodec_decoder_select="opus_parser" vc1_cuvid_decoder_deps="cuvid" vc1_mmal_decoder_deps="mmal" vc1_qsv_decoder_select="qsvdec" vc1_v4l2m2m_decoder_deps="v4l2_m2m vc1_v4l2_m2m" +vorbis_mediacodec_decoder_deps="mediacodec" +vorbis_mediacodec_decoder_select="vorbis_parser" vp8_cuvid_decoder_deps="cuvid" vp8_mediacodec_decoder_deps="mediacodec" vp8_mediacodec_encoder_deps="mediacodec" diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 1a44352906..64771b9944 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -196,6 +196,7 @@ OBJS-$(CONFIG_AAC_ENCODER) += aacenc.o aaccoder.o aacenctab.o\ aacenc_pred.o \ psymodel.o kbdwin.o \ mpeg4audio_sample_rates.o +OBJS-$(CONFIG_AAC_MEDIACODEC_DECODER) += mediacodecdec.o OBJS-$(CONFIG_AAC_MF_ENCODER) += mfenc.o mf_utils.o OBJS-$(CONFIG_AASC_DECODER)+= aasc.o msrledec.o OBJS-$(CONFIG_AC3_DECODER) += ac3dec_float.o ac3dec_data.o ac3.o \ @@ -222,6 +223,8 @@ OBJS-$(CONFIG_AMRWB_DECODER) += amrwbdec.o celp_filters.o \ celp_math.o acelp_filters.o \ acelp_vectors.o \ acelp_pitch_delay.o +OBJS-$(CONFIG_AMRNB_MEDIACODEC_DECODER) += mediacodecdec.o +OBJS-$(CONFIG_AMRWB_MEDIACODEC_DECODER) += mediacodecdec.o OBJS-$(CONFIG_AMV_ENCODER) += mjpegenc.o mjpegenc_common.o OBJS-$(CONFIG_ANM_DECODER) += anm.o OBJS-$(CONFIG_ANULL_DECODER) += null.o @@ -367,6 +370,7 @@ OBJS-$(CONFIG_FIC_DECODER) += fic.o OBJS-$(CONFIG_FITS_DECODER)+= fitsdec.o fits.o OBJS-$(CONFIG_FITS_ENCODER)+= fitsenc.o OBJS-$(CONFIG_FLAC_DECODER)+= flacdec.o flacdata.o flacdsp.o flac.o +OBJS-$(CONFIG_FLAC_MEDIACODEC_DECODER) += mediacodecdec.o OBJS-$(CONFIG_FLAC_ENCODER)+= flacenc.o flacdata.o flacencdsp.o OBJS-$(CONFIG_FLASHSV_DECODER) += flashsv.o OBJS-$(CONFIG_FLASHSV_ENCODER) += flashsvenc.o @@ -518,6 +522,7 @@ OBJS-$(CONFIG_MP2FIXED_ENCODER)+= mpegaudioenc_fixed.o mpegaudio.o \ mpegaudiotabs.o OBJS-$(CONFIG_MP2FLOAT_DECODER)+= mpegaudiodec_float.o OBJS-$(CONFIG_MP3_DECODER) += mpegaudiodec_fixed.o +OBJS-$(CONFIG_MP3_MEDIACODEC_DECODER) += mediacodecdec.o OBJS-$(CONFIG_MP3_MF_ENCODER) += mfenc.o mf_utils.o OBJS-$(CONFIG_MP3ADU_DECODER) += mpegaudiodec_fixed.o OBJS-$(CONFIG_MP3ADUFLOAT_DECODER) += mpegaudiodec_float.o @@ -578,6 +583,7 @@ OBJS-$(CONFIG_OPUS_DECODER)+= opusdec.o opusdec_celt.o opus_celt.o \ opusdsp.o opus_parse.o opus_rc.o OBJS-$(CONFI
[FFmpeg-devel] [PATCH 2/3] avcodec/mediacodecdec: remove unneeded else block in ff_mediacodec_dec_send()
--- 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 f7a06cdc6d..f90e2f1a23 100644 --- a/libavcodec/mediacodecdec_common.c +++ b/libavcodec/mediacodecdec_common.c @@ -632,7 +632,8 @@ int ff_mediacodec_dec_send(AVCodecContext *avctx, MediaCodecDecContext *s, s->draining = 1; return 0; -} else { +} + size = FFMIN(pkt->size - offset, size); memcpy(data, pkt->data + offset, size); offset += size; @@ -645,7 +646,6 @@ int ff_mediacodec_dec_send(AVCodecContext *avctx, MediaCodecDecContext *s, av_log(avctx, AV_LOG_TRACE, "Queued input buffer %zd size=%zd ts=%"PRIi64"\n", index, size, pts); -} } if (offset == 0) -- 2.21.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 1/3] avcodec/mediacodecdec: try to receive a frame after signaling EOF to the codec
Avoids returning EAGAIN after signaling EOF to the codec in ff_mediacodec_dec_send() so we can try to receive a frame before returning in mediacodec_receive_frame(). This helps avoiding an extra round-trip between avcodec_send_frame() and avcodec_receive_frame() while draining the remaining frames. --- libavcodec/mediacodecdec.c| 1 + libavcodec/mediacodecdec_common.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/libavcodec/mediacodecdec.c b/libavcodec/mediacodecdec.c index 3a4240aa95..e353e34bd5 100644 --- a/libavcodec/mediacodecdec.c +++ b/libavcodec/mediacodecdec.c @@ -461,6 +461,7 @@ static int mediacodec_receive_frame(AVCodecContext *avctx, AVFrame *frame) ret = ff_mediacodec_dec_send(avctx, s->ctx, &null_pkt, true); if (ret < 0) return ret; +return ff_mediacodec_dec_receive(avctx, s->ctx, frame, true); } else if (ret == AVERROR(EAGAIN) && s->ctx->current_input_buffer < 0) { return ff_mediacodec_dec_receive(avctx, s->ctx, frame, true); } else if (ret < 0) { diff --git a/libavcodec/mediacodecdec_common.c b/libavcodec/mediacodecdec_common.c index 7c2661f672..f7a06cdc6d 100644 --- a/libavcodec/mediacodecdec_common.c +++ b/libavcodec/mediacodecdec_common.c @@ -631,7 +631,7 @@ int ff_mediacodec_dec_send(AVCodecContext *avctx, MediaCodecDecContext *s, "Queued input buffer %zd size=%zd ts=%"PRIi64"\n", index, size, pts); s->draining = 1; -break; +return 0; } else { size = FFMIN(pkt->size - offset, size); memcpy(data, pkt->data + offset, size); -- 2.21.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 3/3] avcodec/mediacodecdec: re-indent after previous commit
--- libavcodec/mediacodecdec_common.c | 20 ++-- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/libavcodec/mediacodecdec_common.c b/libavcodec/mediacodecdec_common.c index f90e2f1a23..1656cd6664 100644 --- a/libavcodec/mediacodecdec_common.c +++ b/libavcodec/mediacodecdec_common.c @@ -634,18 +634,18 @@ int ff_mediacodec_dec_send(AVCodecContext *avctx, MediaCodecDecContext *s, return 0; } -size = FFMIN(pkt->size - offset, size); -memcpy(data, pkt->data + offset, size); -offset += size; +size = FFMIN(pkt->size - offset, size); +memcpy(data, pkt->data + offset, size); +offset += size; -status = ff_AMediaCodec_queueInputBuffer(codec, index, 0, size, pts, 0); -if (status < 0) { -av_log(avctx, AV_LOG_ERROR, "Failed to queue input buffer (status = %d)\n", status); -return AVERROR_EXTERNAL; -} +status = ff_AMediaCodec_queueInputBuffer(codec, index, 0, size, pts, 0); +if (status < 0) { +av_log(avctx, AV_LOG_ERROR, "Failed to queue input buffer (status = %d)\n", status); +return AVERROR_EXTERNAL; +} -av_log(avctx, AV_LOG_TRACE, - "Queued input buffer %zd size=%zd ts=%"PRIi64"\n", index, size, pts); +av_log(avctx, AV_LOG_TRACE, + "Queued input buffer %zd size=%zd ts=%"PRIi64"\n", index, size, pts); } if (offset == 0) -- 2.21.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 1/3] avcodec/mediacodecdec: try to receive a frame after signaling EOF to the codec
On Wed, Apr 24, 2019 at 09:59:28AM +0200, Matthieu Bouron wrote: > Avoids returning EAGAIN after signaling EOF to the codec in > ff_mediacodec_dec_send() so we can try to receive a frame before > returning in mediacodec_receive_frame(). > > This helps avoiding an extra round-trip between avcodec_send_frame() and > avcodec_receive_frame() while draining the remaining frames. > --- > libavcodec/mediacodecdec.c| 1 + > libavcodec/mediacodecdec_common.c | 2 +- > 2 files changed, 2 insertions(+), 1 deletion(-) > > diff --git a/libavcodec/mediacodecdec.c b/libavcodec/mediacodecdec.c > index 3a4240aa95..e353e34bd5 100644 > --- a/libavcodec/mediacodecdec.c > +++ b/libavcodec/mediacodecdec.c > @@ -461,6 +461,7 @@ static int mediacodec_receive_frame(AVCodecContext > *avctx, AVFrame *frame) > ret = ff_mediacodec_dec_send(avctx, s->ctx, &null_pkt, true); > if (ret < 0) > return ret; > +return ff_mediacodec_dec_receive(avctx, s->ctx, frame, true); > } else if (ret == AVERROR(EAGAIN) && s->ctx->current_input_buffer < > 0) { > return ff_mediacodec_dec_receive(avctx, s->ctx, frame, true); > } else if (ret < 0) { > diff --git a/libavcodec/mediacodecdec_common.c > b/libavcodec/mediacodecdec_common.c > index 7c2661f672..f7a06cdc6d 100644 > --- a/libavcodec/mediacodecdec_common.c > +++ b/libavcodec/mediacodecdec_common.c > @@ -631,7 +631,7 @@ int ff_mediacodec_dec_send(AVCodecContext *avctx, > MediaCodecDecContext *s, > "Queued input buffer %zd size=%zd ts=%"PRIi64"\n", index, > size, pts); > > s->draining = 1; > -break; > +return 0; > } else { > size = FFMIN(pkt->size - offset, size); > memcpy(data, pkt->data + offset, size); > -- > 2.21.0 > Ping. -- Matthieu B. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 1/3] avcodec/mediacodecdec: try to receive a frame after signaling EOF to the codec
On Tue, May 07, 2019 at 02:09:02AM -0700, Aman Gupta wrote: > On Thu, May 2, 2019 at 1:20 AM Matthieu Bouron > wrote: > > > On Wed, Apr 24, 2019 at 09:59:28AM +0200, Matthieu Bouron wrote: > > > Avoids returning EAGAIN after signaling EOF to the codec in > > > ff_mediacodec_dec_send() so we can try to receive a frame before > > > returning in mediacodec_receive_frame(). > > > > > > This helps avoiding an extra round-trip between avcodec_send_frame() and > > > avcodec_receive_frame() while draining the remaining frames. > > > --- > > > libavcodec/mediacodecdec.c| 1 + > > > libavcodec/mediacodecdec_common.c | 2 +- > > > 2 files changed, 2 insertions(+), 1 deletion(-) > > > > > > diff --git a/libavcodec/mediacodecdec.c b/libavcodec/mediacodecdec.c > > > index 3a4240aa95..e353e34bd5 100644 > > > --- a/libavcodec/mediacodecdec.c > > > +++ b/libavcodec/mediacodecdec.c > > > @@ -461,6 +461,7 @@ static int mediacodec_receive_frame(AVCodecContext > > *avctx, AVFrame *frame) > > > ret = ff_mediacodec_dec_send(avctx, s->ctx, &null_pkt, > > true); > > > if (ret < 0) > > > return ret; > > > +return ff_mediacodec_dec_receive(avctx, s->ctx, frame, > > true); > > > } else if (ret == AVERROR(EAGAIN) && > > s->ctx->current_input_buffer < 0) { > > > return ff_mediacodec_dec_receive(avctx, s->ctx, frame, > > true); > > > } else if (ret < 0) { > > > diff --git a/libavcodec/mediacodecdec_common.c > > b/libavcodec/mediacodecdec_common.c > > > index 7c2661f672..f7a06cdc6d 100644 > > > --- a/libavcodec/mediacodecdec_common.c > > > +++ b/libavcodec/mediacodecdec_common.c > > > @@ -631,7 +631,7 @@ int ff_mediacodec_dec_send(AVCodecContext *avctx, > > MediaCodecDecContext *s, > > > "Queued input buffer %zd size=%zd ts=%"PRIi64"\n", > > index, size, pts); > > > > > > s->draining = 1; > > > -break; > > > +return 0; > > > } else { > > > size = FFMIN(pkt->size - offset, size); > > > memcpy(data, pkt->data + offset, size); > > > -- > > > 2.21.0 > > > > > > > Ping. > > > > Did not test, but the diffs look reasonable to me. I will push the patches in a few days in there is no objection. > > > > > > -- > > Matthieu B. > > ___ > > ffmpeg-devel mailing list > > ffmpeg-devel@ffmpeg.org > > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > > > To unsubscribe, visit link above, or email > > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". -- Matthieu B. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 1/3] avcodec/mediacodecdec: try to receive a frame after signaling EOF to the codec
On Sun, May 26, 2019 at 11:25:09AM +0200, Matthieu Bouron wrote: > On Tue, May 07, 2019 at 02:09:02AM -0700, Aman Gupta wrote: > > On Thu, May 2, 2019 at 1:20 AM Matthieu Bouron > > wrote: > > > > > On Wed, Apr 24, 2019 at 09:59:28AM +0200, Matthieu Bouron wrote: > > > > Avoids returning EAGAIN after signaling EOF to the codec in > > > > ff_mediacodec_dec_send() so we can try to receive a frame before > > > > returning in mediacodec_receive_frame(). > > > > > > > > This helps avoiding an extra round-trip between avcodec_send_frame() and > > > > avcodec_receive_frame() while draining the remaining frames. > > > > --- > > > > libavcodec/mediacodecdec.c| 1 + > > > > libavcodec/mediacodecdec_common.c | 2 +- > > > > 2 files changed, 2 insertions(+), 1 deletion(-) > > > > > > > > diff --git a/libavcodec/mediacodecdec.c b/libavcodec/mediacodecdec.c > > > > index 3a4240aa95..e353e34bd5 100644 > > > > --- a/libavcodec/mediacodecdec.c > > > > +++ b/libavcodec/mediacodecdec.c > > > > @@ -461,6 +461,7 @@ static int mediacodec_receive_frame(AVCodecContext > > > *avctx, AVFrame *frame) > > > > ret = ff_mediacodec_dec_send(avctx, s->ctx, &null_pkt, > > > true); > > > > if (ret < 0) > > > > return ret; > > > > +return ff_mediacodec_dec_receive(avctx, s->ctx, frame, > > > true); > > > > } else if (ret == AVERROR(EAGAIN) && > > > s->ctx->current_input_buffer < 0) { > > > > return ff_mediacodec_dec_receive(avctx, s->ctx, frame, > > > true); > > > > } else if (ret < 0) { > > > > diff --git a/libavcodec/mediacodecdec_common.c > > > b/libavcodec/mediacodecdec_common.c > > > > index 7c2661f672..f7a06cdc6d 100644 > > > > --- a/libavcodec/mediacodecdec_common.c > > > > +++ b/libavcodec/mediacodecdec_common.c > > > > @@ -631,7 +631,7 @@ int ff_mediacodec_dec_send(AVCodecContext *avctx, > > > MediaCodecDecContext *s, > > > > "Queued input buffer %zd size=%zd ts=%"PRIi64"\n", > > > index, size, pts); > > > > > > > > s->draining = 1; > > > > -break; > > > > +return 0; > > > > } else { > > > > size = FFMIN(pkt->size - offset, size); > > > > memcpy(data, pkt->data + offset, size); > > > > -- > > > > 2.21.0 > > > > > > > > > > Ping. > > > > > > > Did not test, but the diffs look reasonable to me. > > I will push the patches in a few days in there is no objection. > Pushed. Thanks. [...] -- Matthieu B. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 3/4] avcodec/mediacodec_wrapper: fix a potential local reference leak in ff_AMediaCodec_getCodecNameByType()
--- libavcodec/mediacodec_wrapper.c | 5 + 1 file changed, 5 insertions(+) diff --git a/libavcodec/mediacodec_wrapper.c b/libavcodec/mediacodec_wrapper.c index e2df07cb41..70e1e7cae1 100644 --- a/libavcodec/mediacodec_wrapper.c +++ b/libavcodec/mediacodec_wrapper.c @@ -469,6 +469,11 @@ char *ff_AMediaCodecList_getCodecNameByType(const char *mime, int profile, int e goto done; } +if (codec_name) { +(*env)->DeleteLocalRef(env, codec_name); +codec_name = NULL; +} + /* Skip software decoders */ if ( strstr(name, "OMX.google") || -- 2.22.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 1/4] avcodec/mediacodec_wrapper: add missing include
--- libavcodec/mediacodec_wrapper.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavcodec/mediacodec_wrapper.h b/libavcodec/mediacodec_wrapper.h index f0de16d669..58e5dc7d39 100644 --- a/libavcodec/mediacodec_wrapper.h +++ b/libavcodec/mediacodec_wrapper.h @@ -26,6 +26,8 @@ #include #include +#include + /** * The following API around MediaCodec and MediaFormat is based on the * NDK one provided by Google since Android 5.0. -- 2.22.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 2/4] avcodec/mediacodec_wrapper: fix a local reference leak in ff_AMediaCodec_getName()
--- libavcodec/mediacodec_wrapper.c | 4 1 file changed, 4 insertions(+) diff --git a/libavcodec/mediacodec_wrapper.c b/libavcodec/mediacodec_wrapper.c index a024e3bdb1..e2df07cb41 100644 --- a/libavcodec/mediacodec_wrapper.c +++ b/libavcodec/mediacodec_wrapper.c @@ -1337,6 +1337,10 @@ char *ff_AMediaCodec_getName(FFAMediaCodec *codec) ret = ff_jni_jstring_to_utf_chars(env, name, codec); fail: +if (name) { +(*env)->DeleteLocalRef(env, name); +} + return ret; } -- 2.22.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 4/4] avcodec/mediacodec_wrapper: remove unused local variables in ff_AMediaCodec_getCodecNameByType()
--- libavcodec/mediacodec_wrapper.c | 10 -- 1 file changed, 10 deletions(-) diff --git a/libavcodec/mediacodec_wrapper.c b/libavcodec/mediacodec_wrapper.c index 70e1e7cae1..5213cf640a 100644 --- a/libavcodec/mediacodec_wrapper.c +++ b/libavcodec/mediacodec_wrapper.c @@ -392,8 +392,6 @@ char *ff_AMediaCodecList_getCodecNameByType(const char *mime, int profile, int e struct JNIAMediaCodecListFields jfields = { 0 }; struct JNIAMediaFormatFields mediaformat_jfields = { 0 }; -jobject format = NULL; -jobject codec = NULL; jobject codec_name = NULL; jobject info = NULL; @@ -571,14 +569,6 @@ done_with_info: } done: -if (format) { -(*env)->DeleteLocalRef(env, format); -} - -if (codec) { -(*env)->DeleteLocalRef(env, codec); -} - if (codec_name) { (*env)->DeleteLocalRef(env, codec_name); } -- 2.22.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 1/4] avcodec/mediacodec_wrapper: add missing include
On Thu, Jul 04, 2019 at 04:03:42PM +0200, Nicolas George wrote: > Matthieu Bouron (12019-07-04): > > --- > > libavcodec/mediacodec_wrapper.h | 2 ++ > > 1 file changed, 2 insertions(+) > > > > diff --git a/libavcodec/mediacodec_wrapper.h > > b/libavcodec/mediacodec_wrapper.h > > index f0de16d669..58e5dc7d39 100644 > > --- a/libavcodec/mediacodec_wrapper.h > > +++ b/libavcodec/mediacodec_wrapper.h > > @@ -26,6 +26,8 @@ > > #include > > #include > > > > > +#include > > AFAIK, this is not the correct way of including one of our own headers, > especially from the same sub-library. Just "avcodec.h". Fixed in attached patch. Thanks. -- Matthieu B. >From a18c2bb9ac6a2cc93434def1124266c92efda7ce Mon Sep 17 00:00:00 2001 From: Matthieu Bouron Date: Mon, 29 Apr 2019 11:24:37 +0200 Subject: [PATCH 1/4] avcodec/mediacodec_wrapper: add missing "avcodec.h" include --- libavcodec/mediacodec_wrapper.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavcodec/mediacodec_wrapper.h b/libavcodec/mediacodec_wrapper.h index f0de16d669..b106ff315a 100644 --- a/libavcodec/mediacodec_wrapper.h +++ b/libavcodec/mediacodec_wrapper.h @@ -26,6 +26,8 @@ #include #include +#include "avcodec.h" + /** * The following API around MediaCodec and MediaFormat is based on the * NDK one provided by Google since Android 5.0. -- 2.22.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 4/4] avcodec/mediacodec_wrapper: remove unused local variables in ff_AMediaCodec_getCodecNameByType()
On Thu, Jul 04, 2019 at 03:43:48PM +0200, Matthieu Bouron wrote: > --- > libavcodec/mediacodec_wrapper.c | 10 -- > 1 file changed, 10 deletions(-) > > diff --git a/libavcodec/mediacodec_wrapper.c b/libavcodec/mediacodec_wrapper.c > index 70e1e7cae1..5213cf640a 100644 > --- a/libavcodec/mediacodec_wrapper.c > +++ b/libavcodec/mediacodec_wrapper.c > @@ -392,8 +392,6 @@ char *ff_AMediaCodecList_getCodecNameByType(const char > *mime, int profile, int e > struct JNIAMediaCodecListFields jfields = { 0 }; > struct JNIAMediaFormatFields mediaformat_jfields = { 0 }; > > -jobject format = NULL; > -jobject codec = NULL; > jobject codec_name = NULL; > > jobject info = NULL; > @@ -571,14 +569,6 @@ done_with_info: > } > > done: > -if (format) { > -(*env)->DeleteLocalRef(env, format); > -} > - > -if (codec) { > -(*env)->DeleteLocalRef(env, codec); > -} > - > if (codec_name) { > (*env)->DeleteLocalRef(env, codec_name); > } > -- > 2.22.0 > Ping for the patch set. -- Matthieu B. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 4/4] avcodec/mediacodec_wrapper: remove unused local variables in ff_AMediaCodec_getCodecNameByType()
On Sun, Jul 14, 2019 at 08:17:03PM +0200, Matthieu Bouron wrote: > On Thu, Jul 04, 2019 at 03:43:48PM +0200, Matthieu Bouron wrote: > > --- > > libavcodec/mediacodec_wrapper.c | 10 -- > > 1 file changed, 10 deletions(-) > > > > diff --git a/libavcodec/mediacodec_wrapper.c > > b/libavcodec/mediacodec_wrapper.c > > index 70e1e7cae1..5213cf640a 100644 > > --- a/libavcodec/mediacodec_wrapper.c > > +++ b/libavcodec/mediacodec_wrapper.c > > @@ -392,8 +392,6 @@ char *ff_AMediaCodecList_getCodecNameByType(const char > > *mime, int profile, int e > > struct JNIAMediaCodecListFields jfields = { 0 }; > > struct JNIAMediaFormatFields mediaformat_jfields = { 0 }; > > > > -jobject format = NULL; > > -jobject codec = NULL; > > jobject codec_name = NULL; > > > > jobject info = NULL; > > @@ -571,14 +569,6 @@ done_with_info: > > } > > > > done: > > -if (format) { > > -(*env)->DeleteLocalRef(env, format); > > -} > > - > > -if (codec) { > > -(*env)->DeleteLocalRef(env, codec); > > -} > > - > > if (codec_name) { > > (*env)->DeleteLocalRef(env, codec_name); > > } > > -- > > 2.22.0 > > > > Ping for the patch set. If there is no objection, I will push the patchset in a few days. > > -- > Matthieu B. -- Matthieu B. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 4/4] avcodec/mediacodec_wrapper: remove unused local variables in ff_AMediaCodec_getCodecNameByType()
On Fri, Jul 19, 2019 at 09:40:52AM +0200, Matthieu Bouron wrote: > On Sun, Jul 14, 2019 at 08:17:03PM +0200, Matthieu Bouron wrote: > > On Thu, Jul 04, 2019 at 03:43:48PM +0200, Matthieu Bouron wrote: > > > --- > > > libavcodec/mediacodec_wrapper.c | 10 -- > > > 1 file changed, 10 deletions(-) > > > > > > diff --git a/libavcodec/mediacodec_wrapper.c > > > b/libavcodec/mediacodec_wrapper.c > > > index 70e1e7cae1..5213cf640a 100644 > > > --- a/libavcodec/mediacodec_wrapper.c > > > +++ b/libavcodec/mediacodec_wrapper.c > > > @@ -392,8 +392,6 @@ char *ff_AMediaCodecList_getCodecNameByType(const > > > char *mime, int profile, int e > > > struct JNIAMediaCodecListFields jfields = { 0 }; > > > struct JNIAMediaFormatFields mediaformat_jfields = { 0 }; > > > > > > -jobject format = NULL; > > > -jobject codec = NULL; > > > jobject codec_name = NULL; > > > > > > jobject info = NULL; > > > @@ -571,14 +569,6 @@ done_with_info: > > > } > > > > > > done: > > > -if (format) { > > > -(*env)->DeleteLocalRef(env, format); > > > -} > > > - > > > -if (codec) { > > > -(*env)->DeleteLocalRef(env, codec); > > > -} > > > - > > > if (codec_name) { > > > (*env)->DeleteLocalRef(env, codec_name); > > > } > > > -- > > > 2.22.0 > > > > > > > Ping for the patch set. > > If there is no objection, I will push the patchset in a few days. > Pushed to master. Is it still on time to also be pushed to the 4.2 release branch ? Thanks. -- Matthieu B. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 4/4] avcodec/mediacodec_wrapper: remove unused local variables in ff_AMediaCodec_getCodecNameByType()
On Tue, Jul 23, 2019 at 01:09:41AM +0200, Michael Niedermayer wrote: > On Mon, Jul 22, 2019 at 09:02:15AM +0200, Matthieu Bouron wrote: > > On Fri, Jul 19, 2019 at 09:40:52AM +0200, Matthieu Bouron wrote: > > > On Sun, Jul 14, 2019 at 08:17:03PM +0200, Matthieu Bouron wrote: > > > > On Thu, Jul 04, 2019 at 03:43:48PM +0200, Matthieu Bouron wrote: > > > > > --- > > > > > libavcodec/mediacodec_wrapper.c | 10 -- > > > > > 1 file changed, 10 deletions(-) > > > > > > > > > > diff --git a/libavcodec/mediacodec_wrapper.c > > > > > b/libavcodec/mediacodec_wrapper.c > > > > > index 70e1e7cae1..5213cf640a 100644 > > > > > --- a/libavcodec/mediacodec_wrapper.c > > > > > +++ b/libavcodec/mediacodec_wrapper.c > > > > > @@ -392,8 +392,6 @@ char *ff_AMediaCodecList_getCodecNameByType(const > > > > > char *mime, int profile, int e > > > > > struct JNIAMediaCodecListFields jfields = { 0 }; > > > > > struct JNIAMediaFormatFields mediaformat_jfields = { 0 }; > > > > > > > > > > -jobject format = NULL; > > > > > -jobject codec = NULL; > > > > > jobject codec_name = NULL; > > > > > > > > > > jobject info = NULL; > > > > > @@ -571,14 +569,6 @@ done_with_info: > > > > > } > > > > > > > > > > done: > > > > > -if (format) { > > > > > -(*env)->DeleteLocalRef(env, format); > > > > > -} > > > > > - > > > > > -if (codec) { > > > > > -(*env)->DeleteLocalRef(env, codec); > > > > > -} > > > > > - > > > > > if (codec_name) { > > > > > (*env)->DeleteLocalRef(env, codec_name); > > > > > } > > > > > -- > > > > > 2.22.0 > > > > > > > > > > > > > Ping for the patch set. > > > > > > If there is no objection, I will push the patchset in a few days. > > > > > > > Pushed to master. Is it still on time to also be pushed to the 4.2 release > > branch ? > > i found no time today for working on the release so theres still time for > any backports of bug fixes, yes Pushed to the release/4.2 branch. Thanks. -- Matthieu B. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] RELEASE: update for git after 4.0 branchpoint
--- RELEASE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RELEASE b/RELEASE index 9b601acc0d..ff2c9d1a30 100644 --- a/RELEASE +++ b/RELEASE @@ -1 +1 @@ -3.4.git +4.0.git -- 2.19.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] RELEASE: update for git after 4.0 branchpoint
On Tue, Sep 25, 2018 at 3:12 PM, James Almer wrote: > On 9/25/2018 6:32 AM, Matthieu Bouron wrote: > > --- > > RELEASE | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/RELEASE b/RELEASE > > index 9b601acc0d..ff2c9d1a30 100644 > > --- a/RELEASE > > +++ b/RELEASE > > @@ -1 +1 @@ > > -3.4.git > > +4.0.git > > LGTM. Better late than never... > Pushed, thanks. [...] ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH] avcodec/mediacodec_common: use MediaFormat to probe frame color characteristics
--- libavcodec/mediacodecdec_common.c | 100 ++ 1 file changed, 100 insertions(+) diff --git a/libavcodec/mediacodecdec_common.c b/libavcodec/mediacodecdec_common.c index f0752fa6261..404ed282275 100644 --- a/libavcodec/mediacodecdec_common.c +++ b/libavcodec/mediacodecdec_common.c @@ -85,6 +85,85 @@ #define OUTPUT_DEQUEUE_TIMEOUT_US 8000 #define OUTPUT_DEQUEUE_BLOCK_TIMEOUT_US 100 +enum { +COLOR_RANGE_FULL= 0x1, +COLOR_RANGE_LIMITED = 0x2, +}; + +static enum AVColorRange mcdec_get_color_range(int color_range) +{ +switch (color_range) { +case COLOR_RANGE_FULL: +return AVCOL_RANGE_JPEG; +case COLOR_RANGE_LIMITED: +return AVCOL_RANGE_MPEG; +default: +return AVCOL_RANGE_UNSPECIFIED; +} +} + +enum { +COLOR_STANDARD_BT709 = 0x1, +COLOR_STANDARD_BT601_PAL = 0x2, +COLOR_STANDARD_BT601_NTSC = 0x4, +COLOR_STANDARD_BT2020 = 0x6, +}; + +static enum AVColorSpace mcdec_get_color_space(int color_standard) +{ +switch (color_standard) { +case COLOR_STANDARD_BT709: +return AVCOL_SPC_BT709; +case COLOR_STANDARD_BT601_PAL: +return AVCOL_SPC_BT470BG; +case COLOR_STANDARD_BT601_NTSC: +return AVCOL_SPC_SMPTE170M; +case COLOR_STANDARD_BT2020: +return AVCOL_SPC_BT2020_NCL; +default: +return AVCOL_SPC_UNSPECIFIED; +} +} + +static enum AVColorPrimaries mcdec_get_color_pri(int color_standard) +{ +switch (color_standard) { +case COLOR_STANDARD_BT709: +return AVCOL_PRI_BT709; +case COLOR_STANDARD_BT601_PAL: +return AVCOL_PRI_BT470BG; +case COLOR_STANDARD_BT601_NTSC: +return AVCOL_PRI_SMPTE170M; +case COLOR_STANDARD_BT2020: +return AVCOL_PRI_BT2020; +default: +return AVCOL_PRI_UNSPECIFIED; +} +} + +enum { +COLOR_TRANSFER_LINEAR= 0x1, +COLOR_TRANSFER_SDR_VIDEO = 0x3, +COLOR_TRANSFER_ST2084= 0x6, +COLOR_TRANSFER_HLG = 0x7, +}; + +static enum AVColorTransferCharacteristic mcdec_get_color_trc(int color_transfer) +{ +switch (color_transfer) { +case COLOR_TRANSFER_LINEAR: +return AVCOL_TRC_LINEAR; +case COLOR_TRANSFER_SDR_VIDEO: +return AVCOL_TRC_SMPTE170M; +case COLOR_TRANSFER_ST2084: +return AVCOL_TRC_SMPTEST2084; +case COLOR_TRANSFER_HLG: +return AVCOL_TRC_ARIB_STD_B67; +default: +return AVCOL_TRC_UNSPECIFIED; +} +} + enum { COLOR_FormatYUV420Planar = 0x13, COLOR_FormatYUV420SemiPlanar = 0x15, @@ -220,6 +299,10 @@ FF_DISABLE_DEPRECATION_WARNINGS FF_ENABLE_DEPRECATION_WARNINGS #endif frame->pkt_dts = AV_NOPTS_VALUE; +frame->color_range = avctx->color_range; +frame->color_primaries = avctx->color_primaries; +frame->color_trc = avctx->color_trc; +frame->colorspace = avctx->colorspace; buffer = av_mallocz(sizeof(AVMediaCodecBuffer)); if (!buffer) { @@ -368,6 +451,9 @@ static int mediacodec_dec_parse_format(AVCodecContext *avctx, MediaCodecDecConte int ret = 0; int width = 0; int height = 0; +int color_range = 0; +int color_standard = 0; +int color_transfer = 0; char *format = NULL; if (!s->format) { @@ -426,6 +512,20 @@ static int mediacodec_dec_parse_format(AVCodecContext *avctx, MediaCodecDecConte ff_set_sar(avctx, sar); } +AMEDIAFORMAT_GET_INT32(color_range, "color-range", 0); +if (color_range) +avctx->color_range = mcdec_get_color_range(color_range); + +AMEDIAFORMAT_GET_INT32(color_standard, "color-standard", 0); +if (color_standard) { +avctx->colorspace = mcdec_get_color_space(color_standard); +avctx->color_primaries = mcdec_get_color_pri(color_standard); +} + +AMEDIAFORMAT_GET_INT32(color_transfer, "color-transfer", 0); +if (color_transfer) +avctx->color_trc = mcdec_get_color_trc(color_transfer); + av_log(avctx, AV_LOG_INFO, "Output crop parameters top=%d bottom=%d left=%d right=%d, " "resulting dimensions width=%d height=%d\n", -- 2.26.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] about mediacodec encoder on android platform
On Fri, Mar 27, 2020 at 04:21:59PM +0800, aistoy wrote: > Hi, I want to know why ffmpeg do not include mediacodec encoder, just include > mediacodec decoder. > And why the decoder implemention don’t use mediacodec native api, but use jni > call mediacodec java methods. > If i plan to add the mediacodec encoder, what do you think i should pay > attention to ? Hi, Sorry for the late replay. The MediaCodec decoder wrapper in FFmpeg does not use the native API because at the time it was implemented, more than 40% of the devices were running Android 4.4 (which does not support the native API). The MediaCodec native API has also some limitation regarding codec probing, ie: it does not provide a wrapper around MediaCodecList/MediaCodecInfo. We use this capability to blacklist software codecs for example. I made our MediaCodec java wrapper implement the same API as the native one provided by the NDK so it shouldn't be too hard to switch. Moreover, Aman Gupta already already did this work in one of his branches. The "tricky" part about implementing MediaCodec encoding support in FFmpeg will be to fit the encoder input surface API into the libavcodec API. > thanks! > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". -- Matthieu B. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] avformat/img2dec: skip DHT segment in jpeg_probe()
--- libavformat/img2dec.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavformat/img2dec.c b/libavformat/img2dec.c index 40f3e3d499e..93cd51c1932 100644 --- a/libavformat/img2dec.c +++ b/libavformat/img2dec.c @@ -775,6 +775,7 @@ static int jpeg_probe(const AVProbeData *p) return 0; state = EOI; break; +case DHT: case DQT: case APP0: case APP1: -- 2.26.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] avformat/img2dec: skip DHT segment in jpeg_probe()
On Wed, Apr 01, 2020 at 03:38:45PM +0200, Carl Eugen Hoyos wrote: > Am Mi., 1. Apr. 2020 um 10:57 Uhr schrieb Matthieu Bouron > : > > > > --- > > libavformat/img2dec.c | 1 + > > 1 file changed, 1 insertion(+) > > > > diff --git a/libavformat/img2dec.c b/libavformat/img2dec.c > > index 40f3e3d499e..93cd51c1932 100644 > > --- a/libavformat/img2dec.c > > +++ b/libavformat/img2dec.c > > @@ -775,6 +775,7 @@ static int jpeg_probe(const AVProbeData *p) > > return 0; > > state = EOI; > > break; > > +case DHT: > > case DQT: > > case APP0: > > case APP1: > > Please provide a sample file. This patch does not fix a particular issue. IMHO, we should skip the DHT segment just like the other segments (and avoids parsing the data it contains) unless there is a particular reason for it ? > > Thank you, Carl Eugen > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". -- Matthieu B. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] avformat/img2dec: skip DHT segment in jpeg_probe()
On Wed, Apr 01, 2020 at 01:04:58PM +0100, Derek Buitenhuis wrote: > On 01/04/2020 09:52, Matthieu Bouron wrote: > > --- > > libavformat/img2dec.c | 1 + > > 1 file changed, 1 insertion(+) > > Looks correct, but a commit message explaining why would be good. > Would "Skips the DHT segment in jpeg_probe() to avoid looking for JPEG markers in the DHT segment data" be OK ? > - Derek > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". -- Matthieu B. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] avformat/img2dec: skip DHT segment in jpeg_probe()
On Wed, Apr 01, 2020 at 04:09:08PM +0200, Carl Eugen Hoyos wrote: > Am Mi., 1. Apr. 2020 um 15:48 Uhr schrieb Matthieu Bouron > : > > > > On Wed, Apr 01, 2020 at 03:38:45PM +0200, Carl Eugen Hoyos wrote: > > > Am Mi., 1. Apr. 2020 um 10:57 Uhr schrieb Matthieu Bouron > > > : > > > > > > > > --- > > > > libavformat/img2dec.c | 1 + > > > > 1 file changed, 1 insertion(+) > > > > > > > > diff --git a/libavformat/img2dec.c b/libavformat/img2dec.c > > > > index 40f3e3d499e..93cd51c1932 100644 > > > > --- a/libavformat/img2dec.c > > > > +++ b/libavformat/img2dec.c > > > > @@ -775,6 +775,7 @@ static int jpeg_probe(const AVProbeData *p) > > > > return 0; > > > > state = EOI; > > > > break; > > > > +case DHT: > > > > case DQT: > > > > case APP0: > > > > case APP1: > > > > > > Please provide a sample file. > > > > This patch does not fix a particular issue. IMHO, we should skip the DHT > > segment just like the other segments (and avoids parsing the data it > > contains) unless there is a particular reason for it ? > > I am (somewhat strongly) against patches that do not fix issues but > Michael will hopefully comment. > > Or are you trying to improve probing speed? I am trying to fix an issues with JPEG files containing MPF metadata appended at the end. Theses files makes the jpeg_probe function fails (returns 0) because the MPF metadata contains JPEG images (so jpeg_probe() finds a SOI marker after EOI). I will send a separate patch for that and provide a sample. This patch should improve the probing speed by little though. > > Carl Eugen > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". -- Matthieu B. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] avformat/img2dec: return immediately in jpeg_probe() when EOI is found
Fixes probing of JPEG files containing MPF metadata appended at the end of the file. The MPF metadata chunk can contains multiple JPEG images (thumbnails) which makes the jpeg_probe fails (return 0) because it finds a SOI marker after EOI. --- This patch fixes probing of JPEG files containing MPF metadata [1] appended at the end of the file. Such files can be produced by GoPro camera (which produces JPEG files with MPF metadata). You can find a sample here: https://0x5c.me/gopro_jpg_mpf_probe_fail To reproduce the issue using ffmpeg master: wget https://0x5c.me/gopro_jpg_mpf_probe_fail ./ffmpeg -formatprobesize 500 -i gopro_jpg_mpf_probe_fail I removed intentionally the jpeg extension from the filename so the image2 demuxer is not used. Current ffmpeg master won't still be able to decode this file because of a "regression" introduced by ec3d8a0e6945fe015d16cd98a1e7dbb4be815c15 on the mjpeg_parser. The jpeg_pipe demuxer outputs partial chunks of the jpeg file that the mjpeg decoder can't handle (it needs the whole data). Before ec3d8a0e6945fe015d16cd98a1e7dbb4be815c15, the mjpeg_parser was outputting a complete frame. If the parser is correct as is, another way to fix this issue whould be to add AVSTREAM_PARSE_HEADERS to the need_parsing flags from the jpeg_pipe demuxer, ie: --- a/libavformat/img2dec.c +++ b/libavformat/img2dec.c @@ -209,7 +209,7 @@ int ff_img_read_header(AVFormatContext *s1) s->is_pipe = 0; else { s->is_pipe = 1; -st->need_parsing = AVSTREAM_PARSE_FULL; +st->need_parsing = AVSTREAM_PARSE_FULL | AVSTREAM_PARSE_HEADERS; Settings AVSTREAM_PARSE_HEADERS makes avformat requests complete frames from the parser in libavformat/utils.c What do you think ? [1] https://exiftool.org/TagNames/MPF.html --- libavformat/img2dec.c | 6 +- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/libavformat/img2dec.c b/libavformat/img2dec.c index 93cd51c1932..decd8023e02 100644 --- a/libavformat/img2dec.c +++ b/libavformat/img2dec.c @@ -773,9 +773,7 @@ static int jpeg_probe(const AVProbeData *p) case EOI: if (state != SOS) return 0; -state = EOI; -break; -case DHT: +return AVPROBE_SCORE_EXTENSION + 1; case DQT: case APP0: case APP1: @@ -803,8 +801,6 @@ static int jpeg_probe(const AVProbeData *p) } } -if (state == EOI) -return AVPROBE_SCORE_EXTENSION + 1; if (state == SOS) return AVPROBE_SCORE_EXTENSION / 2; return AVPROBE_SCORE_EXTENSION / 8; -- 2.26.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] avformat/img2dec: skip DHT segment in jpeg_probe()
On Wed, Apr 01, 2020 at 04:29:16PM +0200, Carl Eugen Hoyos wrote: > Am Mi., 1. Apr. 2020 um 16:24 Uhr schrieb Matthieu Bouron > : > > > > On Wed, Apr 01, 2020 at 04:09:08PM +0200, Carl Eugen Hoyos wrote: > > > Am Mi., 1. Apr. 2020 um 15:48 Uhr schrieb Matthieu Bouron > > > : > > > > > > > > On Wed, Apr 01, 2020 at 03:38:45PM +0200, Carl Eugen Hoyos wrote: > > > > > Am Mi., 1. Apr. 2020 um 10:57 Uhr schrieb Matthieu Bouron > > > > > : > > > > > > > > > > > > --- > > > > > > libavformat/img2dec.c | 1 + > > > > > > 1 file changed, 1 insertion(+) > > > > > > > > > > > > diff --git a/libavformat/img2dec.c b/libavformat/img2dec.c > > > > > > index 40f3e3d499e..93cd51c1932 100644 > > > > > > --- a/libavformat/img2dec.c > > > > > > +++ b/libavformat/img2dec.c > > > > > > @@ -775,6 +775,7 @@ static int jpeg_probe(const AVProbeData *p) > > > > > > return 0; > > > > > > state = EOI; > > > > > > break; > > > > > > +case DHT: > > > > > > case DQT: > > > > > > case APP0: > > > > > > case APP1: > > > > > > > > > > Please provide a sample file. > > > > > > > > This patch does not fix a particular issue. IMHO, we should skip the DHT > > > > segment just like the other segments (and avoids parsing the data it > > > > contains) unless there is a particular reason for it ? > > > > > > I am (somewhat strongly) against patches that do not fix issues but > > > Michael will hopefully comment. > > > > > > Or are you trying to improve probing speed? > > > > I am trying to fix an issues with JPEG files containing MPF metadata > > appended at the end. > > Theses files makes the jpeg_probe function fails (returns 0) because the > > MPF metadata contains JPEG images (so jpeg_probe() finds a SOI marker > > after EOI). I will send a separate patch for that and provide a > > sample. > > Are these valid jpeg files? They are valid JPEGs with MPF metadata (https://exiftool.org/TagNames/MPF.html). See https://ffmpeg.org/pipermail/ffmpeg-devel/2020-April/259489.html > > > This patch should improve the probing speed by little though. > > Then please measure the speedup and mention it in the > commit message. I tried to measure the speed gain using perf record ffmpeg -i [...] without success (i can't get a meaningful difference between the different runs which makes sense as the DHT segment size from the file I test against is 419 bytes). > > Thank you, Carl Eugen > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". -- Matthieu B. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] avformat/img2dec: return immediately in jpeg_probe() when EOI is found
On Wed, Apr 01, 2020 at 06:29:03PM +0200, Carl Eugen Hoyos wrote: > Am Mi., 1. Apr. 2020 um 18:01 Uhr schrieb Matthieu Bouron > : > > > > Fixes probing of JPEG files containing MPF metadata appended at the end > > of the file. > > > > The MPF metadata chunk can contains multiple JPEG images (thumbnails) > > which makes the jpeg_probe fails (return 0) because it finds a SOI > > marker after EOI. > > --- > > > > This patch fixes probing of JPEG files containing MPF metadata [1] appended > > at the end of the file. > > > > Such files can be produced by GoPro camera (which produces JPEG files > > with MPF metadata). > > > > You can find a sample here: > > https://0x5c.me/gopro_jpg_mpf_probe_fail > > The sample works fine here with FFmpeg 4.2: Is there a regression? This sample does not work on FFmpeg 4.2 and master if you set a big enought formatprobesize (which matches the file size of the sample): ffmpeg -formatprobesize 500 -i ~/gopro_jpg_mpf_probe_fail gives: /home/mateo/gopro_jpg_mpf_probe_fail: Invalid data found when processing input > > Carl Eugen > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". -- Matthieu B. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] avformat/img2dec: return immediately in jpeg_probe() when EOI is found
On Wed, Apr 01, 2020 at 06:19:56PM +0200, Carl Eugen Hoyos wrote: > Am Mi., 1. Apr. 2020 um 18:01 Uhr schrieb Matthieu Bouron > : > > > > Fixes probing of JPEG files containing MPF metadata appended at the end > > of the file. > > > > The MPF metadata chunk can contains multiple JPEG images (thumbnails) > > which makes the jpeg_probe fails (return 0) because it finds a SOI > > marker after EOI. > > --- > > > > This patch fixes probing of JPEG files containing MPF metadata [1] appended > > at the end of the file. > > > > Such files can be produced by GoPro camera (which produces JPEG files > > with MPF metadata). > > > > You can find a sample here: > > https://0x5c.me/gopro_jpg_mpf_probe_fail > > > > To reproduce the issue using ffmpeg master: > > wget https://0x5c.me/gopro_jpg_mpf_probe_fail > > ./ffmpeg -formatprobesize 500 -i gopro_jpg_mpf_probe_fail > > > > I removed intentionally the jpeg extension from the filename so the > > image2 demuxer is not used. > > > > Current ffmpeg master won't still be able to decode this file because of a > > "regression" introduced by ec3d8a0e6945fe015d16cd98a1e7dbb4be815c15 on > > the mjpeg_parser. > > The jpeg_pipe demuxer outputs partial chunks of the jpeg file that the > > mjpeg decoder can't handle (it needs the whole data). Before > > ec3d8a0e6945fe015d16cd98a1e7dbb4be815c15, the mjpeg_parser was > > outputting a complete frame. > > > > If the parser is correct as is, another way to fix this issue whould be > > to add AVSTREAM_PARSE_HEADERS to the need_parsing flags from the > > jpeg_pipe demuxer, ie: > > > > --- a/libavformat/img2dec.c > > +++ b/libavformat/img2dec.c > > @@ -209,7 +209,7 @@ int ff_img_read_header(AVFormatContext *s1) > > s->is_pipe = 0; > > else { > > s->is_pipe = 1; > > -st->need_parsing = AVSTREAM_PARSE_FULL; > > +st->need_parsing = AVSTREAM_PARSE_FULL | AVSTREAM_PARSE_HEADERS; > > > > Settings AVSTREAM_PARSE_HEADERS makes avformat requests complete frames > > from the parser in libavformat/utils.c > > > > What do you think ? > > Why is your sample not detected by the mjpeg demuxer? I don't know yet, it looks like nb_invalid is incremented in the default case of mjpeg_probe(). I will investigate why. This shouldn't change the fact that the jpeg_probe() should be able to recognize this kind of files. > > I suspect your patch breaks the mjpeg demuxer. Why would it break the mjpeg demuxer ? > > > [1] https://exiftool.org/TagNames/MPF.html > > > > --- > > libavformat/img2dec.c | 6 +- > > 1 file changed, 1 insertion(+), 5 deletions(-) > > > > diff --git a/libavformat/img2dec.c b/libavformat/img2dec.c > > index 93cd51c1932..decd8023e02 100644 > > --- a/libavformat/img2dec.c > > +++ b/libavformat/img2dec.c > > @@ -773,9 +773,7 @@ static int jpeg_probe(const AVProbeData *p) > > case EOI: > > if (state != SOS) > > return 0; > > -state = EOI; > > -break; > > -case DHT: > > +return AVPROBE_SCORE_EXTENSION + 1; > > I don't think this is correct. Why ? Isn't the data JPEG if we find an EOI marker after having found a SOS marker ? > > > case DQT: > > case APP0: > > case APP1: > > @@ -803,8 +801,6 @@ static int jpeg_probe(const AVProbeData *p) > > } > > } > > > > > -if (state == EOI) > > -return AVPROBE_SCORE_EXTENSION + 1; > > > if (state == SOS) > > return AVPROBE_SCORE_EXTENSION / 2; > > return AVPROBE_SCORE_EXTENSION / 8; > > Carl Eugen > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". -- Matthieu B. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] avformat/img2dec: return immediately in jpeg_probe() when EOI is found
On Wed, Apr 01, 2020 at 06:55:42PM +0200, Carl Eugen Hoyos wrote: > Am Mi., 1. Apr. 2020 um 18:35 Uhr schrieb Matthieu Bouron > : > > > > On Wed, Apr 01, 2020 at 06:29:03PM +0200, Carl Eugen Hoyos wrote: > > > Am Mi., 1. Apr. 2020 um 18:01 Uhr schrieb Matthieu Bouron > > > : > > > > > > > > Fixes probing of JPEG files containing MPF metadata appended at the end > > > > of the file. > > > > > > > > The MPF metadata chunk can contains multiple JPEG images (thumbnails) > > > > which makes the jpeg_probe fails (return 0) because it finds a SOI > > > > marker after EOI. > > > > --- > > > > > > > > This patch fixes probing of JPEG files containing MPF metadata [1] > > > > appended > > > > at the end of the file. > > > > > > > > Such files can be produced by GoPro camera (which produces JPEG files > > > > with MPF metadata). > > > > > > > > You can find a sample here: > > > > https://0x5c.me/gopro_jpg_mpf_probe_fail > > > > > > The sample works fine here with FFmpeg 4.2: Is there a regression? > > > > This sample does not work on FFmpeg 4.2 and master if you set a big > > enought formatprobesize (which matches the file size of the sample): > > Inlined is a patch that fixes detection but I wonder if this shouldn't be > detected as mjpeg instead > > Carl Eugen > > diff --git a/libavformat/img2dec.c b/libavformat/img2dec.c > index 40f3e3d499..4e63b3494e 100644 > --- a/libavformat/img2dec.c > +++ b/libavformat/img2dec.c > @@ -737,20 +737,22 @@ static int j2k_probe(const AVProbeData *p) > static int jpeg_probe(const AVProbeData *p) > { > const uint8_t *b = p->buf; > -int i, state = SOI; > +int i, state = SOI, MPF = 0; > > if (AV_RB16(b) != 0xFFD8 || > AV_RB32(b) == 0xFFD8FFF7) > return 0; > > b += 2; > -for (i = 0; i < p->buf_size - 3; i++) { > +for (i = 0; i < p->buf_size - 8; i++) { > int c; > if (b[i] != 0xFF) > continue; > c = b[i + 1]; > switch (c) { > case SOI: > +if (state == EOI && MPF) > +return AVPROBE_SCORE_EXTENSION + 1; Your patch might work but the code is trying to find JPEG markers in the MPF metadata until we reach the first EOI in the MPF JPEG thumbnails, even if we already found the SOS and EOI markes of the main JPEG chunk. This logic does not seem right to me. Is there a specific reason why we couldn't end the probe when we reach the EOI marker in the SOS state (ie: what my patch is doing) ? > return 0; > case SOF0: > case SOF1: > @@ -775,10 +777,12 @@ static int jpeg_probe(const AVProbeData *p) > return 0; > state = EOI; > break; > +case APP2: > +if (AV_RB24(&b[i + 4]) == AV_RB24("MPF")) > +MPF = 1; > case DQT: > case APP0: > case APP1: > -case APP2: > case APP3: > case APP4: > case APP5: > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". -- Matthieu B. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] avformat/img2dec: return immediately in jpeg_probe() when EOI is found
On Wed, Apr 01, 2020 at 07:30:55PM +0200, Carl Eugen Hoyos wrote: > Am Mi., 1. Apr. 2020 um 19:15 Uhr schrieb Matthieu Bouron > : > > > > On Wed, Apr 01, 2020 at 06:55:42PM +0200, Carl Eugen Hoyos wrote: > > > Am Mi., 1. Apr. 2020 um 18:35 Uhr schrieb Matthieu Bouron > > > : > > > > > > > > On Wed, Apr 01, 2020 at 06:29:03PM +0200, Carl Eugen Hoyos wrote: > > > > > Am Mi., 1. Apr. 2020 um 18:01 Uhr schrieb Matthieu Bouron > > > > > : > > > > > > > > > > > > Fixes probing of JPEG files containing MPF metadata appended at the > > > > > > end > > > > > > of the file. > > > > > > > > > > > > The MPF metadata chunk can contains multiple JPEG images > > > > > > (thumbnails) > > > > > > which makes the jpeg_probe fails (return 0) because it finds a SOI > > > > > > marker after EOI. > > > > > > --- > > > > > > > > > > > > This patch fixes probing of JPEG files containing MPF metadata [1] > > > > > > appended > > > > > > at the end of the file. > > > > > > > > > > > > Such files can be produced by GoPro camera (which produces JPEG > > > > > > files > > > > > > with MPF metadata). > > > > > > > > > > > > You can find a sample here: > > > > > > https://0x5c.me/gopro_jpg_mpf_probe_fail > > > > > > > > > > The sample works fine here with FFmpeg 4.2: Is there a regression? > > > > > > > > This sample does not work on FFmpeg 4.2 and master if you set a big > > > > enought formatprobesize (which matches the file size of the sample): > > > > > > Inlined is a patch that fixes detection but I wonder if this shouldn't be > > > detected as mjpeg instead > > > > > > Carl Eugen > > > > > > diff --git a/libavformat/img2dec.c b/libavformat/img2dec.c > > > index 40f3e3d499..4e63b3494e 100644 > > > --- a/libavformat/img2dec.c > > > +++ b/libavformat/img2dec.c > > > @@ -737,20 +737,22 @@ static int j2k_probe(const AVProbeData *p) > > > static int jpeg_probe(const AVProbeData *p) > > > { > > > const uint8_t *b = p->buf; > > > -int i, state = SOI; > > > +int i, state = SOI, MPF = 0; > > > > > > if (AV_RB16(b) != 0xFFD8 || > > > AV_RB32(b) == 0xFFD8FFF7) > > > return 0; > > > > > > b += 2; > > > -for (i = 0; i < p->buf_size - 3; i++) { > > > +for (i = 0; i < p->buf_size - 8; i++) { > > > int c; > > > if (b[i] != 0xFF) > > > continue; > > > c = b[i + 1]; > > > switch (c) { > > > case SOI: > > > +if (state == EOI && MPF) > > > +return AVPROBE_SCORE_EXTENSION + 1; > > > > Your patch might work > > You could test it. > > > but the code is trying to find JPEG markers in the > > MPF metadata until we reach the first EOI in the MPF JPEG thumbnails, > I meant SOI sorry. > No, and I am quite sure that I tested this sufficiently. My point is, we are trying to parse way more data than necessary (the data we parse might not be jpeg at this point): the code looks for a marker and handles it, if the marker is unknown it repeats this operation for the next byte until it reaches the end of the buffer or it finds SOI in the EOI+MPF state (with your patch). Why cant' we end the processing at EOI ? If there is a particular reason for that ? > > Shouldn't there be a mpf demuxer that also provides the attachments? I already have a patch to parse the MPF metadata. The only thing left to do is to expose the attachments (it currently only exposes those as file offsets in stream metadata). I will send the patch later on. > > Carl Eugen > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". -- Matthieu B. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] avformat/img2dec: return immediately in jpeg_probe() when EOI is found
On Wed, Apr 01, 2020 at 07:59:46PM +0200, Carl Eugen Hoyos wrote: > Am Mi., 1. Apr. 2020 um 19:54 Uhr schrieb Matthieu Bouron > : > > > > On Wed, Apr 01, 2020 at 07:30:55PM +0200, Carl Eugen Hoyos wrote: > > > Am Mi., 1. Apr. 2020 um 19:15 Uhr schrieb Matthieu Bouron > > > : > > > > > > > > On Wed, Apr 01, 2020 at 06:55:42PM +0200, Carl Eugen Hoyos wrote: > > > > > Am Mi., 1. Apr. 2020 um 18:35 Uhr schrieb Matthieu Bouron > > > > > : > > > > > > > > > > > > On Wed, Apr 01, 2020 at 06:29:03PM +0200, Carl Eugen Hoyos wrote: > > > > > > > Am Mi., 1. Apr. 2020 um 18:01 Uhr schrieb Matthieu Bouron > > > > > > > : > > > > > > > > > > > > > > > > Fixes probing of JPEG files containing MPF metadata appended at > > > > > > > > the end > > > > > > > > of the file. > > > > > > > > > > > > > > > > The MPF metadata chunk can contains multiple JPEG images > > > > > > > > (thumbnails) > > > > > > > > which makes the jpeg_probe fails (return 0) because it finds a > > > > > > > > SOI > > > > > > > > marker after EOI. > > > > > > > > --- > > > > > > > > > > > > > > > > This patch fixes probing of JPEG files containing MPF metadata > > > > > > > > [1] appended > > > > > > > > at the end of the file. > > > > > > > > > > > > > > > > Such files can be produced by GoPro camera (which produces JPEG > > > > > > > > files > > > > > > > > with MPF metadata). > > > > > > > > > > > > > > > > You can find a sample here: > > > > > > > > https://0x5c.me/gopro_jpg_mpf_probe_fail > > > > > > > > > > > > > > The sample works fine here with FFmpeg 4.2: Is there a regression? > > > > > > > > > > > > This sample does not work on FFmpeg 4.2 and master if you set a big > > > > > > enought formatprobesize (which matches the file size of the sample): > > > > > > > > > > Inlined is a patch that fixes detection but I wonder if this > > > > > shouldn't be > > > > > detected as mjpeg instead > > > > > > > > > > Carl Eugen > > > > > > > > > > diff --git a/libavformat/img2dec.c b/libavformat/img2dec.c > > > > > index 40f3e3d499..4e63b3494e 100644 > > > > > --- a/libavformat/img2dec.c > > > > > +++ b/libavformat/img2dec.c > > > > > @@ -737,20 +737,22 @@ static int j2k_probe(const AVProbeData *p) > > > > > static int jpeg_probe(const AVProbeData *p) > > > > > { > > > > > const uint8_t *b = p->buf; > > > > > -int i, state = SOI; > > > > > +int i, state = SOI, MPF = 0; > > > > > > > > > > if (AV_RB16(b) != 0xFFD8 || > > > > > AV_RB32(b) == 0xFFD8FFF7) > > > > > return 0; > > > > > > > > > > b += 2; > > > > > -for (i = 0; i < p->buf_size - 3; i++) { > > > > > +for (i = 0; i < p->buf_size - 8; i++) { > > > > > int c; > > > > > if (b[i] != 0xFF) > > > > > continue; > > > > > c = b[i + 1]; > > > > > switch (c) { > > > > > case SOI: > > > > > +if (state == EOI && MPF) > > > > > +return AVPROBE_SCORE_EXTENSION + 1; > > > > > > > > Your patch might work > > > > > > You could test it. > > > > > > > but the code is trying to find JPEG markers in the > > > > MPF metadata until we reach the first EOI in the MPF JPEG thumbnails, > > > > > > > I meant SOI sorry. > > > > > No, and I am quite sure that I tested this sufficiently. > > > > My point is, we are trying to parse way more data than necessary (the data > > we parse might not be jpeg at this point): the code looks for a marker and > > handles it, if the marker is unknown it repeats this operation for the > > next byte until it reaches the end of t
Re: [FFmpeg-devel] [PATCH] avformat/img2dec: return immediately in jpeg_probe() when EOI is found
On Wed, Apr 01, 2020 at 09:10:19PM +0200, Carl Eugen Hoyos wrote: > Am Mi., 1. Apr. 2020 um 21:07 Uhr schrieb Matthieu Bouron > : > > > > On Wed, Apr 01, 2020 at 07:59:46PM +0200, Carl Eugen Hoyos wrote: > > > Am Mi., 1. Apr. 2020 um 19:54 Uhr schrieb Matthieu Bouron > > > : > > > > > > > > On Wed, Apr 01, 2020 at 07:30:55PM +0200, Carl Eugen Hoyos wrote: > > > > > Am Mi., 1. Apr. 2020 um 19:15 Uhr schrieb Matthieu Bouron > > > > > : > > > > > > > > > > > > On Wed, Apr 01, 2020 at 06:55:42PM +0200, Carl Eugen Hoyos wrote: > > > > > > > Am Mi., 1. Apr. 2020 um 18:35 Uhr schrieb Matthieu Bouron > > > > > > > : > > > > > > > > > > > > > > > > On Wed, Apr 01, 2020 at 06:29:03PM +0200, Carl Eugen Hoyos > > > > > > > > wrote: > > > > > > > > > Am Mi., 1. Apr. 2020 um 18:01 Uhr schrieb Matthieu Bouron > > > > > > > > > : > > > > > > > > > > > > > > > > > > > > Fixes probing of JPEG files containing MPF metadata > > > > > > > > > > appended at the end > > > > > > > > > > of the file. > > > > > > > > > > > > > > > > > > > > The MPF metadata chunk can contains multiple JPEG images > > > > > > > > > > (thumbnails) > > > > > > > > > > which makes the jpeg_probe fails (return 0) because it > > > > > > > > > > finds a SOI > > > > > > > > > > marker after EOI. > > > > > > > > > > --- > > > > > > > > > > > > > > > > > > > > This patch fixes probing of JPEG files containing MPF > > > > > > > > > > metadata [1] appended > > > > > > > > > > at the end of the file. > > > > > > > > > > > > > > > > > > > > Such files can be produced by GoPro camera (which produces > > > > > > > > > > JPEG files > > > > > > > > > > with MPF metadata). > > > > > > > > > > > > > > > > > > > > You can find a sample here: > > > > > > > > > > https://0x5c.me/gopro_jpg_mpf_probe_fail > > > > > > > > > > > > > > > > > > The sample works fine here with FFmpeg 4.2: Is there a > > > > > > > > > regression? > > > > > > > > > > > > > > > > This sample does not work on FFmpeg 4.2 and master if you set a > > > > > > > > big > > > > > > > > enought formatprobesize (which matches the file size of the > > > > > > > > sample): > > > > > > > > > > > > > > Inlined is a patch that fixes detection but I wonder if this > > > > > > > shouldn't be > > > > > > > detected as mjpeg instead > > > > > > > > > > > > > > Carl Eugen > > > > > > > > > > > > > > diff --git a/libavformat/img2dec.c b/libavformat/img2dec.c > > > > > > > index 40f3e3d499..4e63b3494e 100644 > > > > > > > --- a/libavformat/img2dec.c > > > > > > > +++ b/libavformat/img2dec.c > > > > > > > @@ -737,20 +737,22 @@ static int j2k_probe(const AVProbeData *p) > > > > > > > static int jpeg_probe(const AVProbeData *p) > > > > > > > { > > > > > > > const uint8_t *b = p->buf; > > > > > > > -int i, state = SOI; > > > > > > > +int i, state = SOI, MPF = 0; > > > > > > > > > > > > > > if (AV_RB16(b) != 0xFFD8 || > > > > > > > AV_RB32(b) == 0xFFD8FFF7) > > > > > > > return 0; > > > > > > > > > > > > > > b += 2; > > > > > > > -for (i = 0; i < p->buf_size - 3; i++) { > > > > > > > +for (i = 0; i < p->buf_size - 8; i++) { > > > > > > > int c; > > > > > > > if (b[i] != 0xFF) > > > > > > > continue; >
[FFmpeg-devel] [PATCH] avcodec/mediacodec_wrapper: fix {input, output}_buffers global reference leak
Fixes ticket #8607. --- libavcodec/mediacodec_wrapper.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/libavcodec/mediacodec_wrapper.c b/libavcodec/mediacodec_wrapper.c index 5213cf640a7..79abc8b6aa9 100644 --- a/libavcodec/mediacodec_wrapper.c +++ b/libavcodec/mediacodec_wrapper.c @@ -1303,6 +1303,12 @@ int ff_AMediaCodec_delete(FFAMediaCodec* codec) ret = AVERROR_EXTERNAL; } +(*env)->DeleteGlobalRef(env, codec->input_buffers); +codec->input_buffers = NULL; + +(*env)->DeleteGlobalRef(env, codec->output_buffers); +codec->output_buffers = NULL; + (*env)->DeleteGlobalRef(env, codec->object); codec->object = NULL; -- 2.26.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] avcodec/mediacodec_wrapper: fix {input, output}_buffers global reference leak
On Thu, Apr 09, 2020 at 05:06:05PM +0200, Matthieu Bouron wrote: > Fixes ticket #8607. > --- > libavcodec/mediacodec_wrapper.c | 6 ++ > 1 file changed, 6 insertions(+) > > diff --git a/libavcodec/mediacodec_wrapper.c b/libavcodec/mediacodec_wrapper.c > index 5213cf640a7..79abc8b6aa9 100644 > --- a/libavcodec/mediacodec_wrapper.c > +++ b/libavcodec/mediacodec_wrapper.c > @@ -1303,6 +1303,12 @@ int ff_AMediaCodec_delete(FFAMediaCodec* codec) > ret = AVERROR_EXTERNAL; > } > > +(*env)->DeleteGlobalRef(env, codec->input_buffers); > +codec->input_buffers = NULL; > + > +(*env)->DeleteGlobalRef(env, codec->output_buffers); > +codec->output_buffers = NULL; > + > (*env)->DeleteGlobalRef(env, codec->object); > codec->object = NULL; > > -- > 2.26.0 > The user confirmed the patch fixes the issue. I will apply this patch tomorrow if there is no objection. -- Matthieu B. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] avcodec/mediacodec_wrapper: fix {input, output}_buffers global reference leak
On Tue, Apr 14, 2020 at 09:51:08AM +0200, Matthieu Bouron wrote: > On Thu, Apr 09, 2020 at 05:06:05PM +0200, Matthieu Bouron wrote: > > Fixes ticket #8607. > > --- > > libavcodec/mediacodec_wrapper.c | 6 ++ > > 1 file changed, 6 insertions(+) > > > > diff --git a/libavcodec/mediacodec_wrapper.c > > b/libavcodec/mediacodec_wrapper.c > > index 5213cf640a7..79abc8b6aa9 100644 > > --- a/libavcodec/mediacodec_wrapper.c > > +++ b/libavcodec/mediacodec_wrapper.c > > @@ -1303,6 +1303,12 @@ int ff_AMediaCodec_delete(FFAMediaCodec* codec) > > ret = AVERROR_EXTERNAL; > > } > > > > +(*env)->DeleteGlobalRef(env, codec->input_buffers); > > +codec->input_buffers = NULL; > > + > > +(*env)->DeleteGlobalRef(env, codec->output_buffers); > > +codec->output_buffers = NULL; > > + > > (*env)->DeleteGlobalRef(env, codec->object); > > codec->object = NULL; > > > > -- > > 2.26.0 > > > > The user confirmed the patch fixes the issue. I will apply this patch > tomorrow if there is no objection. Applied. -- Matthieu B. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] avcodec/mediacodecdec: Do not abort when H264/HEVC extradata extraction fails
On Mon, Jan 25, 2021 at 06:38:36PM +0100, sfan5 wrote: > Although rare, extradata can be present but empty and extraction will fail. > However Android also supports passing codec-specific data inline and > will likely play such a stream anyway. So there's no reason to abort > initialization before we know for sure. > --- > libavcodec/mediacodecdec.c | 8 > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/libavcodec/mediacodecdec.c b/libavcodec/mediacodecdec.c > index ac1725e466..67adefb530 100644 > --- a/libavcodec/mediacodecdec.c > +++ b/libavcodec/mediacodecdec.c > @@ -167,8 +167,8 @@ static int h264_set_extradata(AVCodecContext *avctx, > FFAMediaFormat *format) > ff_AMediaFormat_setBuffer(format, "csd-1", (void*)data, data_size); > av_freep(&data); > } else { > -av_log(avctx, AV_LOG_ERROR, "Could not extract PPS/SPS from > extradata"); > -ret = AVERROR_INVALIDDATA; > +av_log(avctx, AV_LOG_WARNING, "Could not extract PPS/SPS from > extradata\n"); > +ret = 0; > } > done: > @@ -254,8 +254,8 @@ static int hevc_set_extradata(AVCodecContext *avctx, > FFAMediaFormat *format) > av_freep(&data); > } else { > -av_log(avctx, AV_LOG_ERROR, "Could not extract VPS/PPS/SPS from > extradata"); > -ret = AVERROR_INVALIDDATA; > +av_log(avctx, AV_LOG_WARNING, "Could not extract VPS/PPS/SPS from > extradata\n"); > +ret = 0; > } > done: Hello, First of all, sorry for the late reply. The original intent with this restriction was to make sure that MediaCodec could error out early (at the configuration stage) so an implementation on top of libavcodec can decide to fall back to a software decoder (without trying to decode anything). I am fine with removing this restriction (if everyone is OK with that) for the following reasons: - there are chances that the h264/hevc software decoders have not been enabled (to avoid licensing issues) so the fallback mechanism is not available - as you said extradata are not always available (mpegts) and we want to give MediaCodec a chance to decode the stream So LGTM. If everyone is OK with that, I'll also submit a patch that removes the requirements on having the avctx->extradata set (I use such patch at work to allow playback of certain hls/mpegts streams). [...] -- Matthieu B. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 2/2] avcodec/mediacodec_wrapper: use MediaCodecInfo.isSoftwareOnly() when available
On Wed, Feb 17, 2021 at 04:51:09PM +0100, sfan5 wrote: > > From 22ebde779f61fb030633a881ef320264ea446b6b Mon Sep 17 00:00:00 2001 > From: sfan5 > Date: Thu, 11 Feb 2021 20:48:54 +0100 > Subject: [PATCH 2/2] avcodec/mediacodec_wrapper: use > MediaCodecInfo.isSoftwareOnly() when available > > Added in Android 10 it provides a reliable way of filtering out > software decoders, unlike existing string-based checks. > --- > libavcodec/mediacodec_wrapper.c | 13 + > 1 file changed, 13 insertions(+) > > diff --git a/libavcodec/mediacodec_wrapper.c b/libavcodec/mediacodec_wrapper.c > index f1945bcfc0..c829941d6b 100644 > --- a/libavcodec/mediacodec_wrapper.c > +++ b/libavcodec/mediacodec_wrapper.c > @@ -45,6 +45,7 @@ struct JNIAMediaCodecListFields { > jmethodID get_codec_capabilities_id; > jmethodID get_supported_types_id; > jmethodID is_encoder_id; > +jmethodID is_software_only_id; > > jclass codec_capabilities_class; > jfieldID color_formats_id; > @@ -81,6 +82,7 @@ static const struct FFJniField > jni_amediacodeclist_mapping[] = { > { "android/media/MediaCodecInfo", "getCapabilitiesForType", > "(Ljava/lang/String;)Landroid/media/MediaCodecInfo$CodecCapabilities;", > FF_JNI_METHOD, offsetof(struct JNIAMediaCodecListFields, > get_codec_capabilities_id), 1 }, > { "android/media/MediaCodecInfo", "getSupportedTypes", > "()[Ljava/lang/String;", FF_JNI_METHOD, offsetof(struct > JNIAMediaCodecListFields, get_supported_types_id), 1 }, > { "android/media/MediaCodecInfo", "isEncoder", "()Z", FF_JNI_METHOD, > offsetof(struct JNIAMediaCodecListFields, is_encoder_id), 1 }, > +{ "android/media/MediaCodecInfo", "isSoftwareOnly", "()Z", > FF_JNI_METHOD, offsetof(struct JNIAMediaCodecListFields, > is_software_only_id), 0 }, > > { "android/media/MediaCodecInfo$CodecCapabilities", NULL, NULL, > FF_JNI_CLASS, offsetof(struct JNIAMediaCodecListFields, > codec_capabilities_class), 1 }, > { "android/media/MediaCodecInfo$CodecCapabilities", "colorFormats", > "[I", FF_JNI_FIELD, offsetof(struct JNIAMediaCodecListFields, > color_formats_id), 1 }, > @@ -441,6 +443,17 @@ char *ff_AMediaCodecList_getCodecNameByType(const char > *mime, int profile, int e > goto done_with_info; > } > > +if (jfields.is_software_only_id) { > +int is_software_only = (*env)->CallBooleanMethod(env, info, > jfields.is_software_only_id); > +if (ff_jni_exception_check(env, 1, log_ctx) < 0) { > +goto done; > +} > + > +if (is_software_only) { > +goto done_with_info; > +} > +} > + > codec_name = (*env)->CallObjectMethod(env, info, > jfields.get_name_id); > if (ff_jni_exception_check(env, 1, log_ctx) < 0) { > goto done; > -- > 2.30.1 > LGTM, I'll push the patch in two days if there is no objection. Thanks, -- Matthieu B. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 1/2] avcodec/mediacodec_wrapper: clean up ff_AMediaCodecList_getCodecNameByType a bit
On Wed, Feb 17, 2021 at 04:50:00PM +0100, sfan5 wrote: > Hi, > > while looking into mediacodec for unrelated reasons I saw some room for > improvement. > > Therefore, here's a series with two small patches. > > From cadd2b2d4a5ffbb4dcc34faf2d3e139e1d4d608b Mon Sep 17 00:00:00 2001 > From: sfan5 > Date: Thu, 11 Feb 2021 19:23:26 +0100 > Subject: [PATCH 1/2] avcodec/mediacodec_wrapper: clean up > ff_AMediaCodecList_getCodecNameByType a bit > > We can skip software decoders before even looking at the mime types. > --- > libavcodec/mediacodec_wrapper.c | 113 > 1 file changed, 57 insertions(+), 56 deletions(-) > > diff --git a/libavcodec/mediacodec_wrapper.c b/libavcodec/mediacodec_wrapper.c > index 79abc8b6aa..f1945bcfc0 100644 > --- a/libavcodec/mediacodec_wrapper.c > +++ b/libavcodec/mediacodec_wrapper.c > @@ -441,6 +441,30 @@ char *ff_AMediaCodecList_getCodecNameByType(const char > *mime, int profile, int e > goto done_with_info; > } > > +codec_name = (*env)->CallObjectMethod(env, info, > jfields.get_name_id); > +if (ff_jni_exception_check(env, 1, log_ctx) < 0) { > +goto done; > +} > + > +name = ff_jni_jstring_to_utf_chars(env, codec_name, log_ctx); > +if (!name) { > +goto done; > +} > + > +if (codec_name) { > +(*env)->DeleteLocalRef(env, codec_name); > +codec_name = NULL; > +} > + > +/* Skip software decoders */ > +if ( > +strstr(name, "OMX.google") || > +strstr(name, "OMX.ffmpeg") || > +(strstr(name, "OMX.SEC") && strstr(name, ".sw.")) || > +!strcmp(name, "OMX.qcom.video.decoder.hevcswvdec")) { > +goto done_with_info; > +} > + > type_count = (*env)->GetArrayLength(env, types); > for (j = 0; j < type_count; j++) { > int k; > @@ -456,74 +480,51 @@ char *ff_AMediaCodecList_getCodecNameByType(const char > *mime, int profile, int e > goto done; > } > > -if (!av_strcasecmp(supported_type, mime)) { > -codec_name = (*env)->CallObjectMethod(env, info, > jfields.get_name_id); > -if (ff_jni_exception_check(env, 1, log_ctx) < 0) { > -goto done; > -} > +if (av_strcasecmp(supported_type, mime)) { > +goto done_with_type; > +} > > -name = ff_jni_jstring_to_utf_chars(env, codec_name, log_ctx); > -if (!name) { > -goto done; > -} > +capabilities = (*env)->CallObjectMethod(env, info, > jfields.get_codec_capabilities_id, type); > +if (ff_jni_exception_check(env, 1, log_ctx) < 0) { > +goto done; > +} > > -if (codec_name) { > -(*env)->DeleteLocalRef(env, codec_name); > -codec_name = NULL; > -} > +profile_levels = (*env)->GetObjectField(env, capabilities, > jfields.profile_levels_id); > +if (ff_jni_exception_check(env, 1, log_ctx) < 0) { > +goto done; > +} > > -/* Skip software decoders */ > -if ( > -strstr(name, "OMX.google") || > -strstr(name, "OMX.ffmpeg") || > -(strstr(name, "OMX.SEC") && strstr(name, ".sw.")) || > -!strcmp(name, "OMX.qcom.video.decoder.hevcswvdec")) { > -av_freep(&name); > -goto done_with_type; > +profile_count = (*env)->GetArrayLength(env, profile_levels); > +if (!profile_count) { > +found_codec = 1; > +} > +for (k = 0; k < profile_count; k++) { > +int supported_profile = 0; > + > +if (profile < 0) { > +found_codec = 1; > +break; > } > > -capabilities = (*env)->CallObjectMethod(env, info, > jfields.get_codec_capabilities_id, type); > +profile_level = (*env)->GetObjectArrayElement(env, > profile_levels, k); > if (ff_jni_exception_check(env, 1, log_ctx) < 0) { > goto done; > } > > -profile_levels = (*env)->GetObjectField(env, capabilities, > jfields.profile_levels_id); > +supported_profile = (*env)->GetIntField(env, profile_level, > jfields.profile_id); > if (ff_jni_exception_check(env, 1, log_ctx) < 0) { > goto done; > } > > -profile_count = (*env)->GetArrayLength(env, profile_levels); > -if (!profile_count) { > -found_codec = 1; > +found_codec = profile == supported_profi
Re: [FFmpeg-devel] [PATCH 1/2] avcodec/mediacodec_wrapper: clean up ff_AMediaCodecList_getCodecNameByType a bit
On Mon, Mar 08, 2021 at 10:11:58AM +0100, Matthieu Bouron wrote: > On Wed, Feb 17, 2021 at 04:50:00PM +0100, sfan5 wrote: > > Hi, > > > > while looking into mediacodec for unrelated reasons I saw some room for > > improvement. > > > > Therefore, here's a series with two small patches. > > > > > From cadd2b2d4a5ffbb4dcc34faf2d3e139e1d4d608b Mon Sep 17 00:00:00 2001 > > From: sfan5 > > Date: Thu, 11 Feb 2021 19:23:26 +0100 > > Subject: [PATCH 1/2] avcodec/mediacodec_wrapper: clean up > > ff_AMediaCodecList_getCodecNameByType a bit > > > > We can skip software decoders before even looking at the mime types. > > --- > > libavcodec/mediacodec_wrapper.c | 113 > > 1 file changed, 57 insertions(+), 56 deletions(-) > > > > diff --git a/libavcodec/mediacodec_wrapper.c > > b/libavcodec/mediacodec_wrapper.c > > index 79abc8b6aa..f1945bcfc0 100644 > > --- a/libavcodec/mediacodec_wrapper.c > > +++ b/libavcodec/mediacodec_wrapper.c > > @@ -441,6 +441,30 @@ char *ff_AMediaCodecList_getCodecNameByType(const char > > *mime, int profile, int e > > goto done_with_info; > > } > > > > +codec_name = (*env)->CallObjectMethod(env, info, > > jfields.get_name_id); > > +if (ff_jni_exception_check(env, 1, log_ctx) < 0) { > > +goto done; > > +} > > + > > +name = ff_jni_jstring_to_utf_chars(env, codec_name, log_ctx); > > +if (!name) { > > +goto done; > > +} > > + > > +if (codec_name) { > > +(*env)->DeleteLocalRef(env, codec_name); > > +codec_name = NULL; > > +} > > + > > +/* Skip software decoders */ > > +if ( > > +strstr(name, "OMX.google") || > > +strstr(name, "OMX.ffmpeg") || > > +(strstr(name, "OMX.SEC") && strstr(name, ".sw.")) || > > +!strcmp(name, "OMX.qcom.video.decoder.hevcswvdec")) { > > +goto done_with_info; > > +} > > + > > type_count = (*env)->GetArrayLength(env, types); > > for (j = 0; j < type_count; j++) { > > int k; > > @@ -456,74 +480,51 @@ char *ff_AMediaCodecList_getCodecNameByType(const > > char *mime, int profile, int e > > goto done; > > } > > > > -if (!av_strcasecmp(supported_type, mime)) { > > -codec_name = (*env)->CallObjectMethod(env, info, > > jfields.get_name_id); > > -if (ff_jni_exception_check(env, 1, log_ctx) < 0) { > > -goto done; > > -} > > +if (av_strcasecmp(supported_type, mime)) { > > +goto done_with_type; > > +} > > > > -name = ff_jni_jstring_to_utf_chars(env, codec_name, > > log_ctx); > > -if (!name) { > > -goto done; > > -} > > +capabilities = (*env)->CallObjectMethod(env, info, > > jfields.get_codec_capabilities_id, type); > > +if (ff_jni_exception_check(env, 1, log_ctx) < 0) { > > +goto done; > > +} > > > > -if (codec_name) { > > -(*env)->DeleteLocalRef(env, codec_name); > > -codec_name = NULL; > > -} > > +profile_levels = (*env)->GetObjectField(env, capabilities, > > jfields.profile_levels_id); > > +if (ff_jni_exception_check(env, 1, log_ctx) < 0) { > > +goto done; > > +} > > > > -/* Skip software decoders */ > > -if ( > > -strstr(name, "OMX.google") || > > -strstr(name, "OMX.ffmpeg") || > > -(strstr(name, "OMX.SEC") && strstr(name, ".sw.")) || > > -!strcmp(name, "OMX.qcom.video.decoder.hevcswvdec")) { > > -av_freep(&name); > > -goto done_with_type; > > +profile_count = (*env)->GetArrayLength(env, profile_levels); > > +if (!profile_count) { > > +found_codec = 1; > > +} > > +for (k = 0; k < profile_coun
Re: [FFmpeg-devel] [PATCH 2/2] avcodec/mediacodec_wrapper: use MediaCodecInfo.isSoftwareOnly() when available
On Mon, Mar 08, 2021 at 10:12:38AM +0100, Matthieu Bouron wrote: > On Wed, Feb 17, 2021 at 04:51:09PM +0100, sfan5 wrote: > > > > > From 22ebde779f61fb030633a881ef320264ea446b6b Mon Sep 17 00:00:00 2001 > > From: sfan5 > > Date: Thu, 11 Feb 2021 20:48:54 +0100 > > Subject: [PATCH 2/2] avcodec/mediacodec_wrapper: use > > MediaCodecInfo.isSoftwareOnly() when available > > > > Added in Android 10 it provides a reliable way of filtering out > > software decoders, unlike existing string-based checks. > > --- > > libavcodec/mediacodec_wrapper.c | 13 + > > 1 file changed, 13 insertions(+) > > > > diff --git a/libavcodec/mediacodec_wrapper.c > > b/libavcodec/mediacodec_wrapper.c > > index f1945bcfc0..c829941d6b 100644 > > --- a/libavcodec/mediacodec_wrapper.c > > +++ b/libavcodec/mediacodec_wrapper.c > > @@ -45,6 +45,7 @@ struct JNIAMediaCodecListFields { > > jmethodID get_codec_capabilities_id; > > jmethodID get_supported_types_id; > > jmethodID is_encoder_id; > > +jmethodID is_software_only_id; > > > > jclass codec_capabilities_class; > > jfieldID color_formats_id; > > @@ -81,6 +82,7 @@ static const struct FFJniField > > jni_amediacodeclist_mapping[] = { > > { "android/media/MediaCodecInfo", "getCapabilitiesForType", > > "(Ljava/lang/String;)Landroid/media/MediaCodecInfo$CodecCapabilities;", > > FF_JNI_METHOD, offsetof(struct JNIAMediaCodecListFields, > > get_codec_capabilities_id), 1 }, > > { "android/media/MediaCodecInfo", "getSupportedTypes", > > "()[Ljava/lang/String;", FF_JNI_METHOD, offsetof(struct > > JNIAMediaCodecListFields, get_supported_types_id), 1 }, > > { "android/media/MediaCodecInfo", "isEncoder", "()Z", > > FF_JNI_METHOD, offsetof(struct JNIAMediaCodecListFields, is_encoder_id), 1 > > }, > > +{ "android/media/MediaCodecInfo", "isSoftwareOnly", "()Z", > > FF_JNI_METHOD, offsetof(struct JNIAMediaCodecListFields, > > is_software_only_id), 0 }, > > > > { "android/media/MediaCodecInfo$CodecCapabilities", NULL, NULL, > > FF_JNI_CLASS, offsetof(struct JNIAMediaCodecListFields, > > codec_capabilities_class), 1 }, > > { "android/media/MediaCodecInfo$CodecCapabilities", > > "colorFormats", "[I", FF_JNI_FIELD, offsetof(struct > > JNIAMediaCodecListFields, color_formats_id), 1 }, > > @@ -441,6 +443,17 @@ char *ff_AMediaCodecList_getCodecNameByType(const char > > *mime, int profile, int e > > goto done_with_info; > > } > > > > +if (jfields.is_software_only_id) { > > +int is_software_only = (*env)->CallBooleanMethod(env, info, > > jfields.is_software_only_id); > > +if (ff_jni_exception_check(env, 1, log_ctx) < 0) { > > +goto done; > > +} > > + > > +if (is_software_only) { > > +goto done_with_info; > > +} > > +} > > + > > codec_name = (*env)->CallObjectMethod(env, info, > > jfields.get_name_id); > > if (ff_jni_exception_check(env, 1, log_ctx) < 0) { > > goto done; > > -- > > 2.30.1 > > > > LGTM, I'll push the patch in two days if there is no objection. > Thanks, Applied as a7425f712aeed6e18204a68810529895fdbdb1be. Thanks. -- Matthieu B. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] avcodec/mediacodec_common: use MediaFormat to probe frame color characteristics
On Tue, Mar 31, 2020 at 10:03:08AM +0200, Matthieu Bouron wrote: > --- > libavcodec/mediacodecdec_common.c | 100 ++ > 1 file changed, 100 insertions(+) > > diff --git a/libavcodec/mediacodecdec_common.c > b/libavcodec/mediacodecdec_common.c > index f0752fa6261..404ed282275 100644 > --- a/libavcodec/mediacodecdec_common.c > +++ b/libavcodec/mediacodecdec_common.c > @@ -85,6 +85,85 @@ > #define OUTPUT_DEQUEUE_TIMEOUT_US 8000 > #define OUTPUT_DEQUEUE_BLOCK_TIMEOUT_US 100 > > +enum { > +COLOR_RANGE_FULL= 0x1, > +COLOR_RANGE_LIMITED = 0x2, > +}; > + > +static enum AVColorRange mcdec_get_color_range(int color_range) > +{ > +switch (color_range) { > +case COLOR_RANGE_FULL: > +return AVCOL_RANGE_JPEG; > +case COLOR_RANGE_LIMITED: > +return AVCOL_RANGE_MPEG; > +default: > +return AVCOL_RANGE_UNSPECIFIED; > +} > +} > + > +enum { > +COLOR_STANDARD_BT709 = 0x1, > +COLOR_STANDARD_BT601_PAL = 0x2, > +COLOR_STANDARD_BT601_NTSC = 0x4, > +COLOR_STANDARD_BT2020 = 0x6, > +}; > + > +static enum AVColorSpace mcdec_get_color_space(int color_standard) > +{ > +switch (color_standard) { > +case COLOR_STANDARD_BT709: > +return AVCOL_SPC_BT709; > +case COLOR_STANDARD_BT601_PAL: > +return AVCOL_SPC_BT470BG; > +case COLOR_STANDARD_BT601_NTSC: > +return AVCOL_SPC_SMPTE170M; > +case COLOR_STANDARD_BT2020: > +return AVCOL_SPC_BT2020_NCL; > +default: > +return AVCOL_SPC_UNSPECIFIED; > +} > +} > + > +static enum AVColorPrimaries mcdec_get_color_pri(int color_standard) > +{ > +switch (color_standard) { > +case COLOR_STANDARD_BT709: > +return AVCOL_PRI_BT709; > +case COLOR_STANDARD_BT601_PAL: > +return AVCOL_PRI_BT470BG; > +case COLOR_STANDARD_BT601_NTSC: > +return AVCOL_PRI_SMPTE170M; > +case COLOR_STANDARD_BT2020: > +return AVCOL_PRI_BT2020; > +default: > +return AVCOL_PRI_UNSPECIFIED; > +} > +} > + > +enum { > +COLOR_TRANSFER_LINEAR= 0x1, > +COLOR_TRANSFER_SDR_VIDEO = 0x3, > +COLOR_TRANSFER_ST2084= 0x6, > +COLOR_TRANSFER_HLG = 0x7, > +}; > + > +static enum AVColorTransferCharacteristic mcdec_get_color_trc(int > color_transfer) > +{ > +switch (color_transfer) { > +case COLOR_TRANSFER_LINEAR: > +return AVCOL_TRC_LINEAR; > +case COLOR_TRANSFER_SDR_VIDEO: > +return AVCOL_TRC_SMPTE170M; > +case COLOR_TRANSFER_ST2084: > +return AVCOL_TRC_SMPTEST2084; > +case COLOR_TRANSFER_HLG: > +return AVCOL_TRC_ARIB_STD_B67; > +default: > +return AVCOL_TRC_UNSPECIFIED; > +} > +} > + > enum { > COLOR_FormatYUV420Planar = 0x13, > COLOR_FormatYUV420SemiPlanar = 0x15, > @@ -220,6 +299,10 @@ FF_DISABLE_DEPRECATION_WARNINGS > FF_ENABLE_DEPRECATION_WARNINGS > #endif > frame->pkt_dts = AV_NOPTS_VALUE; > +frame->color_range = avctx->color_range; > +frame->color_primaries = avctx->color_primaries; > +frame->color_trc = avctx->color_trc; > +frame->colorspace = avctx->colorspace; > > buffer = av_mallocz(sizeof(AVMediaCodecBuffer)); > if (!buffer) { > @@ -368,6 +451,9 @@ static int mediacodec_dec_parse_format(AVCodecContext > *avctx, MediaCodecDecConte > int ret = 0; > int width = 0; > int height = 0; > +int color_range = 0; > +int color_standard = 0; > +int color_transfer = 0; > char *format = NULL; > > if (!s->format) { > @@ -426,6 +512,20 @@ static int mediacodec_dec_parse_format(AVCodecContext > *avctx, MediaCodecDecConte > ff_set_sar(avctx, sar); > } > > +AMEDIAFORMAT_GET_INT32(color_range, "color-range", 0); > +if (color_range) > +avctx->color_range = mcdec_get_color_range(color_range); > + > +AMEDIAFORMAT_GET_INT32(color_standard, "color-standard", 0); > +if (color_standard) { > +avctx->colorspace = mcdec_get_color_space(color_standard); > +avctx->color_primaries = mcdec_get_color_pri(color_standard); > +} > + > +AMEDIAFORMAT_GET_INT32(color_transfer, "color-transfer", 0); > +if (color_transfer) > +avctx->color_trc = mcdec_get_color_trc(color_transfer); > + > av_log(avctx, AV_LOG_INFO, > "Output crop parameters top=%d bottom=%d left=%d right=%d, " > "resulting dimensions width=%d height=%d\n", > -- > 2.26.0 > Ping. -- Matthieu B. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] avcodec/mediacodec_common: use MediaFormat to probe frame color characteristics
On Sat, May 09, 2020 at 09:45:05AM +0200, Matthieu Bouron wrote: > On Tue, Mar 31, 2020 at 10:03:08AM +0200, Matthieu Bouron wrote: > > --- > > libavcodec/mediacodecdec_common.c | 100 ++ > > 1 file changed, 100 insertions(+) > > > > diff --git a/libavcodec/mediacodecdec_common.c > > b/libavcodec/mediacodecdec_common.c > > index f0752fa6261..404ed282275 100644 > > --- a/libavcodec/mediacodecdec_common.c > > +++ b/libavcodec/mediacodecdec_common.c > > @@ -85,6 +85,85 @@ > > #define OUTPUT_DEQUEUE_TIMEOUT_US 8000 > > #define OUTPUT_DEQUEUE_BLOCK_TIMEOUT_US 100 > > > > +enum { > > +COLOR_RANGE_FULL= 0x1, > > +COLOR_RANGE_LIMITED = 0x2, > > +}; > > + > > +static enum AVColorRange mcdec_get_color_range(int color_range) > > +{ > > +switch (color_range) { > > +case COLOR_RANGE_FULL: > > +return AVCOL_RANGE_JPEG; > > +case COLOR_RANGE_LIMITED: > > +return AVCOL_RANGE_MPEG; > > +default: > > +return AVCOL_RANGE_UNSPECIFIED; > > +} > > +} > > + > > +enum { > > +COLOR_STANDARD_BT709 = 0x1, > > +COLOR_STANDARD_BT601_PAL = 0x2, > > +COLOR_STANDARD_BT601_NTSC = 0x4, > > +COLOR_STANDARD_BT2020 = 0x6, > > +}; > > + > > +static enum AVColorSpace mcdec_get_color_space(int color_standard) > > +{ > > +switch (color_standard) { > > +case COLOR_STANDARD_BT709: > > +return AVCOL_SPC_BT709; > > +case COLOR_STANDARD_BT601_PAL: > > +return AVCOL_SPC_BT470BG; > > +case COLOR_STANDARD_BT601_NTSC: > > +return AVCOL_SPC_SMPTE170M; > > +case COLOR_STANDARD_BT2020: > > +return AVCOL_SPC_BT2020_NCL; > > +default: > > +return AVCOL_SPC_UNSPECIFIED; > > +} > > +} > > + > > +static enum AVColorPrimaries mcdec_get_color_pri(int color_standard) > > +{ > > +switch (color_standard) { > > +case COLOR_STANDARD_BT709: > > +return AVCOL_PRI_BT709; > > +case COLOR_STANDARD_BT601_PAL: > > +return AVCOL_PRI_BT470BG; > > +case COLOR_STANDARD_BT601_NTSC: > > +return AVCOL_PRI_SMPTE170M; > > +case COLOR_STANDARD_BT2020: > > +return AVCOL_PRI_BT2020; > > +default: > > +return AVCOL_PRI_UNSPECIFIED; > > +} > > +} > > + > > +enum { > > +COLOR_TRANSFER_LINEAR= 0x1, > > +COLOR_TRANSFER_SDR_VIDEO = 0x3, > > +COLOR_TRANSFER_ST2084= 0x6, > > +COLOR_TRANSFER_HLG = 0x7, > > +}; > > + > > +static enum AVColorTransferCharacteristic mcdec_get_color_trc(int > > color_transfer) > > +{ > > +switch (color_transfer) { > > +case COLOR_TRANSFER_LINEAR: > > +return AVCOL_TRC_LINEAR; > > +case COLOR_TRANSFER_SDR_VIDEO: > > +return AVCOL_TRC_SMPTE170M; > > +case COLOR_TRANSFER_ST2084: > > +return AVCOL_TRC_SMPTEST2084; > > +case COLOR_TRANSFER_HLG: > > +return AVCOL_TRC_ARIB_STD_B67; > > +default: > > +return AVCOL_TRC_UNSPECIFIED; > > +} > > +} > > + > > enum { > > COLOR_FormatYUV420Planar = 0x13, > > COLOR_FormatYUV420SemiPlanar = 0x15, > > @@ -220,6 +299,10 @@ FF_DISABLE_DEPRECATION_WARNINGS > > FF_ENABLE_DEPRECATION_WARNINGS > > #endif > > frame->pkt_dts = AV_NOPTS_VALUE; > > +frame->color_range = avctx->color_range; > > +frame->color_primaries = avctx->color_primaries; > > +frame->color_trc = avctx->color_trc; > > +frame->colorspace = avctx->colorspace; > > > > buffer = av_mallocz(sizeof(AVMediaCodecBuffer)); > > if (!buffer) { > > @@ -368,6 +451,9 @@ static int mediacodec_dec_parse_format(AVCodecContext > > *avctx, MediaCodecDecConte > > int ret = 0; > > int width = 0; > > int height = 0; > > +int color_range = 0; > > +int color_standard = 0; > > +int color_transfer = 0; > > char *format = NULL; > > > > if (!s->format) { > > @@ -426,6 +512,20 @@ static int mediacodec_dec_parse_format(AVCodecContext > > *avctx, MediaCodecDecConte > > ff_set_sar(avctx, sar); > > } > > > > +AMEDIAFORMAT_GET_INT32(color_range, "color-range", 0); > > +if (color_range) >
Re: [FFmpeg-devel] [PATCH] avcodec/mediacodec_common: use MediaFormat to probe frame color characteristics
On Wed, May 20, 2020 at 10:07:03AM +0200, Matthieu Bouron wrote: > On Sat, May 09, 2020 at 09:45:05AM +0200, Matthieu Bouron wrote: > > On Tue, Mar 31, 2020 at 10:03:08AM +0200, Matthieu Bouron wrote: > > > --- > > > libavcodec/mediacodecdec_common.c | 100 ++ > > > 1 file changed, 100 insertions(+) > > > > > > diff --git a/libavcodec/mediacodecdec_common.c > > > b/libavcodec/mediacodecdec_common.c > > > index f0752fa6261..404ed282275 100644 > > > --- a/libavcodec/mediacodecdec_common.c > > > +++ b/libavcodec/mediacodecdec_common.c > > > @@ -85,6 +85,85 @@ > > > #define OUTPUT_DEQUEUE_TIMEOUT_US 8000 > > > #define OUTPUT_DEQUEUE_BLOCK_TIMEOUT_US 100 > > > > > > +enum { > > > +COLOR_RANGE_FULL= 0x1, > > > +COLOR_RANGE_LIMITED = 0x2, > > > +}; > > > + > > > +static enum AVColorRange mcdec_get_color_range(int color_range) > > > +{ > > > +switch (color_range) { > > > +case COLOR_RANGE_FULL: > > > +return AVCOL_RANGE_JPEG; > > > +case COLOR_RANGE_LIMITED: > > > +return AVCOL_RANGE_MPEG; > > > +default: > > > +return AVCOL_RANGE_UNSPECIFIED; > > > +} > > > +} > > > + > > > +enum { > > > +COLOR_STANDARD_BT709 = 0x1, > > > +COLOR_STANDARD_BT601_PAL = 0x2, > > > +COLOR_STANDARD_BT601_NTSC = 0x4, > > > +COLOR_STANDARD_BT2020 = 0x6, > > > +}; > > > + > > > +static enum AVColorSpace mcdec_get_color_space(int color_standard) > > > +{ > > > +switch (color_standard) { > > > +case COLOR_STANDARD_BT709: > > > +return AVCOL_SPC_BT709; > > > +case COLOR_STANDARD_BT601_PAL: > > > +return AVCOL_SPC_BT470BG; > > > +case COLOR_STANDARD_BT601_NTSC: > > > +return AVCOL_SPC_SMPTE170M; > > > +case COLOR_STANDARD_BT2020: > > > +return AVCOL_SPC_BT2020_NCL; > > > +default: > > > +return AVCOL_SPC_UNSPECIFIED; > > > +} > > > +} > > > + > > > +static enum AVColorPrimaries mcdec_get_color_pri(int color_standard) > > > +{ > > > +switch (color_standard) { > > > +case COLOR_STANDARD_BT709: > > > +return AVCOL_PRI_BT709; > > > +case COLOR_STANDARD_BT601_PAL: > > > +return AVCOL_PRI_BT470BG; > > > +case COLOR_STANDARD_BT601_NTSC: > > > +return AVCOL_PRI_SMPTE170M; > > > +case COLOR_STANDARD_BT2020: > > > +return AVCOL_PRI_BT2020; > > > +default: > > > +return AVCOL_PRI_UNSPECIFIED; > > > +} > > > +} > > > + > > > +enum { > > > +COLOR_TRANSFER_LINEAR= 0x1, > > > +COLOR_TRANSFER_SDR_VIDEO = 0x3, > > > +COLOR_TRANSFER_ST2084= 0x6, > > > +COLOR_TRANSFER_HLG = 0x7, > > > +}; > > > + > > > +static enum AVColorTransferCharacteristic mcdec_get_color_trc(int > > > color_transfer) > > > +{ > > > +switch (color_transfer) { > > > +case COLOR_TRANSFER_LINEAR: > > > +return AVCOL_TRC_LINEAR; > > > +case COLOR_TRANSFER_SDR_VIDEO: > > > +return AVCOL_TRC_SMPTE170M; > > > +case COLOR_TRANSFER_ST2084: > > > +return AVCOL_TRC_SMPTEST2084; > > > +case COLOR_TRANSFER_HLG: > > > +return AVCOL_TRC_ARIB_STD_B67; > > > +default: > > > +return AVCOL_TRC_UNSPECIFIED; > > > +} > > > +} > > > + > > > enum { > > > COLOR_FormatYUV420Planar = 0x13, > > > COLOR_FormatYUV420SemiPlanar = 0x15, > > > @@ -220,6 +299,10 @@ FF_DISABLE_DEPRECATION_WARNINGS > > > FF_ENABLE_DEPRECATION_WARNINGS > > > #endif > > > frame->pkt_dts = AV_NOPTS_VALUE; > > > +frame->color_range = avctx->color_range; > > > +frame->color_primaries = avctx->color_primaries; > > > +frame->color_trc = avctx->color_trc; > > > +frame->colorspace = avctx->colorspace; > > > > > > buffer = av_mallocz(sizeof(AVMediaCodecBuffer)); > > > if (!buffer) { > > > @@ -368,6 +451,9 @@ static int mediacodec_dec_parse_format(AVCodecContext > > > *avctx, MediaCodec
Re: [FFmpeg-devel] [PATCH] add support to Android ndk MediaCodec for encoding/decoding
On Sat, Jun 27, 2020 at 09:54:58PM +0300, Martin Storsjö wrote: > On Sat, 27 Jun 2020, Olivier Ayache wrote: > > > Hi everyone this is the first time I post on this mailing list. I am > > working since several years on a fork of Xuggler for manipulating ffmpeg > > API with Java/Kotlin. > > This work leads me to develop encoder and decoder based on Android NDK > > MediaCodec. > > > > This work can be found on my Github repository > > > > https://github.com/olivierayache/xuggle-xuggler > > > > > > I know that FFmpeg already integrate MediaCodec for decoding via Jni > > wrappers since version 3.1. I began this work on FFmpeg 2.8.x and I choose > > the NDK in order to achieve optimum performance. > > If you mean you used the NDK MediaCodec API, I'd suggest you use the same > JNI wrappers as ffmpeg has already, for consistency. The overhead of a few > JNI calls per encoded frame is generally negligible. If it, at a later time, > is decided to drop support for older versions at some point, it should be > straightforward to convert it to use the NDK MediaCodec API instead. I agree with this, please use the MediaCodec wrapper for now. The MediaCodec wrapper mimic the API of the NDK so if we decide to switch to the NDK, it should be quite easy. Moreover, this work (switch to the NDK) has already been done by Aman Gupta in one of his branches. -- Matthieu B. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 4/6] avcodec/mediacodecdec_common: improve trace logging for end-of-stream
On Thu, Sep 05, 2019 at 11:27:33AM -0700, Aman Gupta wrote: > From: Aman Gupta > > Signed-off-by: Aman Gupta > --- > libavcodec/mediacodecdec_common.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/libavcodec/mediacodecdec_common.c > b/libavcodec/mediacodecdec_common.c > index eae9c28d42..c538a00775 100644 > --- a/libavcodec/mediacodecdec_common.c > +++ b/libavcodec/mediacodecdec_common.c > @@ -632,7 +632,7 @@ int ff_mediacodec_dec_send(AVCodecContext *avctx, > MediaCodecDecContext *s, > } > > av_log(avctx, AV_LOG_TRACE, > - "Queued input buffer %zd size=%zd ts=%"PRIi64"\n", index, > size, pts); > + "Queued empty EOS input buffer %zd with flags=%d\n", > index, flags); > > s->draining = 1; > return 0; > -- > 2.20.1 > LGTM. -- Matthieu B. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 2/6] avcodec/mediacodecdec: warn when input buffers are not configured with proper size
On Thu, Sep 05, 2019 at 11:27:31AM -0700, Aman Gupta wrote: > From: Aman Gupta > > In rare circumstances, if the codec is not configured with the > proper parameters the input buffers can be allocated with a size > that's too small to hold an individual packet. Since MediaCodec > expects exactly one incoming buffer with a given PTS, it is not > valid to split data for a given PTS across two input buffers. > > See > https://developer.android.com/reference/android/media/MediaCodec#data-processing: > > > Do not submit multiple input buffers with the same timestamp > > Signed-off-by: Aman Gupta > --- > libavcodec/mediacodecdec.c | 7 ++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > diff --git a/libavcodec/mediacodecdec.c b/libavcodec/mediacodecdec.c > index e353e34bd5..f5771bffb1 100644 > --- a/libavcodec/mediacodecdec.c > +++ b/libavcodec/mediacodecdec.c > @@ -440,8 +440,13 @@ static int mediacodec_receive_frame(AVCodecContext > *avctx, AVFrame *frame) > if (ret >= 0) { > s->buffered_pkt.size -= ret; > s->buffered_pkt.data += ret; > -if (s->buffered_pkt.size <= 0) > +if (s->buffered_pkt.size <= 0) { > av_packet_unref(&s->buffered_pkt); > +} else { > +av_log(avctx, AV_LOG_WARNING, > + "could not send entire packet in single input > buffer (%d < %d)\n", > + ret, s->buffered_pkt.size+ret); > +} > } else if (ret < 0 && ret != AVERROR(EAGAIN)) { > return ret; > } > -- > 2.20.1 > The patch itself looks good to me. We should probably simplifies the mediacodec_dec_send() function to not try to split the input pkt into multiple MediaCodec buffers. I will send a patch to do that. -- Matthieu B. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 6/6] avcodec/mediacodecdec_common: propagate EOF immediately when signaled by decoder
On Thu, Sep 05, 2019 at 11:27:35AM -0700, Aman Gupta wrote: > From: Aman Gupta > > Signed-off-by: Aman Gupta > --- > libavcodec/mediacodecdec_common.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/libavcodec/mediacodecdec_common.c > b/libavcodec/mediacodecdec_common.c > index b9465244a3..ab8525fb14 100644 > --- a/libavcodec/mediacodecdec_common.c > +++ b/libavcodec/mediacodecdec_common.c > @@ -693,6 +693,7 @@ int ff_mediacodec_dec_receive(AVCodecContext *avctx, > MediaCodecDecContext *s, > > if (info.flags & ff_AMediaCodec_getBufferFlagEndOfStream(codec)) { > s->eos = 1; > +return AVERROR_EOF; > } I am not sure it will work in all cases / all devices as we probably can end up with a proper output buffer with the OES flag. Returning AVERROR_EOF here will discard such buffer (frame). > > if (info.size) { > -- > 2.20.1 > -- Matthieu B. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 3/6] avcodec/mediacodecdec_common: warn when PTS is missing
On Thu, Sep 05, 2019 at 11:27:32AM -0700, Aman Gupta wrote: > From: Aman Gupta > > MediaCodec decoders require PTS for proper operation. > > Signed-off-by: Aman Gupta > --- > libavcodec/mediacodecdec_common.c | 6 +- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/libavcodec/mediacodecdec_common.c > b/libavcodec/mediacodecdec_common.c > index 1656cd6664..eae9c28d42 100644 > --- a/libavcodec/mediacodecdec_common.c > +++ b/libavcodec/mediacodecdec_common.c > @@ -612,7 +612,11 @@ int ff_mediacodec_dec_send(AVCodecContext *avctx, > MediaCodecDecContext *s, > } > > pts = pkt->pts; > -if (pts != AV_NOPTS_VALUE && avctx->pkt_timebase.num && > avctx->pkt_timebase.den) { > +if (pts == AV_NOPTS_VALUE) { > +av_log(avctx, AV_LOG_WARNING, "Packet is missing PTS!\n"); Maybe reword to "Input packet is missing PTS" ? (without the !) > +pts = 0; > +} > +if (pts && avctx->pkt_timebase.num && avctx->pkt_timebase.den) { > pts = av_rescale_q(pts, avctx->pkt_timebase, AV_TIME_BASE_Q); > } > > -- > 2.20.1 > Except from my comment, LGTM. -- Matthieu B. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 1/6] avcodec/mediacodec_surface: guard against NULL surface
On Thu, Sep 05, 2019 at 11:27:30AM -0700, Aman Gupta wrote: > From: Aman Gupta > > Signed-off-by: Aman Gupta > --- > libavcodec/mediacodec_surface.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/libavcodec/mediacodec_surface.c b/libavcodec/mediacodec_surface.c > index aada1ecebe..efcc4dc63c 100644 > --- a/libavcodec/mediacodec_surface.c > +++ b/libavcodec/mediacodec_surface.c > @@ -28,9 +28,11 @@ > void *ff_mediacodec_surface_ref(void *surface, void *log_ctx) > { > JNIEnv *env = NULL; > - > void *reference = NULL; > > +if (!surface) > +return NULL; > + > env = ff_jni_get_env(log_ctx); > if (!env) { > return NULL; > -- > 2.20.1 > This should not be needed unless it fixes a crash. NewGlobalRef/DeleteGlobalRef (as well as NewLocalRef/DeleteLocalRef) handles NULL pointers. The JNI MediaCodec wrapper is missleading about this as it does this kind of unneeded checks everywhere (I did not known at the time that the ref functions handle NULL). I have a local branch cleaning this up. I will submit it to the ML in the upcoming days. -- Matthieu B. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 1/2] avcodec/mediacodecdec_common: log codec name during configure/start failures
On Thu, Sep 05, 2019 at 04:07:19PM -0700, Aman Gupta wrote: > From: Aman Gupta > > Signed-off-by: Aman Gupta > --- > libavcodec/mediacodecdec_common.c | 8 > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/libavcodec/mediacodecdec_common.c > b/libavcodec/mediacodecdec_common.c > index ab8525fb14..d200372dd4 100644 > --- a/libavcodec/mediacodecdec_common.c > +++ b/libavcodec/mediacodecdec_common.c > @@ -525,8 +525,8 @@ int ff_mediacodec_dec_init(AVCodecContext *avctx, > MediaCodecDecContext *s, > if (status < 0) { > char *desc = ff_AMediaFormat_toString(format); > av_log(avctx, AV_LOG_ERROR, > -"Failed to configure codec (status = %d) with format %s\n", > -status, desc); > +"Failed to configure codec %s (status = %d) with format %s\n", > +s->codec_name, status, desc); > av_freep(&desc); > > ret = AVERROR_EXTERNAL; > @@ -537,8 +537,8 @@ int ff_mediacodec_dec_init(AVCodecContext *avctx, > MediaCodecDecContext *s, > if (status < 0) { > char *desc = ff_AMediaFormat_toString(format); > av_log(avctx, AV_LOG_ERROR, > -"Failed to start codec (status = %d) with format %s\n", > -status, desc); > +"Failed to start codec %s (status = %d) with format %s\n", > +s->codec_name, status, desc); > av_freep(&desc); > ret = AVERROR_EXTERNAL; > goto fail; > -- > 2.20.1 > LGTM. -- Matthieu B. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 2/2] avcodec/mediacodec_surface: define and use FFANativeWindow to mimic NDK interface
On Thu, Sep 05, 2019 at 04:07:20PM -0700, Aman Gupta wrote: > From: Aman Gupta > > This will make it easy to switch to ANativeWindow_fromSurface > and ANativeWindow_release in the future. > > Signed-off-by: Aman Gupta > --- > libavcodec/mediacodec_surface.c | 11 --- > libavcodec/mediacodec_surface.h | 7 +-- > 2 files changed, 9 insertions(+), 9 deletions(-) > > diff --git a/libavcodec/mediacodec_surface.c b/libavcodec/mediacodec_surface.c > index efcc4dc63c..a292386e34 100644 > --- a/libavcodec/mediacodec_surface.c > +++ b/libavcodec/mediacodec_surface.c > @@ -25,10 +25,9 @@ > #include "ffjni.h" > #include "mediacodec_surface.h" > > -void *ff_mediacodec_surface_ref(void *surface, void *log_ctx) > +FFANativeWindow *ff_mediacodec_surface_ref(void *surface, void *log_ctx) > { > JNIEnv *env = NULL; > -void *reference = NULL; > > if (!surface) > return NULL; > @@ -38,12 +37,10 @@ void *ff_mediacodec_surface_ref(void *surface, void > *log_ctx) > return NULL; > } > > -reference = (*env)->NewGlobalRef(env, surface); > - > -return reference; > +return (*env)->NewGlobalRef(env, surface); This should be done in a separate commit. [...] -- Matthieu B. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 1/2] avcodec/mediacodecdec_common: simplify ff_mediacodec_dec_send()
--- libavcodec/mediacodecdec_common.c | 6 +- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/libavcodec/mediacodecdec_common.c b/libavcodec/mediacodecdec_common.c index 1656cd6664..6c0a1212c1 100644 --- a/libavcodec/mediacodecdec_common.c +++ b/libavcodec/mediacodecdec_common.c @@ -567,7 +567,7 @@ int ff_mediacodec_dec_send(AVCodecContext *avctx, MediaCodecDecContext *s, AVPacket *pkt, bool wait) { int offset = 0; -int need_draining = 0; +int need_draining = pkt->size == 0; uint8_t *data; ssize_t index = s->current_input_buffer; size_t size; @@ -582,10 +582,6 @@ int ff_mediacodec_dec_send(AVCodecContext *avctx, MediaCodecDecContext *s, return AVERROR_EXTERNAL; } -if (pkt->size == 0) { -need_draining = 1; -} - if (s->draining && s->eos) { return AVERROR_EOF; } -- 2.23.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 2/2] avcodec/mediacodecdec_common: do not split input packets into multiple buffers in ff_mediacodec_dec_send()
MediaCodec expects exactly one incoming buffer with a given PTS, it is not valid to split data for a given PTS across multiple input buffers. See https://developer.android.com/reference/android/media/MediaCodec#data-processing > Do not submit multiple input buffers with the same timestamp --- libavcodec/mediacodecdec_common.c | 18 -- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/libavcodec/mediacodecdec_common.c b/libavcodec/mediacodecdec_common.c index 6c0a1212c1..74fa29cc7d 100644 --- a/libavcodec/mediacodecdec_common.c +++ b/libavcodec/mediacodecdec_common.c @@ -566,7 +566,6 @@ fail: int ff_mediacodec_dec_send(AVCodecContext *avctx, MediaCodecDecContext *s, AVPacket *pkt, bool wait) { -int offset = 0; int need_draining = pkt->size == 0; uint8_t *data; ssize_t index = s->current_input_buffer; @@ -586,12 +585,15 @@ int ff_mediacodec_dec_send(AVCodecContext *avctx, MediaCodecDecContext *s, return AVERROR_EOF; } -while (offset < pkt->size || (need_draining && !s->draining)) { +if (s->draining) { +return 0; +} + if (index < 0) { index = ff_AMediaCodec_dequeueInputBuffer(codec, input_dequeue_timeout_us); if (ff_AMediaCodec_infoTryAgainLater(codec, index)) { av_log(avctx, AV_LOG_TRACE, "No input buffer available, try again later\n"); -break; +return AVERROR(EAGAIN); } if (index < 0) { @@ -630,9 +632,8 @@ int ff_mediacodec_dec_send(AVCodecContext *avctx, MediaCodecDecContext *s, return 0; } -size = FFMIN(pkt->size - offset, size); -memcpy(data, pkt->data + offset, size); -offset += size; +size = FFMIN(pkt->size, size); +memcpy(data, pkt->data, size); status = ff_AMediaCodec_queueInputBuffer(codec, index, 0, size, pts, 0); if (status < 0) { @@ -642,11 +643,8 @@ int ff_mediacodec_dec_send(AVCodecContext *avctx, MediaCodecDecContext *s, av_log(avctx, AV_LOG_TRACE, "Queued input buffer %zd size=%zd ts=%"PRIi64"\n", index, size, pts); -} -if (offset == 0) -return AVERROR(EAGAIN); -return offset; +return size; } int ff_mediacodec_dec_receive(AVCodecContext *avctx, MediaCodecDecContext *s, -- 2.23.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 1/2] avformat/mov: parse sdtp atom and set the pkt disposable flag accordingly
Allows the creation of the sdtp atom while remuxing MP4 to MP4. This atom is required by Apple devices (iPhone, Apple TV) in order to accept 2160p medias. --- libavformat/isom.h | 2 ++ libavformat/mov.c | 41 + 2 files changed, 43 insertions(+) diff --git a/libavformat/isom.h b/libavformat/isom.h index 69452cae8e..4943b80ccf 100644 --- a/libavformat/isom.h +++ b/libavformat/isom.h @@ -163,6 +163,8 @@ typedef struct MOVStreamContext { int64_t *chunk_offsets; unsigned int stts_count; MOVStts *stts_data; +unsigned int sdtp_count; +uint8_t *sdtp_data; unsigned int ctts_count; unsigned int ctts_allocated_size; MOVStts *ctts_data; diff --git a/libavformat/mov.c b/libavformat/mov.c index 8e916a28c6..7dfa07b45e 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -2959,6 +2959,40 @@ static int mov_read_stts(MOVContext *c, AVIOContext *pb, MOVAtom atom) return 0; } +static int mov_read_sdtp(MOVContext *c, AVIOContext *pb, MOVAtom atom) +{ +AVStream *st; +MOVStreamContext *sc; +int64_t i, entries; + +if (c->fc->nb_streams < 1) +return 0; +st = c->fc->streams[c->fc->nb_streams-1]; +sc = st->priv_data; + +avio_r8(pb); /* version */ +avio_rb24(pb); /* flags */ +entries = atom.size - 4; + +av_log(c->fc, AV_LOG_TRACE, "track[%u].sdtp.entries = %" PRId64 "\n", + c->fc->nb_streams - 1, entries); + +if (sc->sdtp_data) +av_log(c->fc, AV_LOG_WARNING, "Duplicated SDTP atom\n"); +av_freep(&sc->sdtp_data); +sc->sdtp_count = 0; + +sc->sdtp_data = av_mallocz(entries); +if (!sc->sdtp_data) +return AVERROR(ENOMEM); + +for (i = 0; i < entries && !pb->eof_reached; i++) +sc->sdtp_data[i] = avio_r8(pb); +sc->sdtp_count = i; + +return 0; +} + static void mov_update_dts_shift(MOVStreamContext *sc, int duration) { if (duration < 0) { @@ -6767,6 +6801,7 @@ static const MOVParseTableEntry mov_default_parse_table[] = { { MKTAG('s','t','s','z'), mov_read_stsz }, /* sample size */ { MKTAG('s','t','t','s'), mov_read_stts }, { MKTAG('s','t','z','2'), mov_read_stsz }, /* compact sample size */ +{ MKTAG('s','d','t','p'), mov_read_sdtp }, /* independant and disposable samples */ { MKTAG('t','k','h','d'), mov_read_tkhd }, /* track header */ { MKTAG('t','f','d','t'), mov_read_tfdt }, { MKTAG('t','f','h','d'), mov_read_tfhd }, /* track fragment header */ @@ -7231,6 +7266,7 @@ static int mov_read_close(AVFormatContext *s) av_freep(&sc->sample_sizes); av_freep(&sc->keyframes); av_freep(&sc->stts_data); +av_freep(&sc->sdtp_data); av_freep(&sc->stps_data); av_freep(&sc->elst_data); av_freep(&sc->rap_group); @@ -7820,6 +7856,11 @@ static int mov_read_packet(AVFormatContext *s, AVPacket *pkt) } if (st->discard == AVDISCARD_ALL) goto retry; +if (sc->sdtp_data && sc->current_sample <= sc->sdtp_count) { +uint8_t sample_flags = sc->sdtp_data[sc->current_sample - 1]; +uint8_t sample_is_depended_on = (sample_flags >> 2) & 0x3; +pkt->flags |= sample_is_depended_on == MOV_SAMPLE_DEPENDENCY_NO ? AV_PKT_FLAG_DISPOSABLE : 0; +} pkt->flags |= sample->flags & AVINDEX_KEYFRAME ? AV_PKT_FLAG_KEY : 0; pkt->pos = sample->pos; -- 2.23.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 2/2] fate: update references after mov sdtp parsing change
--- tests/ref/fate/hapqa-extract-snappy1-to-hapalphaonly | 2 +- tests/ref/fate/hapqa-extract-snappy1-to-hapq | 2 +- tests/ref/fate/hapqa-extract-snappy16-to-hapalphaonly | 2 +- tests/ref/fate/hapqa-extract-snappy16-to-hapq | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/ref/fate/hapqa-extract-snappy1-to-hapalphaonly b/tests/ref/fate/hapqa-extract-snappy1-to-hapalphaonly index 9ab123f09d..7edd5fa65b 100644 --- a/tests/ref/fate/hapqa-extract-snappy1-to-hapalphaonly +++ b/tests/ref/fate/hapqa-extract-snappy1-to-hapalphaonly @@ -3,4 +3,4 @@ #codec_id 0: hap #dimensions 0: 127x71 #sar 0: 1/1 -0, 0, 0,1, 3044, 0xcaf6ddd0 +0, 0, 0,1, 3044, 0xcaf6ddd0, F=0x11 diff --git a/tests/ref/fate/hapqa-extract-snappy1-to-hapq b/tests/ref/fate/hapqa-extract-snappy1-to-hapq index f658b1c0b4..1340f77bf5 100644 --- a/tests/ref/fate/hapqa-extract-snappy1-to-hapq +++ b/tests/ref/fate/hapqa-extract-snappy1-to-hapq @@ -3,4 +3,4 @@ #codec_id 0: hap #dimensions 0: 127x71 #sar 0: 1/1 -0, 0, 0,1, 8217, 0x04271f0f +0, 0, 0,1, 8217, 0x04271f0f, F=0x11 diff --git a/tests/ref/fate/hapqa-extract-snappy16-to-hapalphaonly b/tests/ref/fate/hapqa-extract-snappy16-to-hapalphaonly index 1bd920699a..e6adc004d9 100644 --- a/tests/ref/fate/hapqa-extract-snappy16-to-hapalphaonly +++ b/tests/ref/fate/hapqa-extract-snappy16-to-hapalphaonly @@ -3,4 +3,4 @@ #codec_id 0: hap #dimensions 0: 127x71 #sar 0: 1/1 -0, 0, 0,1, 3513, 0x69c7014f +0, 0, 0,1, 3513, 0x69c7014f, F=0x11 diff --git a/tests/ref/fate/hapqa-extract-snappy16-to-hapq b/tests/ref/fate/hapqa-extract-snappy16-to-hapq index 8334d53d61..f356301501 100644 --- a/tests/ref/fate/hapqa-extract-snappy16-to-hapq +++ b/tests/ref/fate/hapqa-extract-snappy16-to-hapq @@ -3,4 +3,4 @@ #codec_id 0: hap #dimensions 0: 127x71 #sar 0: 1/1 -0, 0, 0,1, 8726, 0xf889691c +0, 0, 0,1, 8726, 0xf889691c, F=0x11 -- 2.23.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 1/2] avformat/mov: parse sdtp atom and set the pkt disposable flag accordingly
On Fri, Sep 27, 2019 at 04:14:33PM +0100, Derek Buitenhuis wrote: > On 27/09/2019 15:37, Matthieu Bouron wrote: > > Allows the creation of the sdtp atom while remuxing MP4 to MP4. This > > atom is required by Apple devices (iPhone, Apple TV) in order to accept > > 2160p medias. > > Can you point to a document about this (for informational purposes)? For the MP4 container, tt is part of ISO/IEC14496-12 but it looks like it is not public. It is also described here for the QT container: https://developer.apple.com/library/archive/documentation/QuickTime/QTFF/QTFFChap2/qtff2.html#//apple_ref/doc/uid/TP4939-CH204-SW46 The specification differs in wording and presentation between the two, but the final encoded values of each flags are the same. For both specs the flags are stored in 1 byte. For sample_is_depended_on in QT, you have to use: kQTSampleDependency_NoOtherSampleDependsOnThisSample = 1<<3, kQTSampleDependency_OtherSamplesDependOnThisSample = 1<<2, In MP4, the spec describe the following layout for the flags: unsigned int(2) reserved = 0; unsigned int(2) sample_depends_on; unsigned int(2) sample_is_depended_on; unsigned int(2) sample_has_redundancy; unsigned int(2) And values for sample_is_depended_on: 0: the dependency of other samples on this sample is unknown 1: other samples depend on this one (not disposable) 2: no other sample depends on this one (disposable) 3: reserved NOTE: we already support the sdtp atom in movenc.c. > > Is this valid for both QTFF and ISOBMFF? > > > static void mov_update_dts_shift(MOVStreamContext *sc, int duration) > > { > > if (duration < 0) { > > @@ -6767,6 +6801,7 @@ static const MOVParseTableEntry > > mov_default_parse_table[] = { > > { MKTAG('s','t','s','z'), mov_read_stsz }, /* sample size */ > > { MKTAG('s','t','t','s'), mov_read_stts }, > > { MKTAG('s','t','z','2'), mov_read_stsz }, /* compact sample size */ > > +{ MKTAG('s','d','t','p'), mov_read_sdtp }, /* independant and disposable > > samples */ > > Spelling mistake. Fixed locally. Thanks. -- Matthieu B. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 3/3] avformat/aiffenc: Remove wrong and redundant check
On Wed, Oct 02, 2019 at 06:04:12AM +0200, Andreas Rheinhardt wrote: > The check "if (!pb->seekable & AVIO_SEEKABLE_NORMAL)" is wrong, because > ! has higher precendence than &. But it is also redundant, because this > part of the code is only ever reached when the AVIO_SEEKABLE_NORMAL flag > is set for pb. So simply remove the check. > > Signed-off-by: Andreas Rheinhardt > --- > libavformat/aiffenc.c | 3 --- > 1 file changed, 3 deletions(-) > > diff --git a/libavformat/aiffenc.c b/libavformat/aiffenc.c > index 0b837cd264..d09c9afb95 100644 > --- a/libavformat/aiffenc.c > +++ b/libavformat/aiffenc.c > @@ -49,9 +49,6 @@ static int put_id3v2_tags(AVFormatContext *s, > AIFFOutputContext *aiff) > AVIOContext *pb = s->pb; > AVPacketList *pict_list = aiff->pict_list; > > -if (!pb->seekable & AVIO_SEEKABLE_NORMAL) > -return 0; > - > if (!s->metadata && !aiff->pict_list) > return 0; > > -- > 2.21.0 LGTM. -- Matthieu B. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 1/3] avformat/aiffenc: Use standard packet list functions
On Wed, Oct 02, 2019 at 06:04:10AM +0200, Andreas Rheinhardt wrote: > Up until now, aiffenc didn't rely on the standard functions for adding > an element to a linked list and freeing the list, but instead > reimplemented them. This has been changed. > > Signed-off-by: Andreas Rheinhardt > --- > libavformat/aiffenc.c | 33 - > 1 file changed, 4 insertions(+), 29 deletions(-) > > diff --git a/libavformat/aiffenc.c b/libavformat/aiffenc.c > index aab37418f0..dd8b8c3d01 100644 > --- a/libavformat/aiffenc.c > +++ b/libavformat/aiffenc.c > @@ -36,7 +36,7 @@ typedef struct AIFFOutputContext { > int64_t frames; > int64_t ssnd; > int audio_stream_idx; > -AVPacketList *pict_list; > +AVPacketList *pict_list, *pict_list_end; > int write_id3v2; > int id3v2_version; > } AIFFOutputContext; > @@ -215,9 +215,6 @@ static int aiff_write_packet(AVFormatContext *s, AVPacket > *pkt) > if (pkt->stream_index == aiff->audio_stream_idx) > avio_write(pb, pkt->data, pkt->size); > else { > -int ret; > -AVPacketList *pict_list, *last; > - > if (s->streams[pkt->stream_index]->codecpar->codec_type != > AVMEDIA_TYPE_VIDEO) > return 0; > > @@ -229,24 +226,8 @@ static int aiff_write_packet(AVFormatContext *s, > AVPacket *pkt) > if (s->streams[pkt->stream_index]->nb_frames >= 1) > return 0; > > -pict_list = av_mallocz(sizeof(AVPacketList)); > -if (!pict_list) > -return AVERROR(ENOMEM); > - > -ret = av_packet_ref(&pict_list->pkt, pkt); > -if (ret < 0) { > -av_freep(&pict_list); > -return ret; > -} > - > -if (!aiff->pict_list) > -aiff->pict_list = pict_list; > -else { > -last = aiff->pict_list; > -while (last->next) > -last = last->next; > -last->next = pict_list; > -} > +return ff_packet_list_put(&aiff->pict_list, &aiff->pict_list_end, > + pkt, FF_PACKETLIST_FLAG_REF_PACKET); > } > > return 0; > @@ -257,7 +238,6 @@ static int aiff_write_trailer(AVFormatContext *s) > int ret; > AVIOContext *pb = s->pb; > AIFFOutputContext *aiff = s->priv_data; > -AVPacketList *pict_list = aiff->pict_list; > AVCodecParameters *par = s->streams[aiff->audio_stream_idx]->codecpar; > > /* Chunks sizes must be even */ > @@ -293,12 +273,7 @@ static int aiff_write_trailer(AVFormatContext *s) > avio_flush(pb); > } > > -while (pict_list) { > -AVPacketList *next = pict_list->next; > -av_packet_unref(&pict_list->pkt); > -av_freep(&pict_list); > -pict_list = next; > -} > +ff_packet_list_free(&aiff->pict_list, &aiff->pict_list_end); > > return 0; > } > -- > 2.21.0 LGTM. Fate passes and patch tested with a few remux of aiff files containing id3v2 tags + attached pics (ffmpeg -i input.aiff -write_id3v2 1 output.aiff). Thanks. -- Matthieu B. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 2/3] avformat/aiffenc: Fix potential memleak upon failure
On Wed, Oct 02, 2019 at 06:04:11AM +0200, Andreas Rheinhardt wrote: > Signed-off-by: Andreas Rheinhardt > --- > libavformat/aiffenc.c | 7 --- > 1 file changed, 4 insertions(+), 3 deletions(-) > > diff --git a/libavformat/aiffenc.c b/libavformat/aiffenc.c > index dd8b8c3d01..0b837cd264 100644 > --- a/libavformat/aiffenc.c > +++ b/libavformat/aiffenc.c > @@ -235,7 +235,7 @@ static int aiff_write_packet(AVFormatContext *s, AVPacket > *pkt) > > static int aiff_write_trailer(AVFormatContext *s) > { > -int ret; > +int ret = 0; > AVIOContext *pb = s->pb; > AIFFOutputContext *aiff = s->priv_data; > AVCodecParameters *par = s->streams[aiff->audio_stream_idx]->codecpar; > @@ -263,7 +263,7 @@ static int aiff_write_trailer(AVFormatContext *s) > /* Write ID3 tags */ > if (aiff->write_id3v2) > if ((ret = put_id3v2_tags(s, aiff)) < 0) > -return ret; > +goto free; > > /* File length */ > file_size = avio_tell(pb); > @@ -273,9 +273,10 @@ static int aiff_write_trailer(AVFormatContext *s) > avio_flush(pb); > } > > +free: > ff_packet_list_free(&aiff->pict_list, &aiff->pict_list_end); > > -return 0; > +return ret; > } > > #define OFFSET(x) offsetof(AIFFOutputContext, x) > -- > 2.21.0 LGTM. -- Matthieu B. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 1/2] avformat/mov: parse sdtp atom and set the pkt disposable flag accordingly
On Fri, Sep 27, 2019 at 04:37:31PM +0200, Matthieu Bouron wrote: > Allows the creation of the sdtp atom while remuxing MP4 to MP4. This > atom is required by Apple devices (iPhone, Apple TV) in order to accept > 2160p medias. > --- > libavformat/isom.h | 2 ++ > libavformat/mov.c | 41 + > 2 files changed, 43 insertions(+) > > diff --git a/libavformat/isom.h b/libavformat/isom.h > index 69452cae8e..4943b80ccf 100644 > --- a/libavformat/isom.h > +++ b/libavformat/isom.h > @@ -163,6 +163,8 @@ typedef struct MOVStreamContext { > int64_t *chunk_offsets; > unsigned int stts_count; > MOVStts *stts_data; > +unsigned int sdtp_count; > +uint8_t *sdtp_data; > unsigned int ctts_count; > unsigned int ctts_allocated_size; > MOVStts *ctts_data; > diff --git a/libavformat/mov.c b/libavformat/mov.c > index 8e916a28c6..7dfa07b45e 100644 > --- a/libavformat/mov.c > +++ b/libavformat/mov.c > @@ -2959,6 +2959,40 @@ static int mov_read_stts(MOVContext *c, AVIOContext > *pb, MOVAtom atom) > return 0; > } > > +static int mov_read_sdtp(MOVContext *c, AVIOContext *pb, MOVAtom atom) > +{ > +AVStream *st; > +MOVStreamContext *sc; > +int64_t i, entries; > + > +if (c->fc->nb_streams < 1) > +return 0; > +st = c->fc->streams[c->fc->nb_streams-1]; > +sc = st->priv_data; > + > +avio_r8(pb); /* version */ > +avio_rb24(pb); /* flags */ > +entries = atom.size - 4; > + > +av_log(c->fc, AV_LOG_TRACE, "track[%u].sdtp.entries = %" PRId64 "\n", > + c->fc->nb_streams - 1, entries); > + > +if (sc->sdtp_data) > +av_log(c->fc, AV_LOG_WARNING, "Duplicated SDTP atom\n"); > +av_freep(&sc->sdtp_data); > +sc->sdtp_count = 0; > + > +sc->sdtp_data = av_mallocz(entries); > +if (!sc->sdtp_data) > +return AVERROR(ENOMEM); > + > +for (i = 0; i < entries && !pb->eof_reached; i++) > +sc->sdtp_data[i] = avio_r8(pb); > +sc->sdtp_count = i; > + > +return 0; > +} > + > static void mov_update_dts_shift(MOVStreamContext *sc, int duration) > { > if (duration < 0) { > @@ -6767,6 +6801,7 @@ static const MOVParseTableEntry > mov_default_parse_table[] = { > { MKTAG('s','t','s','z'), mov_read_stsz }, /* sample size */ > { MKTAG('s','t','t','s'), mov_read_stts }, > { MKTAG('s','t','z','2'), mov_read_stsz }, /* compact sample size */ > +{ MKTAG('s','d','t','p'), mov_read_sdtp }, /* independant and disposable > samples */ > { MKTAG('t','k','h','d'), mov_read_tkhd }, /* track header */ > { MKTAG('t','f','d','t'), mov_read_tfdt }, > { MKTAG('t','f','h','d'), mov_read_tfhd }, /* track fragment header */ > @@ -7231,6 +7266,7 @@ static int mov_read_close(AVFormatContext *s) > av_freep(&sc->sample_sizes); > av_freep(&sc->keyframes); > av_freep(&sc->stts_data); > +av_freep(&sc->sdtp_data); > av_freep(&sc->stps_data); > av_freep(&sc->elst_data); > av_freep(&sc->rap_group); > @@ -7820,6 +7856,11 @@ static int mov_read_packet(AVFormatContext *s, > AVPacket *pkt) > } > if (st->discard == AVDISCARD_ALL) > goto retry; > +if (sc->sdtp_data && sc->current_sample <= sc->sdtp_count) { > +uint8_t sample_flags = sc->sdtp_data[sc->current_sample - 1]; > +uint8_t sample_is_depended_on = (sample_flags >> 2) & 0x3; > +pkt->flags |= sample_is_depended_on == MOV_SAMPLE_DEPENDENCY_NO ? > AV_PKT_FLAG_DISPOSABLE : 0; > +} > pkt->flags |= sample->flags & AVINDEX_KEYFRAME ? AV_PKT_FLAG_KEY : 0; > pkt->pos = sample->pos; > > -- > 2.23.0 > Ping. -- Matthieu B. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 1/2] avformat/mov: parse sdtp atom and set the pkt disposable flag accordingly
On Mon, Oct 07, 2019 at 10:19:59PM +0100, Derek Buitenhuis wrote: > On 07/10/2019 16:06, Matthieu Bouron wrote: > > Ping. > > > > No objections from me. Pushed (with the patch updating fate squashed into this patch). Thanks, -- Matthieu B. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] configure: error out if jni is enabled and not found
On Wed, Mar 15, 2017 at 03:29:08PM +0100, Matthieu Bouron wrote: > --- > configure | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/configure b/configure > index 1e2e774950..a4890ca0d3 100755 > --- a/configure > +++ b/configure > @@ -5744,7 +5744,7 @@ enabled frei0r&& { check_header frei0r.h || > die "ERROR: frei0r.h hea > enabled gmp && require2 gmp gmp.h mpz_export -lgmp > enabled gnutls&& require_pkg_config gnutls gnutls/gnutls.h > gnutls_global_init > enabled jni && { [ $target_os = "android" ] && check_header > jni.h && enabled pthreads && > - check_lib2 "dlfcn.h" dlopen -ldl; } > + check_lib2 "dlfcn.h" dlopen -ldl || die > "ERROR: JNI not found"; } > enabled ladspa&& { check_header ladspa.h || die "ERROR: ladspa.h > header not found"; } > enabled libiec61883 && require libiec61883 libiec61883/iec61883.h > iec61883_cmp_connect -lraw1394 -lavc1394 -lrom1394 -liec61883 > enabled libass&& require_pkg_config libass ass/ass.h > ass_library_init > -- > 2.12.0 > I'll apply the patch in one day if there is no objection. Matthieu [...] ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] configure: error out if jni is enabled and not found
On Sat, Mar 18, 2017 at 12:27:20PM +0100, Matthieu Bouron wrote: > On Wed, Mar 15, 2017 at 03:29:08PM +0100, Matthieu Bouron wrote: > > --- > > configure | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/configure b/configure > > index 1e2e774950..a4890ca0d3 100755 > > --- a/configure > > +++ b/configure > > @@ -5744,7 +5744,7 @@ enabled frei0r&& { check_header frei0r.h > > || die "ERROR: frei0r.h hea > > enabled gmp && require2 gmp gmp.h mpz_export -lgmp > > enabled gnutls&& require_pkg_config gnutls gnutls/gnutls.h > > gnutls_global_init > > enabled jni && { [ $target_os = "android" ] && check_header > > jni.h && enabled pthreads && > > - check_lib2 "dlfcn.h" dlopen -ldl; } > > + check_lib2 "dlfcn.h" dlopen -ldl || die > > "ERROR: JNI not found"; } > > enabled ladspa&& { check_header ladspa.h || die "ERROR: > > ladspa.h header not found"; } > > enabled libiec61883 && require libiec61883 libiec61883/iec61883.h > > iec61883_cmp_connect -lraw1394 -lavc1394 -lrom1394 -liec61883 > > enabled libass&& require_pkg_config libass ass/ass.h > > ass_library_init > > -- > > 2.12.0 > > > > I'll apply the patch in one day if there is no objection. Pushed. [...] ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 1/7] avcodec/mediacodec: convert to stdatomic
Le 23 mars 2017 12:35 AM, "James Almer" a écrit : Signed-off-by: James Almer --- Untested. libavcodec/mediacodec.c | 5 ++--- libavcodec/mediacodecdec.c| 1 - libavcodec/mediacodecdec_common.c | 14 ++ libavcodec/mediacodecdec_common.h | 5 +++-- 4 files changed, 11 insertions(+), 14 deletions(-) diff --git a/libavcodec/mediacodec.c b/libavcodec/mediacodec.c index 4ad5921bc2..91f725621d 100644 --- a/libavcodec/mediacodec.c +++ b/libavcodec/mediacodec.c @@ -31,7 +31,6 @@ #include #include "libavcodec/avcodec.h" -#include "libavutil/atomic.h" #include "libavutil/mem.h" #include "ffjni.h" @@ -90,9 +89,9 @@ void av_mediacodec_default_free(AVCodecContext *avctx) int av_mediacodec_release_buffer(AVMediaCodecBuffer *buffer, int render) { MediaCodecDecContext *ctx = buffer->ctx; -int released = avpriv_atomic_int_add_and_fetch(&buffer->released, 1); +atomic_int released = atomic_fetch_add(&buffer->released, 1); -if (released == 1) { +if (!released) { Hello, The underlying buffer is meant to be released once. Unless i miss something there, you could potentially release a later buffer using the same index or release an invalid buffer. A mediacodec buffer can only be released once. Once it is released it goes back to the decoder pool and it is not usable anymore unless it bas been returned by the decoder again. The buffer itself is represented by an index. Can you bring the original check back ? (released == 1) I dont have the time to review and test the entire patch (nor the machine, i m writing from my phone) as i am on holidays but i ll be back on monday (and i ll test the patch). Matthieu [...] ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 1/7] avcodec/mediacodec: convert to stdatomic
Le 23 mars 2017 7:31 PM, "James Almer" a écrit : On 3/23/2017 3:15 PM, Matthieu Bouron wrote: > Le 23 mars 2017 12:35 AM, "James Almer" a écrit : > > Signed-off-by: James Almer > --- > Untested. > > libavcodec/mediacodec.c | 5 ++--- > libavcodec/mediacodecdec.c| 1 - > libavcodec/mediacodecdec_common.c | 14 ++ > libavcodec/mediacodecdec_common.h | 5 +++-- > 4 files changed, 11 insertions(+), 14 deletions(-) > > diff --git a/libavcodec/mediacodec.c b/libavcodec/mediacodec.c > index 4ad5921bc2..91f725621d 100644 > --- a/libavcodec/mediacodec.c > +++ b/libavcodec/mediacodec.c > @@ -31,7 +31,6 @@ > #include > > #include "libavcodec/avcodec.h" > -#include "libavutil/atomic.h" > #include "libavutil/mem.h" > > #include "ffjni.h" > @@ -90,9 +89,9 @@ void av_mediacodec_default_free(AVCodecContext *avctx) > int av_mediacodec_release_buffer(AVMediaCodecBuffer *buffer, int render) > { > MediaCodecDecContext *ctx = buffer->ctx; > -int released = avpriv_atomic_int_add_and_fetch(&buffer->released, 1); > +atomic_int released = atomic_fetch_add(&buffer->released, 1); > > -if (released == 1) { > +if (!released) { > > > Hello, > > The underlying buffer is meant to be released once. Unless i miss something > there, you could potentially release a later buffer using the same index or > release an invalid buffer. A mediacodec buffer can only be released once. > Once it is released it goes back to the decoder pool and it is not usable > anymore unless it bas been returned by the decoder again. The buffer itself > is represented by an index. Can you bring the original check back ? > (released == 1) C11 atomics only has fetch_add functions, not add_fetch like the previous implementation. add_fetch(&dst, 1) adds 1 to dst, then returns the new dst value. fetch_add(&dst, 1) adds 1 to dst, then returns the old dst value. This means that for us to check if the buffer was released once, while for add_fetch we had to check if the return value was 1, for fetch_add we need to check if it's zero. Thanks for the explanation and for the patch (and sorry for the noise). Matthieu [...] ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH] doc/examples/remuxing: switch to codecpar
Also limits remuxing to audio, video and subtitle streams. --- doc/examples/remuxing.c | 48 +--- 1 file changed, 41 insertions(+), 7 deletions(-) diff --git a/doc/examples/remuxing.c b/doc/examples/remuxing.c index 65437d9abd..8615c73842 100644 --- a/doc/examples/remuxing.c +++ b/doc/examples/remuxing.c @@ -50,6 +50,9 @@ int main(int argc, char **argv) AVPacket pkt; const char *in_filename, *out_filename; int ret, i; +int stream_index = 0; +int *stream_mapping = NULL; +int stream_mapping_size = 0; if (argc < 3) { printf("usage: %s input output\n" @@ -83,25 +86,48 @@ int main(int argc, char **argv) goto end; } +stream_mapping_size = ifmt_ctx->nb_streams; +stream_mapping = av_mallocz_array(stream_mapping_size, sizeof(*stream_mapping)); +if (!stream_mapping) { +ret = AVERROR(ENOMEM); +goto end; +} + ofmt = ofmt_ctx->oformat; for (i = 0; i < ifmt_ctx->nb_streams; i++) { +AVStream *out_stream; AVStream *in_stream = ifmt_ctx->streams[i]; -AVStream *out_stream = avformat_new_stream(ofmt_ctx, in_stream->codec->codec); +AVCodecParameters *in_codecpar = in_stream->codecpar; + +if (in_codecpar->codec_type != AVMEDIA_TYPE_AUDIO && +in_codecpar->codec_type != AVMEDIA_TYPE_VIDEO && +in_codecpar->codec_type != AVMEDIA_TYPE_SUBTITLE) { +stream_mapping[i] = -1; +continue; +} + +stream_mapping[i] = stream_index++; + +out_stream = avformat_new_stream(ofmt_ctx, NULL); if (!out_stream) { fprintf(stderr, "Failed allocating output stream\n"); ret = AVERROR_UNKNOWN; goto end; } -ret = avcodec_copy_context(out_stream->codec, in_stream->codec); +ret = avcodec_parameters_copy(out_stream->codecpar, in_codecpar); if (ret < 0) { -fprintf(stderr, "Failed to copy context from input to output stream codec context\n"); +fprintf(stderr, "Failed to copy copy codec parameters\n"); +goto end; +} +out_stream->codecpar->codec_tag = 0; + +ret = avformat_transfer_internal_stream_timing_info(ofmt, out_stream, in_stream, AVFMT_TBCF_AUTO); +if (ret < 0) { +fprintf(stderr, "Failed to copy stream timing info\n"); goto end; } -out_stream->codec->codec_tag = 0; -if (ofmt_ctx->oformat->flags & AVFMT_GLOBALHEADER) -out_stream->codec->flags |= AV_CODEC_FLAG_GLOBAL_HEADER; } av_dump_format(ofmt_ctx, 0, out_filename, 1); @@ -127,8 +153,14 @@ int main(int argc, char **argv) break; in_stream = ifmt_ctx->streams[pkt.stream_index]; -out_stream = ofmt_ctx->streams[pkt.stream_index]; +if (pkt.stream_index >= stream_mapping_size || +stream_mapping[pkt.stream_index] < 0) { +av_packet_unref(&pkt); +continue; +} +pkt.stream_index = stream_mapping[pkt.stream_index]; +out_stream = ofmt_ctx->streams[pkt.stream_index]; log_packet(ifmt_ctx, &pkt, "in"); /* copy packet */ @@ -156,6 +188,8 @@ end: avio_closep(&ofmt_ctx->pb); avformat_free_context(ofmt_ctx); +av_freep(&stream_mapping); + if (ret < 0 && ret != AVERROR_EOF) { fprintf(stderr, "Error occurred: %s\n", av_err2str(ret)); return 1; -- 2.12.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH] doc/examples/extract_mvs: switch to codecpar
--- doc/examples/extract_mvs.c | 33 ++--- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/doc/examples/extract_mvs.c b/doc/examples/extract_mvs.c index 975189c77d..09c3d32389 100644 --- a/doc/examples/extract_mvs.c +++ b/doc/examples/extract_mvs.c @@ -69,8 +69,7 @@ static int decode_packet(int *got_frame, int cached) return decoded; } -static int open_codec_context(int *stream_idx, - AVFormatContext *fmt_ctx, enum AVMediaType type) +static int open_codec_context(AVFormatContext *fmt_ctx, enum AVMediaType type) { int ret; AVStream *st; @@ -84,18 +83,29 @@ static int open_codec_context(int *stream_idx, av_get_media_type_string(type), src_filename); return ret; } else { -*stream_idx = ret; -st = fmt_ctx->streams[*stream_idx]; +int stream_idx = ret; +st = fmt_ctx->streams[stream_idx]; /* find decoder for the stream */ -dec_ctx = st->codec; -dec = avcodec_find_decoder(dec_ctx->codec_id); +dec = avcodec_find_decoder(st->codecpar->codec_id); if (!dec) { fprintf(stderr, "Failed to find %s codec\n", av_get_media_type_string(type)); return AVERROR(EINVAL); } +dec_ctx = avcodec_alloc_context3(dec); +if (!dec_ctx) { +fprintf(stderr, "Failed to allocate codec\n"); +return AVERROR(EINVAL); +} + +ret = avcodec_parameters_to_context(dec_ctx, st->codecpar); +if (ret < 0) { +fprintf(stderr, "Failed to copy codec parameters to codec context\n"); +return ret; +} + /* Init the video decoder */ av_dict_set(&opts, "flags2", "+export_mvs", 0); if ((ret = avcodec_open2(dec_ctx, dec, &opts)) < 0) { @@ -103,6 +113,10 @@ static int open_codec_context(int *stream_idx, av_get_media_type_string(type)); return ret; } + +video_stream_idx = stream_idx; +video_stream = fmt_ctx->streams[video_stream_idx]; +video_dec_ctx = dec_ctx; } return 0; @@ -130,10 +144,7 @@ int main(int argc, char **argv) exit(1); } -if (open_codec_context(&video_stream_idx, fmt_ctx, AVMEDIA_TYPE_VIDEO) >= 0) { -video_stream = fmt_ctx->streams[video_stream_idx]; -video_dec_ctx = video_stream->codec; -} +open_codec_context(fmt_ctx, AVMEDIA_TYPE_VIDEO); av_dump_format(fmt_ctx, 0, src_filename, 0); @@ -178,7 +189,7 @@ int main(int argc, char **argv) } while (got_frame); end: -avcodec_close(video_dec_ctx); +avcodec_free_context(&video_dec_ctx); avformat_close_input(&fmt_ctx); av_frame_free(&frame); return ret < 0; -- 2.12.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] doc/examples/extract_mvs: switch to codecpar
On Tue, Mar 28, 2017 at 1:48 PM, Matthieu Bouron wrote: > --- > doc/examples/extract_mvs.c | 33 ++--- > 1 file changed, 22 insertions(+), 11 deletions(-) > > diff --git a/doc/examples/extract_mvs.c b/doc/examples/extract_mvs.c > index 975189c77d..09c3d32389 100644 > --- a/doc/examples/extract_mvs.c > +++ b/doc/examples/extract_mvs.c > @@ -69,8 +69,7 @@ static int decode_packet(int *got_frame, int cached) > return decoded; > } > > -static int open_codec_context(int *stream_idx, > - AVFormatContext *fmt_ctx, enum AVMediaType > type) > +static int open_codec_context(AVFormatContext *fmt_ctx, enum AVMediaType > type) > { > int ret; > AVStream *st; > @@ -84,18 +83,29 @@ static int open_codec_context(int *stream_idx, > av_get_media_type_string(type), src_filename); > return ret; > } else { > -*stream_idx = ret; > -st = fmt_ctx->streams[*stream_idx]; > +int stream_idx = ret; > +st = fmt_ctx->streams[stream_idx]; > > /* find decoder for the stream */ > -dec_ctx = st->codec; > -dec = avcodec_find_decoder(dec_ctx->codec_id); > +dec = avcodec_find_decoder(st->codecpar->codec_id); > avcodec_find_decoder call removed locally and replaced by the codec returned by avformat_find_best_stream. [...] ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] doc/examples/remuxing: switch to codecpar
On Tue, Mar 28, 2017 at 12:48 PM, wm4 wrote: > On Tue, 28 Mar 2017 12:32:19 +0200 > Matthieu Bouron wrote: > > > Also limits remuxing to audio, video and subtitle streams. > > --- > > doc/examples/remuxing.c | 48 ++ > +++--- > > 1 file changed, 41 insertions(+), 7 deletions(-) > > > > diff --git a/doc/examples/remuxing.c b/doc/examples/remuxing.c > > index 65437d9abd..8615c73842 100644 > > --- a/doc/examples/remuxing.c > > +++ b/doc/examples/remuxing.c > > @@ -50,6 +50,9 @@ int main(int argc, char **argv) > > AVPacket pkt; > > const char *in_filename, *out_filename; > > int ret, i; > > +int stream_index = 0; > > +int *stream_mapping = NULL; > > +int stream_mapping_size = 0; > > > > if (argc < 3) { > > printf("usage: %s input output\n" > > @@ -83,25 +86,48 @@ int main(int argc, char **argv) > > goto end; > > } > > > > +stream_mapping_size = ifmt_ctx->nb_streams; > > +stream_mapping = av_mallocz_array(stream_mapping_size, > sizeof(*stream_mapping)); > > +if (!stream_mapping) { > > +ret = AVERROR(ENOMEM); > > +goto end; > > +} > > + > > ofmt = ofmt_ctx->oformat; > > > > for (i = 0; i < ifmt_ctx->nb_streams; i++) { > > +AVStream *out_stream; > > AVStream *in_stream = ifmt_ctx->streams[i]; > > -AVStream *out_stream = avformat_new_stream(ofmt_ctx, > in_stream->codec->codec); > > +AVCodecParameters *in_codecpar = in_stream->codecpar; > > + > > +if (in_codecpar->codec_type != AVMEDIA_TYPE_AUDIO && > > +in_codecpar->codec_type != AVMEDIA_TYPE_VIDEO && > > +in_codecpar->codec_type != AVMEDIA_TYPE_SUBTITLE) { > > +stream_mapping[i] = -1; > > +continue; > > +} > > + > > +stream_mapping[i] = stream_index++; > > + > > +out_stream = avformat_new_stream(ofmt_ctx, NULL); > > if (!out_stream) { > > fprintf(stderr, "Failed allocating output stream\n"); > > ret = AVERROR_UNKNOWN; > > goto end; > > } > > > > -ret = avcodec_copy_context(out_stream->codec, > in_stream->codec); > > +ret = avcodec_parameters_copy(out_stream->codecpar, > in_codecpar); > > if (ret < 0) { > > -fprintf(stderr, "Failed to copy context from input to > output stream codec context\n"); > > +fprintf(stderr, "Failed to copy copy codec parameters\n"); > > +goto end; > > +} > > +out_stream->codecpar->codec_tag = 0; > > + > > +ret = avformat_transfer_internal_stream_timing_info(ofmt, > out_stream, in_stream, AVFMT_TBCF_AUTO); > > +if (ret < 0) { > > +fprintf(stderr, "Failed to copy stream timing info\n"); > > Remove this call. It was made for obscure corner cases like ffserver, > and one avi thing AFAIK? > > I just ran fate with ffmpeg.c compiled without the avformat_transfer_internal_stream_timing_info call, and it broke in many areas. On the other hand, it only seems to transfer ist->time_base to enc_ctx->time_base for the general case, which shouldn't be useful for remuxing (i can be missing things though). I removed the call locally. > goto end; > > } > > -out_stream->codec->codec_tag = 0; > > -if (ofmt_ctx->oformat->flags & AVFMT_GLOBALHEADER) > > -out_stream->codec->flags |= AV_CODEC_FLAG_GLOBAL_HEADER; > > } > > av_dump_format(ofmt_ctx, 0, out_filename, 1); > > > > @@ -127,8 +153,14 @@ int main(int argc, char **argv) > > break; > > > > in_stream = ifmt_ctx->streams[pkt.stream_index]; > > -out_stream = ofmt_ctx->streams[pkt.stream_index]; > > +if (pkt.stream_index >= stream_mapping_size || > > +stream_mapping[pkt.stream_index] < 0) { > > +av_packet_unref(&pkt); > > +continue; > > +} > > > > +pkt.stream_index = stream_mapping[pkt.stream_index]; > > +out_stream = ofmt_ctx->streams[pkt.stream_index]; > > log_packet(ifmt_ctx, &pkt, "in"); > > > > /* copy packet */ > > @@ -156,6 +188,8 @@ end: > > avio_closep(&ofmt_ctx->pb); > > avformat_free_context(ofmt_ctx); > > > > +av_freep(&stream_mapping); > > + > > if (ret < 0 && ret != AVERROR_EOF) { > > fprintf(stderr, "Error occurred: %s\n", av_err2str(ret)); > > return 1; > > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel > ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] doc/examples/remuxing: switch to codecpar
On Tue, Mar 28, 2017 at 4:21 PM, Moritz Barsnick wrote: > On Tue, Mar 28, 2017 at 12:32:19 +0200, Matthieu Bouron wrote: > > -fprintf(stderr, "Failed to copy context from input to > output stream codec context\n"); > > +fprintf(stderr, "Failed to copy copy codec parameters\n"); > > "copy copy"? > Fixed locally. Thanks [...] ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] doc/examples/remuxing: switch to codecpar
On Tue, Mar 28, 2017 at 12:32 PM, Matthieu Bouron wrote: > Also limits remuxing to audio, video and subtitle streams. > --- > doc/examples/remuxing.c | 48 ++ > +++--- > 1 file changed, 41 insertions(+), 7 deletions(-) > > diff --git a/doc/examples/remuxing.c b/doc/examples/remuxing.c > index 65437d9abd..8615c73842 100644 > --- a/doc/examples/remuxing.c > +++ b/doc/examples/remuxing.c > @@ -50,6 +50,9 @@ int main(int argc, char **argv) > AVPacket pkt; > const char *in_filename, *out_filename; > int ret, i; > +int stream_index = 0; > +int *stream_mapping = NULL; > +int stream_mapping_size = 0; > > if (argc < 3) { > printf("usage: %s input output\n" > @@ -83,25 +86,48 @@ int main(int argc, char **argv) > goto end; > } > > +stream_mapping_size = ifmt_ctx->nb_streams; > +stream_mapping = av_mallocz_array(stream_mapping_size, > sizeof(*stream_mapping)); > +if (!stream_mapping) { > +ret = AVERROR(ENOMEM); > +goto end; > +} > + > ofmt = ofmt_ctx->oformat; > > for (i = 0; i < ifmt_ctx->nb_streams; i++) { > +AVStream *out_stream; > AVStream *in_stream = ifmt_ctx->streams[i]; > -AVStream *out_stream = avformat_new_stream(ofmt_ctx, > in_stream->codec->codec); > +AVCodecParameters *in_codecpar = in_stream->codecpar; > + > +if (in_codecpar->codec_type != AVMEDIA_TYPE_AUDIO && > +in_codecpar->codec_type != AVMEDIA_TYPE_VIDEO && > +in_codecpar->codec_type != AVMEDIA_TYPE_SUBTITLE) { > +stream_mapping[i] = -1; > +continue; > +} > + > +stream_mapping[i] = stream_index++; > + > +out_stream = avformat_new_stream(ofmt_ctx, NULL); > if (!out_stream) { > fprintf(stderr, "Failed allocating output stream\n"); > ret = AVERROR_UNKNOWN; > goto end; > } > > -ret = avcodec_copy_context(out_stream->codec, in_stream->codec); > +ret = avcodec_parameters_copy(out_stream->codecpar, in_codecpar); > if (ret < 0) { > -fprintf(stderr, "Failed to copy context from input to output > stream codec context\n"); > +fprintf(stderr, "Failed to copy copy codec parameters\n"); > +goto end; > +} > +out_stream->codecpar->codec_tag = 0; > + > +ret = avformat_transfer_internal_stream_timing_info(ofmt, > out_stream, in_stream, AVFMT_TBCF_AUTO); > +if (ret < 0) { > +fprintf(stderr, "Failed to copy stream timing info\n"); > goto end; > } > -out_stream->codec->codec_tag = 0; > -if (ofmt_ctx->oformat->flags & AVFMT_GLOBALHEADER) > -out_stream->codec->flags |= AV_CODEC_FLAG_GLOBAL_HEADER; > } > av_dump_format(ofmt_ctx, 0, out_filename, 1); > > @@ -127,8 +153,14 @@ int main(int argc, char **argv) > break; > > in_stream = ifmt_ctx->streams[pkt.stream_index]; > -out_stream = ofmt_ctx->streams[pkt.stream_index]; > +if (pkt.stream_index >= stream_mapping_size || > +stream_mapping[pkt.stream_index] < 0) { > +av_packet_unref(&pkt); > +continue; > +} > > +pkt.stream_index = stream_mapping[pkt.stream_index]; > +out_stream = ofmt_ctx->streams[pkt.stream_index]; > log_packet(ifmt_ctx, &pkt, "in"); > > /* copy packet */ > @@ -156,6 +188,8 @@ end: > avio_closep(&ofmt_ctx->pb); > avformat_free_context(ofmt_ctx); > > +av_freep(&stream_mapping); > + > if (ret < 0 && ret != AVERROR_EOF) { > fprintf(stderr, "Error occurred: %s\n", av_err2str(ret)); > return 1; > -- > 2.12.0 > > Patch pushed (taking into account wm4 and Moritz reviews). ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] doc/examples/extract_mvs: switch to codecpar
On Tue, Mar 28, 2017 at 12:53 PM, Matthieu Bouron wrote: > > > On Tue, Mar 28, 2017 at 1:48 PM, Matthieu Bouron < > matthieu.bou...@gmail.com> wrote: > >> --- >> doc/examples/extract_mvs.c | 33 ++--- >> 1 file changed, 22 insertions(+), 11 deletions(-) >> >> diff --git a/doc/examples/extract_mvs.c b/doc/examples/extract_mvs.c >> index 975189c77d..09c3d32389 100644 >> --- a/doc/examples/extract_mvs.c >> +++ b/doc/examples/extract_mvs.c >> @@ -69,8 +69,7 @@ static int decode_packet(int *got_frame, int cached) >> return decoded; >> } >> >> -static int open_codec_context(int *stream_idx, >> - AVFormatContext *fmt_ctx, enum AVMediaType >> type) >> +static int open_codec_context(AVFormatContext *fmt_ctx, enum >> AVMediaType type) >> { >> int ret; >> AVStream *st; >> @@ -84,18 +83,29 @@ static int open_codec_context(int *stream_idx, >> av_get_media_type_string(type), src_filename); >> return ret; >> } else { >> -*stream_idx = ret; >> -st = fmt_ctx->streams[*stream_idx]; >> +int stream_idx = ret; >> +st = fmt_ctx->streams[stream_idx]; >> >> /* find decoder for the stream */ >> -dec_ctx = st->codec; >> -dec = avcodec_find_decoder(dec_ctx->codec_id); >> +dec = avcodec_find_decoder(st->codecpar->codec_id); >> > > avcodec_find_decoder call removed locally and replaced by the codec > returned by avformat_find_best_stream. > Patch pushed. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] doc/examples/remuxing: switch to codecpar
On Tue, Mar 28, 2017 at 10:06:31PM +0200, Michael Niedermayer wrote: > On Tue, Mar 28, 2017 at 04:54:38PM +0200, Matthieu Bouron wrote: > > On Tue, Mar 28, 2017 at 12:32 PM, Matthieu Bouron > > wrote: > > > > > Also limits remuxing to audio, video and subtitle streams. > > > --- > > > doc/examples/remuxing.c | 48 ++ > > > +++--- > > > 1 file changed, 41 insertions(+), 7 deletions(-) > > > > > > diff --git a/doc/examples/remuxing.c b/doc/examples/remuxing.c > > > index 65437d9abd..8615c73842 100644 > > > --- a/doc/examples/remuxing.c > > > +++ b/doc/examples/remuxing.c > > > @@ -50,6 +50,9 @@ int main(int argc, char **argv) > > > AVPacket pkt; > > > const char *in_filename, *out_filename; > > > int ret, i; > > > +int stream_index = 0; > > > +int *stream_mapping = NULL; > > > +int stream_mapping_size = 0; > > > > > > if (argc < 3) { > > > printf("usage: %s input output\n" > > > @@ -83,25 +86,48 @@ int main(int argc, char **argv) > > > goto end; > > > } > > > > > > +stream_mapping_size = ifmt_ctx->nb_streams; > > > +stream_mapping = av_mallocz_array(stream_mapping_size, > > > sizeof(*stream_mapping)); > > > +if (!stream_mapping) { > > > +ret = AVERROR(ENOMEM); > > > +goto end; > > > +} > > > + > > > ofmt = ofmt_ctx->oformat; > > > > > > for (i = 0; i < ifmt_ctx->nb_streams; i++) { > > > +AVStream *out_stream; > > > AVStream *in_stream = ifmt_ctx->streams[i]; > > > -AVStream *out_stream = avformat_new_stream(ofmt_ctx, > > > in_stream->codec->codec); > > > +AVCodecParameters *in_codecpar = in_stream->codecpar; > > > + > > > +if (in_codecpar->codec_type != AVMEDIA_TYPE_AUDIO && > > > +in_codecpar->codec_type != AVMEDIA_TYPE_VIDEO && > > > +in_codecpar->codec_type != AVMEDIA_TYPE_SUBTITLE) { > > > +stream_mapping[i] = -1; > > > +continue; > > > +} > > > + > > > +stream_mapping[i] = stream_index++; > > > + > > > +out_stream = avformat_new_stream(ofmt_ctx, NULL); > > > if (!out_stream) { > > > fprintf(stderr, "Failed allocating output stream\n"); > > > ret = AVERROR_UNKNOWN; > > > goto end; > > > } > > > > > > -ret = avcodec_copy_context(out_stream->codec, in_stream->codec); > > > +ret = avcodec_parameters_copy(out_stream->codecpar, in_codecpar); > > > if (ret < 0) { > > > -fprintf(stderr, "Failed to copy context from input to output > > > stream codec context\n"); > > > +fprintf(stderr, "Failed to copy copy codec parameters\n"); > > > +goto end; > > > +} > > > +out_stream->codecpar->codec_tag = 0; > > > + > > > +ret = avformat_transfer_internal_stream_timing_info(ofmt, > > > out_stream, in_stream, AVFMT_TBCF_AUTO); > > > +if (ret < 0) { > > > +fprintf(stderr, "Failed to copy stream timing info\n"); > > > goto end; > > > } > > > -out_stream->codec->codec_tag = 0; > > > -if (ofmt_ctx->oformat->flags & AVFMT_GLOBALHEADER) > > > -out_stream->codec->flags |= AV_CODEC_FLAG_GLOBAL_HEADER; > > > } > > > av_dump_format(ofmt_ctx, 0, out_filename, 1); > > > > > > @@ -127,8 +153,14 @@ int main(int argc, char **argv) > > > break; > > > > > > in_stream = ifmt_ctx->streams[pkt.stream_index]; > > > -out_stream = ofmt_ctx->streams[pkt.stream_index]; > > > +if (pkt.stream_index >= stream_mapping_size || > > > +stream_mapping[pkt.stream_index] < 0) { > > > +av_packet_unref(&pkt); > > > +continue; > > > +} > > > > > > +pkt.stream_index = stream_mapping[pkt.stream_index]; > > > +out_stream = ofmt_ctx->streams[pkt.stream_index]; > > > log_packet(ifmt_ctx, &a
[FFmpeg-devel] [PATCH] doc/examples/filtering_video: switch to new decoding API
--- doc/examples/filtering_video.c | 32 ++-- 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/doc/examples/filtering_video.c b/doc/examples/filtering_video.c index 15116d3881..b664c69f9d 100644 --- a/doc/examples/filtering_video.c +++ b/doc/examples/filtering_video.c @@ -211,6 +211,7 @@ int main(int argc, char **argv) { int ret; AVPacket packet; +int keep_packet = 0; AVFrame *frame = av_frame_alloc(); AVFrame *filt_frame = av_frame_alloc(); int got_frame; @@ -234,14 +235,30 @@ int main(int argc, char **argv) /* read all packets */ while (1) { -if ((ret = av_read_frame(fmt_ctx, &packet)) < 0) -break; +if (!keep_packet) { +if ((ret = av_read_frame(fmt_ctx, &packet)) < 0) +break; +keep_packet = 1; +} if (packet.stream_index == video_stream_index) { got_frame = 0; -ret = avcodec_decode_video2(dec_ctx, frame, &got_frame, &packet); -if (ret < 0) { -av_log(NULL, AV_LOG_ERROR, "Error decoding video\n"); + +ret = avcodec_send_packet(dec_ctx, &packet); +if (ret >= 0) { +keep_packet = 0; +} else if (ret != AVERROR(EAGAIN) && ret != AVERROR_EOF) { +av_log(NULL, AV_LOG_ERROR, "Error while sending a packet to the decoder\n"); +break; +} + +ret = avcodec_receive_frame(dec_ctx, frame); +if (ret >= 0) { +got_frame = 1; +} else if (ret == AVERROR_EOF) { +break; +} else if (ret != AVERROR(EAGAIN)) { +av_log(NULL, AV_LOG_ERROR, "Error while receiving a frame from the decoder\n"); break; } @@ -266,8 +283,11 @@ int main(int argc, char **argv) } av_frame_unref(frame); } +} else { +keep_packet = 0; } -av_packet_unref(&packet); +if (!keep_packet) + av_packet_unref(&packet); } end: avfilter_graph_free(&filter_graph); -- 2.12.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH] doc/examples/filtering_audio: switch to new decoding API
--- doc/examples/filtering_audio.c | 42 ++ 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/doc/examples/filtering_audio.c b/doc/examples/filtering_audio.c index c6a930ba8b..c62a1f6f62 100644 --- a/doc/examples/filtering_audio.c +++ b/doc/examples/filtering_audio.c @@ -216,7 +216,8 @@ static void print_frame(const AVFrame *frame) int main(int argc, char **argv) { int ret; -AVPacket packet0, packet; +AVPacket packet; +int keep_packet = 0; AVFrame *frame = av_frame_alloc(); AVFrame *filt_frame = av_frame_alloc(); int got_frame; @@ -239,28 +240,37 @@ int main(int argc, char **argv) goto end; /* read all packets */ -packet0.data = NULL; -packet.data = NULL; while (1) { -if (!packet0.data) { +if (!keep_packet) { if ((ret = av_read_frame(fmt_ctx, &packet)) < 0) break; -packet0 = packet; +keep_packet = 1; } if (packet.stream_index == audio_stream_index) { got_frame = 0; -ret = avcodec_decode_audio4(dec_ctx, frame, &got_frame, &packet); -if (ret < 0) { -av_log(NULL, AV_LOG_ERROR, "Error decoding audio\n"); -continue; + +ret = avcodec_send_packet(dec_ctx, &packet); +if (ret >= 0) { +keep_packet = 0; +} else if (ret != AVERROR(EAGAIN) && ret != AVERROR_EOF) { +av_log(NULL, AV_LOG_ERROR, "Error while sending a packet to the decoder\n"); +break; +} + +ret = avcodec_receive_frame(dec_ctx, frame); +if (ret >= 0) { +got_frame = 1; +} else if (ret == AVERROR_EOF) { +break; +} else if (ret != AVERROR(EAGAIN)) { +av_log(NULL, AV_LOG_ERROR, "Error while receiving a frame from the decoder\n"); +break; } -packet.size -= ret; -packet.data += ret; if (got_frame) { /* push the audio data from decoded frame into the filtergraph */ -if (av_buffersrc_add_frame_flags(buffersrc_ctx, frame, 0) < 0) { +if (av_buffersrc_add_frame_flags(buffersrc_ctx, frame, AV_BUFFERSRC_FLAG_KEEP_REF) < 0) { av_log(NULL, AV_LOG_ERROR, "Error while feeding the audio filtergraph\n"); break; } @@ -275,14 +285,14 @@ int main(int argc, char **argv) print_frame(filt_frame); av_frame_unref(filt_frame); } +av_frame_unref(frame); } - -if (packet.size <= 0) -av_packet_unref(&packet0); } else { /* discard non-wanted packets */ -av_packet_unref(&packet0); +keep_packet = 0; } +if (!keep_packet) + av_packet_unref(&packet); } end: avfilter_graph_free(&filter_graph); -- 2.12.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] doc/examples/filtering_video: switch to new decoding API
On Wed, Mar 29, 2017 at 3:37 PM, wm4 wrote: > On Wed, 29 Mar 2017 15:03:55 +0200 > Matthieu Bouron wrote: > > > --- > > doc/examples/filtering_video.c | 32 ++-- > > 1 file changed, 26 insertions(+), 6 deletions(-) > > > > diff --git a/doc/examples/filtering_video.c b/doc/examples/filtering_ > video.c > > index 15116d3881..b664c69f9d 100644 > > --- a/doc/examples/filtering_video.c > > +++ b/doc/examples/filtering_video.c > > @@ -211,6 +211,7 @@ int main(int argc, char **argv) > > { > > int ret; > > AVPacket packet; > > +int keep_packet = 0; > > AVFrame *frame = av_frame_alloc(); > > AVFrame *filt_frame = av_frame_alloc(); > > int got_frame; > > @@ -234,14 +235,30 @@ int main(int argc, char **argv) > > > > /* read all packets */ > > while (1) { > > -if ((ret = av_read_frame(fmt_ctx, &packet)) < 0) > > -break; > > +if (!keep_packet) { > > +if ((ret = av_read_frame(fmt_ctx, &packet)) < 0) > > +break; > > +keep_packet = 1; > > +} > > > > if (packet.stream_index == video_stream_index) { > > got_frame = 0; > > -ret = avcodec_decode_video2(dec_ctx, frame, &got_frame, > &packet); > > -if (ret < 0) { > > -av_log(NULL, AV_LOG_ERROR, "Error decoding video\n"); > > + > > +ret = avcodec_send_packet(dec_ctx, &packet); > > +if (ret >= 0) { > > +keep_packet = 0; > > +} else if (ret != AVERROR(EAGAIN) && ret != AVERROR_EOF) { > > If you have packets after the decoder entered the EOF state, you > probably want to discard them. Either that, or reset the decoder after > it's flushed and start over. Anyway, normally this shouldn't happen. > > You could also avoid the keep_packet business by running receive_frame > in a loop after send_packet (then send_packet can never fail with > EAGAIN). > > > +av_log(NULL, AV_LOG_ERROR, "Error while sending a > packet to the decoder\n"); > > +break; > > +} > > + > > +ret = avcodec_receive_frame(dec_ctx, frame); > > +if (ret >= 0) { > > +got_frame = 1; > > +} else if (ret == AVERROR_EOF) { > > +break; > > +} else if (ret != AVERROR(EAGAIN)) { > > +av_log(NULL, AV_LOG_ERROR, "Error while receiving a > frame from the decoder\n"); > > break; > > } > > > > @@ -266,8 +283,11 @@ int main(int argc, char **argv) > > } > > av_frame_unref(frame); > > } > > +} else { > > +keep_packet = 0; > > } > > -av_packet_unref(&packet); > > +if (!keep_packet) > > + av_packet_unref(&packet); > > } > > end: > > avfilter_graph_free(&filter_graph); > > Otherwise should work. > New patch attached (removing the keep_packet logic). From e9e5b3e679a12fdd9495c53177ade51c3dee7ba2 Mon Sep 17 00:00:00 2001 From: Matthieu Bouron Date: Wed, 29 Mar 2017 14:58:01 +0200 Subject: [PATCH] doc/examples/filtering_video: switch to new decoding API --- doc/examples/filtering_video.c | 46 +- 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/doc/examples/filtering_video.c b/doc/examples/filtering_video.c index 15116d3881..4d973024f1 100644 --- a/doc/examples/filtering_video.c +++ b/doc/examples/filtering_video.c @@ -213,7 +213,6 @@ int main(int argc, char **argv) AVPacket packet; AVFrame *frame = av_frame_alloc(); AVFrame *filt_frame = av_frame_alloc(); -int got_frame; if (!frame || !filt_frame) { perror("Could not allocate frame"); @@ -238,33 +237,42 @@ int main(int argc, char **argv) break; if (packet.stream_index == video_stream_index) { -got_frame = 0; -ret = avcodec_decode_video2(dec_ctx, frame, &got_frame, &packet); +ret = avcodec_send_packet(dec_ctx, &packet); if (ret < 0) { -av_log(NULL, AV_LOG_ERROR, "Error decoding video\n"); +av_log(NULL, AV_LOG_ERROR, "Error while sending a packet to the decoder\n"); break; } -if (got_frame) { -frame->pts = av_frame_
Re: [FFmpeg-devel] [PATCH] doc/examples/filtering_audio: switch to new decoding API
On Wed, Mar 29, 2017 at 04:31:47PM +0200, Matthieu Bouron wrote: > --- > doc/examples/filtering_audio.c | 42 > ++ > 1 file changed, 26 insertions(+), 16 deletions(-) > > diff --git a/doc/examples/filtering_audio.c b/doc/examples/filtering_audio.c > index c6a930ba8b..c62a1f6f62 100644 > --- a/doc/examples/filtering_audio.c > +++ b/doc/examples/filtering_audio.c > @@ -216,7 +216,8 @@ static void print_frame(const AVFrame *frame) > int main(int argc, char **argv) > { > int ret; > -AVPacket packet0, packet; > +AVPacket packet; > +int keep_packet = 0; > AVFrame *frame = av_frame_alloc(); > AVFrame *filt_frame = av_frame_alloc(); > int got_frame; > @@ -239,28 +240,37 @@ int main(int argc, char **argv) > goto end; > > /* read all packets */ > -packet0.data = NULL; > -packet.data = NULL; > while (1) { > -if (!packet0.data) { > +if (!keep_packet) { > if ((ret = av_read_frame(fmt_ctx, &packet)) < 0) > break; > -packet0 = packet; > +keep_packet = 1; > } > > if (packet.stream_index == audio_stream_index) { > got_frame = 0; > -ret = avcodec_decode_audio4(dec_ctx, frame, &got_frame, &packet); > -if (ret < 0) { > -av_log(NULL, AV_LOG_ERROR, "Error decoding audio\n"); > -continue; > + > +ret = avcodec_send_packet(dec_ctx, &packet); > +if (ret >= 0) { > +keep_packet = 0; > +} else if (ret != AVERROR(EAGAIN) && ret != AVERROR_EOF) { > +av_log(NULL, AV_LOG_ERROR, "Error while sending a packet to > the decoder\n"); > +break; > +} > + > +ret = avcodec_receive_frame(dec_ctx, frame); > +if (ret >= 0) { > +got_frame = 1; > +} else if (ret == AVERROR_EOF) { > +break; > +} else if (ret != AVERROR(EAGAIN)) { > +av_log(NULL, AV_LOG_ERROR, "Error while receiving a frame > from the decoder\n"); > +break; > } > -packet.size -= ret; > -packet.data += ret; > > if (got_frame) { > /* push the audio data from decoded frame into the > filtergraph */ > -if (av_buffersrc_add_frame_flags(buffersrc_ctx, frame, 0) < > 0) { > +if (av_buffersrc_add_frame_flags(buffersrc_ctx, frame, > AV_BUFFERSRC_FLAG_KEEP_REF) < 0) { > av_log(NULL, AV_LOG_ERROR, "Error while feeding the > audio filtergraph\n"); > break; > } > @@ -275,14 +285,14 @@ int main(int argc, char **argv) > print_frame(filt_frame); > av_frame_unref(filt_frame); > } > +av_frame_unref(frame); > } > - > -if (packet.size <= 0) > -av_packet_unref(&packet0); > } else { > /* discard non-wanted packets */ > -av_packet_unref(&packet0); > +keep_packet = 0; > } > +if (!keep_packet) > + av_packet_unref(&packet); > } > end: > avfilter_graph_free(&filter_graph); > -- > 2.12.0 > Patch applied (taking into account wm4 comments about porting the filtering_video example). ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] doc/examples/filtering_video: switch to new decoding API
On Thu, Mar 30, 2017 at 02:23:11PM +0200, wm4 wrote: > On Thu, 30 Mar 2017 13:35:47 +0200 > Matthieu Bouron wrote: > > > From e9e5b3e679a12fdd9495c53177ade51c3dee7ba2 Mon Sep 17 00:00:00 2001 > > From: Matthieu Bouron > > Date: Wed, 29 Mar 2017 14:58:01 +0200 > > Subject: [PATCH] doc/examples/filtering_video: switch to new decoding API > > > > --- > > doc/examples/filtering_video.c | 46 > > +- > > 1 file changed, 27 insertions(+), 19 deletions(-) > > > > diff --git a/doc/examples/filtering_video.c b/doc/examples/filtering_video.c > > index 15116d3881..4d973024f1 100644 > > --- a/doc/examples/filtering_video.c > > +++ b/doc/examples/filtering_video.c > > @@ -213,7 +213,6 @@ int main(int argc, char **argv) > > AVPacket packet; > > AVFrame *frame = av_frame_alloc(); > > AVFrame *filt_frame = av_frame_alloc(); > > -int got_frame; > > > > if (!frame || !filt_frame) { > > perror("Could not allocate frame"); > > @@ -238,33 +237,42 @@ int main(int argc, char **argv) > > break; > > > > if (packet.stream_index == video_stream_index) { > > -got_frame = 0; > > -ret = avcodec_decode_video2(dec_ctx, frame, &got_frame, > > &packet); > > +ret = avcodec_send_packet(dec_ctx, &packet); > > I assume the "flush" packet makes it to this code as well... > > > if (ret < 0) { > > -av_log(NULL, AV_LOG_ERROR, "Error decoding video\n"); > > +av_log(NULL, AV_LOG_ERROR, "Error while sending a packet > > to the decoder\n"); > > break; > > } > > > > -if (got_frame) { > > -frame->pts = av_frame_get_best_effort_timestamp(frame); > > - > > -/* push the decoded frame into the filtergraph */ > > -if (av_buffersrc_add_frame_flags(buffersrc_ctx, frame, > > AV_BUFFERSRC_FLAG_KEEP_REF) < 0) { > > -av_log(NULL, AV_LOG_ERROR, "Error while feeding the > > filtergraph\n"); > > +while (ret >= 0) { > > +ret = avcodec_receive_frame(dec_ctx, frame); > > +if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) { > > break; > > On EOF this assumes the demuxer takes care of it, and if the demuxer is > unexpectedly not EOF, the send call will error. So LGTM. > > > +} else if (ret < 0) { > > +av_log(NULL, AV_LOG_ERROR, "Error while receiving a > > frame from the decoder\n"); > > +goto end; > > } > > > > -/* pull filtered frames from the filtergraph */ > > -while (1) { > > -ret = av_buffersink_get_frame(buffersink_ctx, > > filt_frame); > > -if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) > > +if (ret >= 0) { > > +frame->pts = av_frame_get_best_effort_timestamp(frame); > > + > > +/* push the decoded frame into the filtergraph */ > > +if (av_buffersrc_add_frame_flags(buffersrc_ctx, frame, > > AV_BUFFERSRC_FLAG_KEEP_REF) < 0) { > > +av_log(NULL, AV_LOG_ERROR, "Error while feeding > > the filtergraph\n"); > > break; > > -if (ret < 0) > > -goto end; > > -display_frame(filt_frame, > > buffersink_ctx->inputs[0]->time_base); > > -av_frame_unref(filt_frame); > > +} > > + > > +/* pull filtered frames from the filtergraph */ > > +while (1) { > > +ret = av_buffersink_get_frame(buffersink_ctx, > > filt_frame); > > +if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) > > +break; > > +if (ret < 0) > > +goto end; > > +display_frame(filt_frame, > > buffersink_ctx->inputs[0]->time_base); > > +av_frame_unref(filt_frame); > > +} > > +av_frame_unref(frame); > > } > > -av_frame_unref(frame); > > } > > } > > av_packet_unref(&packet); > > LGTM. Patch applied. > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 3/3] doc/examples/extract_mvs: re-indent after previous commit
--- doc/examples/extract_mvs.c | 56 +++--- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/doc/examples/extract_mvs.c b/doc/examples/extract_mvs.c index 552a7334cf..7ae934ead3 100644 --- a/doc/examples/extract_mvs.c +++ b/doc/examples/extract_mvs.c @@ -35,40 +35,40 @@ static int video_frame_count = 0; static int decode_packet(const AVPacket *pkt) { -int ret = avcodec_send_packet(video_dec_ctx, pkt); -if (ret < 0) { -fprintf(stderr, "Error while sending a packet to the decoder: %s\n", av_err2str(ret)); +int ret = avcodec_send_packet(video_dec_ctx, pkt); +if (ret < 0) { +fprintf(stderr, "Error while sending a packet to the decoder: %s\n", av_err2str(ret)); +return ret; +} + +while (ret >= 0) { +ret = avcodec_receive_frame(video_dec_ctx, frame); +if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) { +break; +} else if (ret < 0) { +fprintf(stderr, "Error while receiving a frame from the decoder: %s\n", av_err2str(ret)); return ret; } -while (ret >= 0) { -ret = avcodec_receive_frame(video_dec_ctx, frame); -if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) { -break; -} else if (ret < 0) { -fprintf(stderr, "Error while receiving a frame from the decoder: %s\n", av_err2str(ret)); -return ret; -} - -if (ret >= 0) { -int i; -AVFrameSideData *sd; - -video_frame_count++; -sd = av_frame_get_side_data(frame, AV_FRAME_DATA_MOTION_VECTORS); -if (sd) { -const AVMotionVector *mvs = (const AVMotionVector *)sd->data; -for (i = 0; i < sd->size / sizeof(*mvs); i++) { -const AVMotionVector *mv = &mvs[i]; -printf("%d,%2d,%2d,%2d,%4d,%4d,%4d,%4d,0x%"PRIx64"\n", -video_frame_count, mv->source, -mv->w, mv->h, mv->src_x, mv->src_y, -mv->dst_x, mv->dst_y, mv->flags); -} +if (ret >= 0) { +int i; +AVFrameSideData *sd; + +video_frame_count++; +sd = av_frame_get_side_data(frame, AV_FRAME_DATA_MOTION_VECTORS); +if (sd) { +const AVMotionVector *mvs = (const AVMotionVector *)sd->data; +for (i = 0; i < sd->size / sizeof(*mvs); i++) { +const AVMotionVector *mv = &mvs[i]; +printf("%d,%2d,%2d,%2d,%4d,%4d,%4d,%4d,0x%"PRIx64"\n", +video_frame_count, mv->source, +mv->w, mv->h, mv->src_x, mv->src_y, +mv->dst_x, mv->dst_y, mv->flags); } -av_frame_unref(frame); } +av_frame_unref(frame); } +} return 0; } -- 2.12.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 1/3] doc/examples/extract_mvs: switch to new decoding API
--- doc/examples/extract_mvs.c | 72 ++ 1 file changed, 35 insertions(+), 37 deletions(-) diff --git a/doc/examples/extract_mvs.c b/doc/examples/extract_mvs.c index 8b22b40c11..d6730db3a2 100644 --- a/doc/examples/extract_mvs.c +++ b/doc/examples/extract_mvs.c @@ -34,39 +34,46 @@ static AVFrame *frame = NULL; static AVPacket pkt; static int video_frame_count = 0; -static int decode_packet(int *got_frame, int cached) +static int decode_packet(void) { -int decoded = pkt.size; - -*got_frame = 0; - if (pkt.stream_index == video_stream_idx) { -int ret = avcodec_decode_video2(video_dec_ctx, frame, got_frame, &pkt); +int ret = avcodec_send_packet(video_dec_ctx, &pkt); if (ret < 0) { -fprintf(stderr, "Error decoding video frame (%s)\n", av_err2str(ret)); +fprintf(stderr, "Error while sending a packet to the decoder: %s\n", av_err2str(ret)); return ret; } -if (*got_frame) { -int i; -AVFrameSideData *sd; - -video_frame_count++; -sd = av_frame_get_side_data(frame, AV_FRAME_DATA_MOTION_VECTORS); -if (sd) { -const AVMotionVector *mvs = (const AVMotionVector *)sd->data; -for (i = 0; i < sd->size / sizeof(*mvs); i++) { -const AVMotionVector *mv = &mvs[i]; -printf("%d,%2d,%2d,%2d,%4d,%4d,%4d,%4d,0x%"PRIx64"\n", - video_frame_count, mv->source, - mv->w, mv->h, mv->src_x, mv->src_y, - mv->dst_x, mv->dst_y, mv->flags); +while (ret >= 0) { +ret = avcodec_receive_frame(video_dec_ctx, frame); +if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) { +break; +} else if (ret < 0) { +fprintf(stderr, "Error while receiving a frame from the decoder: %s\n", av_err2str(ret)); +return ret; +} + +if (ret >= 0) { +int i; +AVFrameSideData *sd; + +video_frame_count++; +sd = av_frame_get_side_data(frame, AV_FRAME_DATA_MOTION_VECTORS); +if (sd) { +const AVMotionVector *mvs = (const AVMotionVector *)sd->data; +for (i = 0; i < sd->size / sizeof(*mvs); i++) { +const AVMotionVector *mv = &mvs[i]; +printf("%d,%2d,%2d,%2d,%4d,%4d,%4d,%4d,0x%"PRIx64"\n", +video_frame_count, mv->source, +mv->w, mv->h, mv->src_x, mv->src_y, +mv->dst_x, mv->dst_y, mv->flags); +} } +av_frame_unref(frame); } } } -return decoded; +return 0; } static int open_codec_context(AVFormatContext *fmt_ctx, enum AVMediaType type) @@ -116,7 +123,7 @@ static int open_codec_context(AVFormatContext *fmt_ctx, enum AVMediaType type) int main(int argc, char **argv) { -int ret = 0, got_frame; +int ret = 0; if (argc != 2) { fprintf(stderr, "Usage: %s \n", argv[0]); @@ -157,28 +164,19 @@ int main(int argc, char **argv) /* initialize packet, set data to NULL, let the demuxer fill it */ av_init_packet(&pkt); -pkt.data = NULL; -pkt.size = 0; /* read frames from the file */ while (av_read_frame(fmt_ctx, &pkt) >= 0) { -AVPacket orig_pkt = pkt; -do { -ret = decode_packet(&got_frame, 0); -if (ret < 0) -break; -pkt.data += ret; -pkt.size -= ret; -} while (pkt.size > 0); -av_packet_unref(&orig_pkt); +ret = decode_packet(); +av_packet_unref(&pkt); +if (ret < 0) +break; } /* flush cached frames */ pkt.data = NULL; pkt.size = 0; -do { -decode_packet(&got_frame, 1); -} while (got_frame); +decode_packet(); end: avcodec_free_context(&video_dec_ctx); -- 2.12.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 2/3] doc/examples/extract_mvs: make pkt local to the main function
--- doc/examples/extract_mvs.c | 18 ++ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/doc/examples/extract_mvs.c b/doc/examples/extract_mvs.c index d6730db3a2..552a7334cf 100644 --- a/doc/examples/extract_mvs.c +++ b/doc/examples/extract_mvs.c @@ -31,13 +31,11 @@ static const char *src_filename = NULL; static int video_stream_idx = -1; static AVFrame *frame = NULL; -static AVPacket pkt; static int video_frame_count = 0; -static int decode_packet(void) +static int decode_packet(const AVPacket *pkt) { -if (pkt.stream_index == video_stream_idx) { -int ret = avcodec_send_packet(video_dec_ctx, &pkt); +int ret = avcodec_send_packet(video_dec_ctx, pkt); if (ret < 0) { fprintf(stderr, "Error while sending a packet to the decoder: %s\n", av_err2str(ret)); return ret; @@ -71,7 +69,6 @@ static int decode_packet(void) av_frame_unref(frame); } } -} return 0; } @@ -124,6 +121,7 @@ static int open_codec_context(AVFormatContext *fmt_ctx, enum AVMediaType type) int main(int argc, char **argv) { int ret = 0; +AVPacket pkt = { 0 }; if (argc != 2) { fprintf(stderr, "Usage: %s \n", argv[0]); @@ -162,21 +160,17 @@ int main(int argc, char **argv) printf("framenum,source,blockw,blockh,srcx,srcy,dstx,dsty,flags\n"); -/* initialize packet, set data to NULL, let the demuxer fill it */ -av_init_packet(&pkt); - /* read frames from the file */ while (av_read_frame(fmt_ctx, &pkt) >= 0) { -ret = decode_packet(); +if (pkt.stream_index == video_stream_idx) +ret = decode_packet(&pkt); av_packet_unref(&pkt); if (ret < 0) break; } /* flush cached frames */ -pkt.data = NULL; -pkt.size = 0; -decode_packet(); +decode_packet(NULL); end: avcodec_free_context(&video_dec_ctx); -- 2.12.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 1/2] lavc/mediacodecdec: switch to AV_CODEC_CAP_DELAY
--- libavcodec/mediacodecdec.c | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libavcodec/mediacodecdec.c b/libavcodec/mediacodecdec.c index 79a51ec684..4cbec09acd 100644 --- a/libavcodec/mediacodecdec.c +++ b/libavcodec/mediacodecdec.c @@ -552,7 +552,7 @@ AVCodec ff_h264_mediacodec_decoder = { .decode = mediacodec_decode_frame, .flush = mediacodec_decode_flush, .close = mediacodec_decode_close, -.capabilities = CODEC_CAP_DELAY, +.capabilities = AV_CODEC_CAP_DELAY, .caps_internal = FF_CODEC_CAP_SETS_PKT_DTS, }; #endif @@ -568,7 +568,7 @@ AVCodec ff_hevc_mediacodec_decoder = { .decode = mediacodec_decode_frame, .flush = mediacodec_decode_flush, .close = mediacodec_decode_close, -.capabilities = CODEC_CAP_DELAY, +.capabilities = AV_CODEC_CAP_DELAY, .caps_internal = FF_CODEC_CAP_SETS_PKT_DTS, }; #endif @@ -584,7 +584,7 @@ AVCodec ff_mpeg4_mediacodec_decoder = { .decode = mediacodec_decode_frame, .flush = mediacodec_decode_flush, .close = mediacodec_decode_close, -.capabilities = CODEC_CAP_DELAY, +.capabilities = AV_CODEC_CAP_DELAY, .caps_internal = FF_CODEC_CAP_SETS_PKT_DTS, }; #endif @@ -600,7 +600,7 @@ AVCodec ff_vp8_mediacodec_decoder = { .decode = mediacodec_decode_frame, .flush = mediacodec_decode_flush, .close = mediacodec_decode_close, -.capabilities = CODEC_CAP_DELAY, +.capabilities = AV_CODEC_CAP_DELAY, .caps_internal = FF_CODEC_CAP_SETS_PKT_DTS, }; #endif @@ -616,7 +616,7 @@ AVCodec ff_vp9_mediacodec_decoder = { .decode = mediacodec_decode_frame, .flush = mediacodec_decode_flush, .close = mediacodec_decode_close, -.capabilities = CODEC_CAP_DELAY, +.capabilities = AV_CODEC_CAP_DELAY, .caps_internal = FF_CODEC_CAP_SETS_PKT_DTS, }; #endif -- 2.12.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 2/2] lavc/mediacodecdec: set AV_CODEC_CAP_AVOID_PROBING capability
--- libavcodec/mediacodecdec.c | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libavcodec/mediacodecdec.c b/libavcodec/mediacodecdec.c index 4cbec09acd..857e7a5fed 100644 --- a/libavcodec/mediacodecdec.c +++ b/libavcodec/mediacodecdec.c @@ -552,7 +552,7 @@ AVCodec ff_h264_mediacodec_decoder = { .decode = mediacodec_decode_frame, .flush = mediacodec_decode_flush, .close = mediacodec_decode_close, -.capabilities = AV_CODEC_CAP_DELAY, +.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AVOID_PROBING, .caps_internal = FF_CODEC_CAP_SETS_PKT_DTS, }; #endif @@ -568,7 +568,7 @@ AVCodec ff_hevc_mediacodec_decoder = { .decode = mediacodec_decode_frame, .flush = mediacodec_decode_flush, .close = mediacodec_decode_close, -.capabilities = AV_CODEC_CAP_DELAY, +.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AVOID_PROBING, .caps_internal = FF_CODEC_CAP_SETS_PKT_DTS, }; #endif @@ -584,7 +584,7 @@ AVCodec ff_mpeg4_mediacodec_decoder = { .decode = mediacodec_decode_frame, .flush = mediacodec_decode_flush, .close = mediacodec_decode_close, -.capabilities = AV_CODEC_CAP_DELAY, +.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AVOID_PROBING, .caps_internal = FF_CODEC_CAP_SETS_PKT_DTS, }; #endif @@ -600,7 +600,7 @@ AVCodec ff_vp8_mediacodec_decoder = { .decode = mediacodec_decode_frame, .flush = mediacodec_decode_flush, .close = mediacodec_decode_close, -.capabilities = AV_CODEC_CAP_DELAY, +.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AVOID_PROBING, .caps_internal = FF_CODEC_CAP_SETS_PKT_DTS, }; #endif @@ -616,7 +616,7 @@ AVCodec ff_vp9_mediacodec_decoder = { .decode = mediacodec_decode_frame, .flush = mediacodec_decode_flush, .close = mediacodec_decode_close, -.capabilities = AV_CODEC_CAP_DELAY, +.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AVOID_PROBING, .caps_internal = FF_CODEC_CAP_SETS_PKT_DTS, }; #endif -- 2.12.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 2/2] lavc/mediacodecdec: set AV_CODEC_CAP_AVOID_PROBING capability
On Tue, Apr 04, 2017 at 09:31:14AM +0200, wm4 wrote: > On Tue, 4 Apr 2017 09:21:00 +0200 > Matthieu Bouron wrote: > > > --- > > libavcodec/mediacodecdec.c | 10 +- > > 1 file changed, 5 insertions(+), 5 deletions(-) > > > > Both patches LGTM. Applied. Thanks for the review. Matthieu [...] ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 3/3] doc/examples/extract_mvs: re-indent after previous commit
On Mon, Apr 03, 2017 at 04:33:57PM +0200, Matthieu Bouron wrote: > --- > doc/examples/extract_mvs.c | 56 > +++--- > 1 file changed, 28 insertions(+), 28 deletions(-) > > diff --git a/doc/examples/extract_mvs.c b/doc/examples/extract_mvs.c > index 552a7334cf..7ae934ead3 100644 > --- a/doc/examples/extract_mvs.c > +++ b/doc/examples/extract_mvs.c > @@ -35,40 +35,40 @@ static int video_frame_count = 0; > > static int decode_packet(const AVPacket *pkt) > { > -int ret = avcodec_send_packet(video_dec_ctx, pkt); > -if (ret < 0) { > -fprintf(stderr, "Error while sending a packet to the decoder: > %s\n", av_err2str(ret)); > +int ret = avcodec_send_packet(video_dec_ctx, pkt); > +if (ret < 0) { > +fprintf(stderr, "Error while sending a packet to the decoder: %s\n", > av_err2str(ret)); > +return ret; > +} > + > +while (ret >= 0) { > +ret = avcodec_receive_frame(video_dec_ctx, frame); > +if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) { > +break; > +} else if (ret < 0) { > +fprintf(stderr, "Error while receiving a frame from the decoder: > %s\n", av_err2str(ret)); > return ret; > } > > -while (ret >= 0) { > -ret = avcodec_receive_frame(video_dec_ctx, frame); > -if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) { > -break; > -} else if (ret < 0) { > -fprintf(stderr, "Error while receiving a frame from the > decoder: %s\n", av_err2str(ret)); > -return ret; > -} > - > -if (ret >= 0) { > -int i; > -AVFrameSideData *sd; > - > -video_frame_count++; > -sd = av_frame_get_side_data(frame, > AV_FRAME_DATA_MOTION_VECTORS); > -if (sd) { > -const AVMotionVector *mvs = (const AVMotionVector > *)sd->data; > -for (i = 0; i < sd->size / sizeof(*mvs); i++) { > -const AVMotionVector *mv = &mvs[i]; > - > printf("%d,%2d,%2d,%2d,%4d,%4d,%4d,%4d,0x%"PRIx64"\n", > -video_frame_count, mv->source, > -mv->w, mv->h, mv->src_x, mv->src_y, > -mv->dst_x, mv->dst_y, mv->flags); > -} > +if (ret >= 0) { > +int i; > +AVFrameSideData *sd; > + > +video_frame_count++; > +sd = av_frame_get_side_data(frame, AV_FRAME_DATA_MOTION_VECTORS); > +if (sd) { > +const AVMotionVector *mvs = (const AVMotionVector *)sd->data; > +for (i = 0; i < sd->size / sizeof(*mvs); i++) { > +const AVMotionVector *mv = &mvs[i]; > +printf("%d,%2d,%2d,%2d,%4d,%4d,%4d,%4d,0x%"PRIx64"\n", > +video_frame_count, mv->source, > +mv->w, mv->h, mv->src_x, mv->src_y, > +mv->dst_x, mv->dst_y, mv->flags); > } > -av_frame_unref(frame); > } > +av_frame_unref(frame); > } > +} > > return 0; > } > -- > 2.12.0 > Patchset applied (reviewed by Clément). Matthieu [...] ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH] lavc/aarch64/simple_idct: fix macro parameter escaping
Untested: fixes ticket #6324. --- libavcodec/aarch64/simple_idct_neon.S | 42 +-- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/libavcodec/aarch64/simple_idct_neon.S b/libavcodec/aarch64/simple_idct_neon.S index 52273420f9..fa43bcfb01 100644 --- a/libavcodec/aarch64/simple_idct_neon.S +++ b/libavcodec/aarch64/simple_idct_neon.S @@ -74,21 +74,21 @@ endconst .endm .macro idct_col4_top y1 y2 y3 y4 i l -smull\i v7.4S, \y3\().\l, z2 -smull\i v16.4S, \y3\().\l, z6 -smull\i v17.4S, \y2\().\l, z1 +smull\i v7.4S, \y3\().\l\(), z2 +smull\i v16.4S, \y3\().\l\(), z6 +smull\i v17.4S, \y2\().\l\(), z1 add v19.4S, v23.4S, v7.4S -smull\i v18.4S, \y2\().\l, z3 +smull\i v18.4S, \y2\().\l\(), z3 add v20.4S, v23.4S, v16.4S -smull\i v5.4S, \y2\().\l, z5 +smull\i v5.4S, \y2\().\l\(), z5 sub v21.4S, v23.4S, v16.4S -smull\i v6.4S, \y2\().\l, z7 +smull\i v6.4S, \y2\().\l\(), z7 sub v22.4S, v23.4S, v7.4S -smlal\i v17.4S, \y4\().\l, z3 -smlsl\i v18.4S, \y4\().\l, z7 -smlsl\i v5.4S, \y4\().\l, z1 -smlsl\i v6.4S, \y4\().\l, z5 +smlal\i v17.4S, \y4\().\l\(), z3 +smlsl\i v18.4S, \y4\().\l\(), z7 +smlsl\i v5.4S, \y4\().\l\(), z1 +smlsl\i v6.4S, \y4\().\l\(), z5 .endm .macro idct_row4_neon y1 y2 y3 y4 pass @@ -171,7 +171,7 @@ function idct_col4_neon\i cmp x4, #0 beq 1f -smull\i v7.4S, v28.\l, z4 +smull\i v7.4S, v28.\l\(), z4 add v19.4S, v19.4S, v7.4S sub v20.4S, v20.4S, v7.4S sub v21.4S, v21.4S, v7.4S @@ -181,17 +181,17 @@ function idct_col4_neon\i cmp x5, #0 beq 2f -smlal\i v17.4S, v29.\l, z5 -smlsl\i v18.4S, v29.\l, z1 -smlal\i v5.4S, v29.\l, z7 -smlal\i v6.4S, v29.\l, z3 +smlal\i v17.4S, v29.\l\(), z5 +smlsl\i v18.4S, v29.\l\(), z1 +smlal\i v5.4S, v29.\l\(), z7 +smlal\i v6.4S, v29.\l\(), z3 2: mov x5, v31.D[\i - 1] cmp x4, #0 beq 3f -smull\i v7.4S, v30.\l, z6 -smull\i v16.4S, v30.\l, z2 +smull\i v7.4S, v30.\l\(), z6 +smull\i v16.4S, v30.\l\(), z2 add v19.4S, v19.4S, v7.4S sub v22.4S, v22.4S, v7.4S sub v20.4S, v20.4S, v16.4S @@ -200,10 +200,10 @@ function idct_col4_neon\i 3: cmp x5, #0 beq 4f -smlal\i v17.4S, v31.\l, z7 -smlsl\i v18.4S, v31.\l, z5 -smlal\i v5.4S, v31.\l, z3 -smlsl\i v6.4S, v31.\l, z1 +smlal\i v17.4S, v31.\l\(), z7 +smlsl\i v18.4S, v31.\l\(), z5 +smlal\i v5.4S, v31.\l\(), z3 +smlsl\i v6.4S, v31.\l\(), z1 4: addhn v7.4H, v19.4S, v17.4S addhn2 v7.8H, v20.4S, v18.4S -- 2.12.2 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] lavc/aarch64/simple_idct: fix macro parameter escaping
On Fri, Apr 28, 2017 at 4:53 PM, Matthieu Bouron wrote: > Untested: fixes ticket #6324. > --- > libavcodec/aarch64/simple_idct_neon.S | 42 +- > - > 1 file changed, 21 insertions(+), 21 deletions(-) > > diff --git a/libavcodec/aarch64/simple_idct_neon.S > b/libavcodec/aarch64/simple_idct_neon.S > index 52273420f9..fa43bcfb01 100644 > --- a/libavcodec/aarch64/simple_idct_neon.S > +++ b/libavcodec/aarch64/simple_idct_neon.S > @@ -74,21 +74,21 @@ endconst > .endm > > .macro idct_col4_top y1 y2 y3 y4 i l > -smull\i v7.4S, \y3\().\l, z2 > -smull\i v16.4S, \y3\().\l, z6 > -smull\i v17.4S, \y2\().\l, z1 > +smull\i v7.4S, \y3\().\l\(), z2 > +smull\i v16.4S, \y3\().\l\(), z6 > +smull\i v17.4S, \y2\().\l\(), z1 > add v19.4S, v23.4S, v7.4S > -smull\i v18.4S, \y2\().\l, z3 > +smull\i v18.4S, \y2\().\l\(), z3 > add v20.4S, v23.4S, v16.4S > -smull\i v5.4S, \y2\().\l, z5 > +smull\i v5.4S, \y2\().\l\(), z5 > sub v21.4S, v23.4S, v16.4S > -smull\i v6.4S, \y2\().\l, z7 > +smull\i v6.4S, \y2\().\l\(), z7 > sub v22.4S, v23.4S, v7.4S > > -smlal\i v17.4S, \y4\().\l, z3 > -smlsl\i v18.4S, \y4\().\l, z7 > -smlsl\i v5.4S, \y4\().\l, z1 > -smlsl\i v6.4S, \y4\().\l, z5 > +smlal\i v17.4S, \y4\().\l\(), z3 > +smlsl\i v18.4S, \y4\().\l\(), z7 > +smlsl\i v5.4S, \y4\().\l\(), z1 > +smlsl\i v6.4S, \y4\().\l\(), z5 > .endm > > .macro idct_row4_neon y1 y2 y3 y4 pass > @@ -171,7 +171,7 @@ function idct_col4_neon\i > cmp x4, #0 > beq 1f > > -smull\i v7.4S, v28.\l, z4 > +smull\i v7.4S, v28.\l\(), z4 > add v19.4S, v19.4S, v7.4S > sub v20.4S, v20.4S, v7.4S > sub v21.4S, v21.4S, v7.4S > @@ -181,17 +181,17 @@ function idct_col4_neon\i > cmp x5, #0 > beq 2f > > -smlal\i v17.4S, v29.\l, z5 > -smlsl\i v18.4S, v29.\l, z1 > -smlal\i v5.4S, v29.\l, z7 > -smlal\i v6.4S, v29.\l, z3 > +smlal\i v17.4S, v29.\l\(), z5 > +smlsl\i v18.4S, v29.\l\(), z1 > +smlal\i v5.4S, v29.\l\(), z7 > +smlal\i v6.4S, v29.\l\(), z3 > > 2: mov x5, v31.D[\i - 1] > cmp x4, #0 > beq 3f > > -smull\i v7.4S, v30.\l, z6 > -smull\i v16.4S, v30.\l, z2 > +smull\i v7.4S, v30.\l\(), z6 > +smull\i v16.4S, v30.\l\(), z2 > add v19.4S, v19.4S, v7.4S > sub v22.4S, v22.4S, v7.4S > sub v20.4S, v20.4S, v16.4S > @@ -200,10 +200,10 @@ function idct_col4_neon\i > 3: cmp x5, #0 > beq 4f > > -smlal\i v17.4S, v31.\l, z7 > -smlsl\i v18.4S, v31.\l, z5 > -smlal\i v5.4S, v31.\l, z3 > -smlsl\i v6.4S, v31.\l, z1 > +smlal\i v17.4S, v31.\l\(), z7 > +smlsl\i v18.4S, v31.\l\(), z5 > +smlal\i v5.4S, v31.\l\(), z3 > +smlsl\i v6.4S, v31.\l\(), z1 > > 4: addhn v7.4H, v19.4S, v17.4S > addhn2 v7.8H, v20.4S, v18.4S > -- > 2.12.2 > > Please discard this patch as it does not fix the mentioned trac ticket (which is in fact invalid). Sorry for the noise, Matthieu ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH] lavc/aarch64/simple_idct: separate macro arguments with commas
Untested: fixes ticket #6324. --- libavcodec/aarch64/simple_idct_neon.S | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libavcodec/aarch64/simple_idct_neon.S b/libavcodec/aarch64/simple_idct_neon.S index 52273420f9..d31f72a609 100644 --- a/libavcodec/aarch64/simple_idct_neon.S +++ b/libavcodec/aarch64/simple_idct_neon.S @@ -61,19 +61,19 @@ endconst br x10 .endm -.macro smull1 a b c +.macro smull1 a, b, c smull \a, \b, \c .endm -.macro smlal1 a b c +.macro smlal1 a, b, c smlal \a, \b, \c .endm -.macro smlsl1 a b c +.macro smlsl1 a, b, c smlsl \a, \b, \c .endm -.macro idct_col4_top y1 y2 y3 y4 i l +.macro idct_col4_top y1, y2, y3, y4, i, l smull\i v7.4S, \y3\().\l, z2 smull\i v16.4S, \y3\().\l, z6 smull\i v17.4S, \y2\().\l, z1 @@ -91,7 +91,7 @@ endconst smlsl\i v6.4S, \y4\().\l, z5 .endm -.macro idct_row4_neon y1 y2 y3 y4 pass +.macro idct_row4_neon y1, y2, y3, y4, pass ld1 {\y1\().2D-\y2\().2D}, [x2], #32 moviv23.4S, #1<<2, lsl #8 orr v5.16B, \y1\().16B, \y2\().16B @@ -153,7 +153,7 @@ endconst trn2\y4\().4S, v17.4S, v19.4S .endm -.macro declare_idct_col4_neon i l +.macro declare_idct_col4_neon i, l function idct_col4_neon\i dup v23.4H, z4c .if \i == 1 -- 2.12.2 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] lavc/aarch64/simple_idct: separate macro arguments with commas
Le 2 mai 2017 12:01 PM, "Benoit Fouet" a écrit : Hi, On 28/04/2017 21:58, Matthieu Bouron wrote: > Untested: fixes ticket #6324. > --- > libavcodec/aarch64/simple_idct_neon.S | 12 ++-- > 1 file changed, 6 insertions(+), 6 deletions(-) > > diff --git a/libavcodec/aarch64/simple_idct_neon.S b/libavcodec/aarch64/simple_idct_neon.S > index 52273420f9..d31f72a609 100644 > --- a/libavcodec/aarch64/simple_idct_neon.S > +++ b/libavcodec/aarch64/simple_idct_neon.S > @@ -61,19 +61,19 @@ endconst > br x10 > .endm > > -.macro smull1 a b c > +.macro smull1 a, b, c > smull \a, \b, \c > .endm > > -.macro smlal1 a b c > +.macro smlal1 a, b, c > smlal \a, \b, \c > .endm > > -.macro smlsl1 a b c > +.macro smlsl1 a, b, c > smlsl \a, \b, \c > .endm > > -.macro idct_col4_top y1 y2 y3 y4 i l > +.macro idct_col4_top y1, y2, y3, y4, i, l > smull\i v7.4S, \y3\().\l, z2 > smull\i v16.4S, \y3\().\l, z6 > smull\i v17.4S, \y2\().\l, z1 > @@ -91,7 +91,7 @@ endconst > smlsl\i v6.4S, \y4\().\l, z5 > .endm > > -.macro idct_row4_neon y1 y2 y3 y4 pass > +.macro idct_row4_neon y1, y2, y3, y4, pass > ld1 {\y1\().2D-\y2\().2D}, [x2], #32 > moviv23.4S, #1<<2, lsl #8 > orr v5.16B, \y1\().16B, \y2\().16B > @@ -153,7 +153,7 @@ endconst > trn2\y4\().4S, v17.4S, v19.4S > .endm > > -.macro declare_idct_col4_neon i l > +.macro declare_idct_col4_neon i, l > function idct_col4_neon\i > dup v23.4H, z4c > .if \i == 1 Sounds sane, but shouldn't we be doing this for all instances of multiple arguments macros without commas? Sure, I may have missed some. I will work again on this patch on Tuesday as I will have access to an apple machine (and hopefully fix the build without gas-preprocessor). Sorry for the delay, Matthieu Thanks -- Ben ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] lavc/aarch64/simple_idct: separate macro arguments with commas
On Sun, May 7, 2017 at 11:05 AM, Matthieu Bouron wrote: > > > Le 2 mai 2017 12:01 PM, "Benoit Fouet" a écrit : > > Hi, > > > On 28/04/2017 21:58, Matthieu Bouron wrote: > > Untested: fixes ticket #6324. > > --- > > libavcodec/aarch64/simple_idct_neon.S | 12 ++-- > > 1 file changed, 6 insertions(+), 6 deletions(-) > > > > diff --git a/libavcodec/aarch64/simple_idct_neon.S > b/libavcodec/aarch64/simple_idct_neon.S > > index 52273420f9..d31f72a609 100644 > > --- a/libavcodec/aarch64/simple_idct_neon.S > > +++ b/libavcodec/aarch64/simple_idct_neon.S > > @@ -61,19 +61,19 @@ endconst > > br x10 > > .endm > > > > -.macro smull1 a b c > > +.macro smull1 a, b, c > > smull \a, \b, \c > > .endm > > > > -.macro smlal1 a b c > > +.macro smlal1 a, b, c > > smlal \a, \b, \c > > .endm > > > > -.macro smlsl1 a b c > > +.macro smlsl1 a, b, c > > smlsl \a, \b, \c > > .endm > > > > -.macro idct_col4_top y1 y2 y3 y4 i l > > +.macro idct_col4_top y1, y2, y3, y4, i, l > > smull\i v7.4S, \y3\().\l, z2 > > smull\i v16.4S, \y3\().\l, z6 > > smull\i v17.4S, \y2\().\l, z1 > > @@ -91,7 +91,7 @@ endconst > > smlsl\i v6.4S, \y4\().\l, z5 > > .endm > > > > -.macro idct_row4_neon y1 y2 y3 y4 pass > > +.macro idct_row4_neon y1, y2, y3, y4, pass > > ld1 {\y1\().2D-\y2\().2D}, [x2], #32 > > moviv23.4S, #1<<2, lsl #8 > > orr v5.16B, \y1\().16B, \y2\().16B > > @@ -153,7 +153,7 @@ endconst > > trn2\y4\().4S, v17.4S, v19.4S > > .endm > > > > -.macro declare_idct_col4_neon i l > > +.macro declare_idct_col4_neon i, l > > function idct_col4_neon\i > > dup v23.4H, z4c > > .if \i == 1 > > Sounds sane, but shouldn't we be doing this for all instances of > multiple arguments macros without commas? > > > Sure, I may have missed some. I will work again on this patch on Tuesday > as I will have access to an apple machine (and hopefully fix the build > without gas-preprocessor). > > Sorry for the delay, > Matthieu > > Updated patch attached: * add missing commas to separate macro arguments * passes .4H/.8H as macro arguments instead of .4H/.8H (the later form being interpreted as an hexadecimal value, ie: 4/8). From e27ac0f3a8b6436a7530ee5c5c514bfdfac4a558 Mon Sep 17 00:00:00 2001 From: Matthieu Bouron Date: Fri, 28 Apr 2017 21:58:55 +0200 Subject: [PATCH] lavc/aarch64/simple_idct: fix iOS build without gas-preprocessor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Separates macro arguments with commas and passes .4H/.8H as macro arguments instead of 4H/8H (the later form being interpreted as an hexadecimal value). Fixes ticket #6324. Suggested-by: Martin Storsjö --- libavcodec/aarch64/simple_idct_neon.S | 74 +-- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/libavcodec/aarch64/simple_idct_neon.S b/libavcodec/aarch64/simple_idct_neon.S index 52273420f9..92987985d2 100644 --- a/libavcodec/aarch64/simple_idct_neon.S +++ b/libavcodec/aarch64/simple_idct_neon.S @@ -61,37 +61,37 @@ endconst br x10 .endm -.macro smull1 a b c +.macro smull1 a, b, c smull \a, \b, \c .endm -.macro smlal1 a b c +.macro smlal1 a, b, c smlal \a, \b, \c .endm -.macro smlsl1 a b c +.macro smlsl1 a, b, c smlsl \a, \b, \c .endm -.macro idct_col4_top y1 y2 y3 y4 i l -smull\i v7.4S, \y3\().\l, z2 -smull\i v16.4S, \y3\().\l, z6 -smull\i v17.4S, \y2\().\l, z1 +.macro idct_col4_top y1, y2, y3, y4, i, l +smull\i v7.4S, \y3\l, z1 +smull\i v16.4S, \y3\l, z6 +smull\i v17.4S, \y2\l, z1 add v19.4S, v23.4S, v7.4S -smull\i v18.4S, \y2\().\l, z3 +smull\i v18.4S, \y2\l, z3 add v20.4S, v23.4S, v16.4S -smull\i v5.4S, \y2\().\l, z5 +smull\i v5.4S, \y2\l, z5 sub v21.4S, v23.4S, v16.4S -smull\i v6.4S, \y2\().\l, z7 +smull\i v6.4S, \y2\l, z7 sub v22.4S, v23.4S, v7.4S -smlal\i v17.4S, \y4\().\l, z3 -smlsl\i v18.4S, \y4\().\l, z7 -smlsl\i v5.4S, \y4\().\l, z1 -smlsl\i v6.4S, \y4\().\l, z5 +smlal\i
Re: [FFmpeg-devel] [PATCH] lavc/aarch64/simple_idct: separate macro arguments with commas
On Tue, May 09, 2017 at 11:08:48PM +0200, Matthieu Bouron wrote: > On Sun, May 7, 2017 at 11:05 AM, Matthieu Bouron > wrote: > > > > > > > Le 2 mai 2017 12:01 PM, "Benoit Fouet" a écrit : > > > > Hi, > > > > > > On 28/04/2017 21:58, Matthieu Bouron wrote: > > > Untested: fixes ticket #6324. > > > --- > > > libavcodec/aarch64/simple_idct_neon.S | 12 ++-- > > > 1 file changed, 6 insertions(+), 6 deletions(-) > > > > > > diff --git a/libavcodec/aarch64/simple_idct_neon.S > > b/libavcodec/aarch64/simple_idct_neon.S > > > index 52273420f9..d31f72a609 100644 > > > --- a/libavcodec/aarch64/simple_idct_neon.S > > > +++ b/libavcodec/aarch64/simple_idct_neon.S > > > @@ -61,19 +61,19 @@ endconst > > > br x10 > > > .endm > > > > > > -.macro smull1 a b c > > > +.macro smull1 a, b, c > > > smull \a, \b, \c > > > .endm > > > > > > -.macro smlal1 a b c > > > +.macro smlal1 a, b, c > > > smlal \a, \b, \c > > > .endm > > > > > > -.macro smlsl1 a b c > > > +.macro smlsl1 a, b, c > > > smlsl \a, \b, \c > > > .endm > > > > > > -.macro idct_col4_top y1 y2 y3 y4 i l > > > +.macro idct_col4_top y1, y2, y3, y4, i, l > > > smull\i v7.4S, \y3\().\l, z2 > > > smull\i v16.4S, \y3\().\l, z6 > > > smull\i v17.4S, \y2\().\l, z1 > > > @@ -91,7 +91,7 @@ endconst > > > smlsl\i v6.4S, \y4\().\l, z5 > > > .endm > > > > > > -.macro idct_row4_neon y1 y2 y3 y4 pass > > > +.macro idct_row4_neon y1, y2, y3, y4, pass > > > ld1 {\y1\().2D-\y2\().2D}, [x2], #32 > > > moviv23.4S, #1<<2, lsl #8 > > > orr v5.16B, \y1\().16B, \y2\().16B > > > @@ -153,7 +153,7 @@ endconst > > > trn2\y4\().4S, v17.4S, v19.4S > > > .endm > > > > > > -.macro declare_idct_col4_neon i l > > > +.macro declare_idct_col4_neon i, l > > > function idct_col4_neon\i > > > dup v23.4H, z4c > > > .if \i == 1 > > > > Sounds sane, but shouldn't we be doing this for all instances of > > multiple arguments macros without commas? > > > > > > Sure, I may have missed some. I will work again on this patch on Tuesday > > as I will have access to an apple machine (and hopefully fix the build > > without gas-preprocessor). > > > > Sorry for the delay, > > Matthieu > > > > > Updated patch attached: > * add missing commas to separate macro arguments > * passes .4H/.8H as macro arguments instead of .4H/.8H (the later form > being interpreted as an hexadecimal value, ie: 4/8). > From e27ac0f3a8b6436a7530ee5c5c514bfdfac4a558 Mon Sep 17 00:00:00 2001 > From: Matthieu Bouron > Date: Fri, 28 Apr 2017 21:58:55 +0200 > Subject: [PATCH] lavc/aarch64/simple_idct: fix iOS build without > gas-preprocessor > MIME-Version: 1.0 > Content-Type: text/plain; charset=UTF-8 > Content-Transfer-Encoding: 8bit > > Separates macro arguments with commas and passes .4H/.8H as macro > arguments instead of 4H/8H (the later form being interpreted as an > hexadecimal value). > > Fixes ticket #6324. > > Suggested-by: Martin Storsjö > --- > libavcodec/aarch64/simple_idct_neon.S | 74 > +-- > 1 file changed, 37 insertions(+), 37 deletions(-) > > diff --git a/libavcodec/aarch64/simple_idct_neon.S > b/libavcodec/aarch64/simple_idct_neon.S > index 52273420f9..92987985d2 100644 > --- a/libavcodec/aarch64/simple_idct_neon.S > +++ b/libavcodec/aarch64/simple_idct_neon.S > @@ -61,37 +61,37 @@ endconst > br x10 > .endm > > -.macro smull1 a b c > +.macro smull1 a, b, c > smull \a, \b, \c > .endm > > -.macro smlal1 a b c > +.macro smlal1 a, b, c > smlal \a, \b, \c > .endm > > -.macro smlsl1 a b c > +.macro smlsl1 a, b, c > smlsl \a, \b, \c > .endm > > -.macro idct_col4_top y1 y2 y3 y4 i l > -smull\i v7.4S, \y3\().\l, z2 > -smull\i v16.4S, \y3\().\l, z6 > -smull\i v17.4S, \y2\().\l, z1 > +.macro idct_col4_top y1, y2, y3, y4, i, l > +smull\i v7.4S, \y3\l, z1 > +smull\i
Re: [FFmpeg-devel] ffmpeg using MediaCodec, avcodec_open2 says error code:-1 (0xffffffff) text: “Operation not permitted”
On Thu, May 11, 2017 at 08:10:37AM +, Miguel del Amor wrote: > > Qt version: 5.7.1 > ffmpeg version: n3.3 > Android version: 5.1.1 ( but I've tried on some different devices ) > > I'm trying to use the Android API MediaCoded that have been supported by > ffmpeg but while I try to open the codec I got "Operation not permitted" all > times, I've tried some changes and I've tried to find examples without not > luck. > > This is what I'm doing > > av_jni_set_java_vm(QAndroidJniEnvironment::javaVM(), NULL); > > av_register_all(); > avcodec_register_all(); > > AVCodec *_codec(nullptr); > AVCodecContext *_codecContext(nullptr); > > if (_codec == nullptr) > _codec = avcodec_find_decoder_by_name("h264_mediacodec"); > > if (_codecContext == nullptr) > _codecContext = avcodec_alloc_context3(_codec); > > int ret = 0; > if( (ret = avcodec_open2(_codecContext, _codec, NULL)) < 0 ) { > > char str[AV_ERROR_MAX_STRING_SIZE]; > memset(str, 0, sizeof(str)); > av_strerror(ret, str, sizeof(str)); > > qDebug("avcodec_open2 \"%s\" error[code:%d > text:\"%s\"]",_codec->long_name, ret, str); > } > > > And I'm getting this output > > avcodec_open2 "H.264 Android MediaCodec decoder" error[code:-1 > text:"Operation not permitted"] > > > What I'm doing wrong? > This is the wrong mailing list, libavcodec user questions belong to the libav-user mailing list: http://ffmpeg.org/contact.html Note: h264_mediacodec requires AVCodecContext.extradata to be set. Matthieu [...] ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] lavc/aarch64/simple_idct: separate macro arguments with commas
On Wed, May 10, 2017 at 08:23:02PM +0200, Matthieu Bouron wrote: > On Tue, May 09, 2017 at 11:08:48PM +0200, Matthieu Bouron wrote: > > On Sun, May 7, 2017 at 11:05 AM, Matthieu Bouron > > wrote: > > > > > > > > > > > Le 2 mai 2017 12:01 PM, "Benoit Fouet" a écrit : > > > > > > Hi, > > > > > > > > > On 28/04/2017 21:58, Matthieu Bouron wrote: > > > > Untested: fixes ticket #6324. > > > > --- > > > > libavcodec/aarch64/simple_idct_neon.S | 12 ++-- > > > > 1 file changed, 6 insertions(+), 6 deletions(-) > > > > > > > > diff --git a/libavcodec/aarch64/simple_idct_neon.S > > > b/libavcodec/aarch64/simple_idct_neon.S > > > > index 52273420f9..d31f72a609 100644 > > > > --- a/libavcodec/aarch64/simple_idct_neon.S > > > > +++ b/libavcodec/aarch64/simple_idct_neon.S > > > > @@ -61,19 +61,19 @@ endconst > > > > br x10 > > > > .endm > > > > > > > > -.macro smull1 a b c > > > > +.macro smull1 a, b, c > > > > smull \a, \b, \c > > > > .endm > > > > > > > > -.macro smlal1 a b c > > > > +.macro smlal1 a, b, c > > > > smlal \a, \b, \c > > > > .endm > > > > > > > > -.macro smlsl1 a b c > > > > +.macro smlsl1 a, b, c > > > > smlsl \a, \b, \c > > > > .endm > > > > > > > > -.macro idct_col4_top y1 y2 y3 y4 i l > > > > +.macro idct_col4_top y1, y2, y3, y4, i, l > > > > smull\i v7.4S, \y3\().\l, z2 > > > > smull\i v16.4S, \y3\().\l, z6 > > > > smull\i v17.4S, \y2\().\l, z1 > > > > @@ -91,7 +91,7 @@ endconst > > > > smlsl\i v6.4S, \y4\().\l, z5 > > > > .endm > > > > > > > > -.macro idct_row4_neon y1 y2 y3 y4 pass > > > > +.macro idct_row4_neon y1, y2, y3, y4, pass > > > > ld1 {\y1\().2D-\y2\().2D}, [x2], #32 > > > > moviv23.4S, #1<<2, lsl #8 > > > > orr v5.16B, \y1\().16B, \y2\().16B > > > > @@ -153,7 +153,7 @@ endconst > > > > trn2\y4\().4S, v17.4S, v19.4S > > > > .endm > > > > > > > > -.macro declare_idct_col4_neon i l > > > > +.macro declare_idct_col4_neon i, l > > > > function idct_col4_neon\i > > > > dup v23.4H, z4c > > > > .if \i == 1 > > > > > > Sounds sane, but shouldn't we be doing this for all instances of > > > multiple arguments macros without commas? > > > > > > > > > Sure, I may have missed some. I will work again on this patch on Tuesday > > > as I will have access to an apple machine (and hopefully fix the build > > > without gas-preprocessor). > > > > > > Sorry for the delay, > > > Matthieu > > > > > > > > Updated patch attached: > > * add missing commas to separate macro arguments > > * passes .4H/.8H as macro arguments instead of .4H/.8H (the later form > > being interpreted as an hexadecimal value, ie: 4/8). > > > From e27ac0f3a8b6436a7530ee5c5c514bfdfac4a558 Mon Sep 17 00:00:00 2001 > > From: Matthieu Bouron > > Date: Fri, 28 Apr 2017 21:58:55 +0200 > > Subject: [PATCH] lavc/aarch64/simple_idct: fix iOS build without > > gas-preprocessor > > MIME-Version: 1.0 > > Content-Type: text/plain; charset=UTF-8 > > Content-Transfer-Encoding: 8bit > > > > Separates macro arguments with commas and passes .4H/.8H as macro > > arguments instead of 4H/8H (the later form being interpreted as an > > hexadecimal value). > > > > Fixes ticket #6324. > > > > Suggested-by: Martin Storsjö > > --- > > libavcodec/aarch64/simple_idct_neon.S | 74 > > +-- > > 1 file changed, 37 insertions(+), 37 deletions(-) > > > > diff --git a/libavcodec/aarch64/simple_idct_neon.S > > b/libavcodec/aarch64/simple_idct_neon.S > > index 52273420f9..92987985d2 100644 > > --- a/libavcodec/aarch64/simple_idct_neon.S > > +++ b/libavcodec/aarch64/simple_idct_neon.S > > @@ -61,37 +61,37 @@ endconst > > br x10 > > .endm > > > > -.macro smull1 a b c > > +.macro smu
[FFmpeg-devel] [PATCH] lavf/mov: make invalid mdhd time_scale default to 1 instead of erroring out
Some samples have their metadata track time_scale incorrectly set to 0 and the check introduced by a398f054fdb9b0f0b5a91c231fba6ce014143f71 prevents playback of those samples. Setting the time_scale to 1 fixes playback. --- libavformat/mov.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index afef53b79a..3c8b75ddb3 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -1236,8 +1236,8 @@ static int mov_read_mdhd(MOVContext *c, AVIOContext *pb, MOVAtom atom) sc->time_scale = avio_rb32(pb); if (sc->time_scale <= 0) { -av_log(c->fc, AV_LOG_ERROR, "Invalid mdhd time scale %d\n", sc->time_scale); -return AVERROR_INVALIDDATA; +av_log(c->fc, AV_LOG_ERROR, "Invalid mdhd time scale %d, defaulting to 1\n", sc->time_scale); +sc->time_scale = 1; } st->duration = (version == 1) ? avio_rb64(pb) : avio_rb32(pb); /* duration */ -- 2.12.2 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] configure: jni no longer requires -ldl
On Fri, May 12, 2017 at 12:14:20PM -0700, Aaron Levinson wrote: > On 5/12/2017 11:34 AM, Aman Gupta wrote: > > From: Aman Gupta > > > > this dependency was removed in 33d69a90085d30af8a292d9364b835a26565d6b9 > > --- > > configure | 3 +-- > > 1 file changed, 1 insertion(+), 2 deletions(-) > > > > diff --git a/configure b/configure > > index 5ae5227868..ba33241a45 100755 > > --- a/configure > > +++ b/configure > > @@ -5766,8 +5766,7 @@ enabled decklink && { { check_header > > DeckLinkAPI.h || die "ERROR: DeckL > > enabled frei0r&& { check_header frei0r.h || die "ERROR: > > frei0r.h header not found"; } > > enabled gmp && require gmp gmp.h mpz_export -lgmp > > enabled gnutls&& require_pkg_config gnutls gnutls/gnutls.h > > gnutls_global_init > > -enabled jni && { [ $target_os = "android" ] && check_header > > jni.h && enabled pthreads && > > - check_lib jni "dlfcn.h" dlopen -ldl || die > > "ERROR: jni not found"; } > > +enabled jni && { [ $target_os = "android" ] && check_header > > jni.h && enabled pthreads || die "ERROR: jni not found"; } > > enabled ladspa&& { check_header ladspa.h || die "ERROR: > > ladspa.h header not found"; } > > enabled libiec61883 && require libiec61883 libiec61883/iec61883.h > > iec61883_cmp_connect -lraw1394 -lavc1394 -lrom1394 -liec61883 > > enabled libass&& require_pkg_config libass ass/ass.h > > ass_library_init > > > > LGTM--I see that the use of dl was eliminated in 33d69a9 (at > https://github.com/FFmpeg/FFmpeg/commit/33d69a90085d30af8a292d9364b835a26565d6b9 > ). LGTM too. Matthieu ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] configure: jni no longer requires -ldl
On Sat, May 13, 2017 at 05:26:13PM +0200, Matthieu Bouron wrote: > On Fri, May 12, 2017 at 12:14:20PM -0700, Aaron Levinson wrote: > > On 5/12/2017 11:34 AM, Aman Gupta wrote: > > > From: Aman Gupta > > > > > > this dependency was removed in 33d69a90085d30af8a292d9364b835a26565d6b9 > > > --- > > > configure | 3 +-- > > > 1 file changed, 1 insertion(+), 2 deletions(-) > > > > > > diff --git a/configure b/configure > > > index 5ae5227868..ba33241a45 100755 > > > --- a/configure > > > +++ b/configure > > > @@ -5766,8 +5766,7 @@ enabled decklink && { { check_header > > > DeckLinkAPI.h || die "ERROR: DeckL > > > enabled frei0r&& { check_header frei0r.h || die "ERROR: > > > frei0r.h header not found"; } > > > enabled gmp && require gmp gmp.h mpz_export -lgmp > > > enabled gnutls&& require_pkg_config gnutls gnutls/gnutls.h > > > gnutls_global_init > > > -enabled jni && { [ $target_os = "android" ] && > > > check_header jni.h && enabled pthreads && > > > - check_lib jni "dlfcn.h" dlopen -ldl || > > > die "ERROR: jni not found"; } > > > +enabled jni && { [ $target_os = "android" ] && > > > check_header jni.h && enabled pthreads || die "ERROR: jni not found"; } > > > enabled ladspa&& { check_header ladspa.h || die "ERROR: > > > ladspa.h header not found"; } > > > enabled libiec61883 && require libiec61883 libiec61883/iec61883.h > > > iec61883_cmp_connect -lraw1394 -lavc1394 -lrom1394 -liec61883 > > > enabled libass&& require_pkg_config libass ass/ass.h > > > ass_library_init > > > > > > > LGTM--I see that the use of dl was eliminated in 33d69a9 (at > > https://github.com/FFmpeg/FFmpeg/commit/33d69a90085d30af8a292d9364b835a26565d6b9 > > ). > > LGTM too. Patch applied. Thanks, Matthieu ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] lavf/mov: make invalid mdhd time_scale default to 1 instead of erroring out
On Fri, May 12, 2017 at 11:12:12PM +0200, Michael Niedermayer wrote: > On Thu, May 11, 2017 at 04:33:50PM +0200, Matthieu Bouron wrote: > > Some samples have their metadata track time_scale incorrectly set to 0 > > and the check introduced by a398f054fdb9b0f0b5a91c231fba6ce014143f71 > > prevents playback of those samples. Setting the time_scale to 1 fixes > > playback. > > --- > > libavformat/mov.c | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > should be ok Do you agree if I extend the patch to apply this behaviour to the mvhd atoms (like a398f054fdb9b0f0b5a91c231fba6ce014143f71 originally did) ? > please add a fate test I will. Is it mandatory in order to get this patch applied (as I would like to apply this patch as soon as possible) ? [...] -- Matthieu B. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] lavf/mov: make invalid mdhd time_scale default to 1 instead of erroring out
On Wed, May 17, 2017 at 01:56:13PM +0200, Matthieu Bouron wrote: > On Fri, May 12, 2017 at 11:12:12PM +0200, Michael Niedermayer wrote: > > On Thu, May 11, 2017 at 04:33:50PM +0200, Matthieu Bouron wrote: > > > Some samples have their metadata track time_scale incorrectly set to 0 > > > and the check introduced by a398f054fdb9b0f0b5a91c231fba6ce014143f71 > > > prevents playback of those samples. Setting the time_scale to 1 fixes > > > playback. > > > --- > > > libavformat/mov.c | 4 ++-- > > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > should be ok > > Do you agree if I extend the patch to apply this behaviour to the mvhd > atoms (like a398f054fdb9b0f0b5a91c231fba6ce014143f71 originally did) ? Here is an updated version of the patch (which extends the behaviour to the mvhd atoms). -- Matthieu B. >From 31d808ac885bcf1af1f546a1c8f29b1af82b381b Mon Sep 17 00:00:00 2001 From: Matthieu Bouron Date: Thu, 11 May 2017 15:16:22 +0200 Subject: [PATCH] lavf/mov: make invalid m{d,v}hd time_scale default to 1 instead of erroring out Some samples have their metadata track time_scale incorrectly set to 0 and the check introduced by a398f054fdb9b0f0b5a91c231fba6ce014143f71 prevents playback of those samples. Setting the time_scale to 1 fixes playback. --- libavformat/mov.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index afef53b79a..90b0ab1de7 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -1236,8 +1236,8 @@ static int mov_read_mdhd(MOVContext *c, AVIOContext *pb, MOVAtom atom) sc->time_scale = avio_rb32(pb); if (sc->time_scale <= 0) { -av_log(c->fc, AV_LOG_ERROR, "Invalid mdhd time scale %d\n", sc->time_scale); -return AVERROR_INVALIDDATA; +av_log(c->fc, AV_LOG_ERROR, "Invalid mdhd time scale %d, defaulting to 1\n", sc->time_scale); +sc->time_scale = 1; } st->duration = (version == 1) ? avio_rb64(pb) : avio_rb32(pb); /* duration */ @@ -1266,8 +1266,8 @@ static int mov_read_mvhd(MOVContext *c, AVIOContext *pb, MOVAtom atom) mov_metadata_creation_time(&c->fc->metadata, creation_time); c->time_scale = avio_rb32(pb); /* time scale */ if (c->time_scale <= 0) { -av_log(c->fc, AV_LOG_ERROR, "Invalid mvhd time scale %d\n", c->time_scale); -return AVERROR_INVALIDDATA; +av_log(c->fc, AV_LOG_ERROR, "Invalid mvhd time scale %d, defaulting to 1\n", c->time_scale); +c->time_scale = 1; } av_log(c->fc, AV_LOG_TRACE, "time scale = %i\n", c->time_scale); -- 2.12.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel