Re: [FFmpeg-devel] [PATCH v2] libavformat/dashdec: Support negative value of the @r attrbute of S in SegmentTimeline element.
> On Aug 11, 2018, at 08:20, sanil wrote: > > Hi, > The following patch supports parsing negative value of the @r attribute of S > in SegmentTimeline element. > > Example streams: > 1. http://dash.edgesuite.net/dash264/TestCases/1c/qualcomm/1/MultiRate.mpd > 2. http://dash.edgesuite.net/dash264/TestCases/1c/qualcomm/2/MultiRate.mpd > > --- > libavformat/dashdec.c | 13 - > 1 file changed, 12 insertions(+), 1 deletion(-) > > diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c > index 5730252..f851bbf 100644 > --- a/libavformat/dashdec.c > +++ b/libavformat/dashdec.c > @@ -259,6 +259,12 @@ static int64_t > get_segment_start_time_based_on_timeline(struct representation *p > goto finish; > > start_time += pls->timelines[i]->duration; > + > +if (pls->timelines[i]->repeat == -1) { > +start_time = pls->timelines[i]->duration * cur_seq_no; > +goto finish; > +} > + > for (j = 0; j < pls->timelines[i]->repeat; j++) { > num++; > if (num == cur_seq_no) > @@ -1322,7 +1328,12 @@ static int64_t calc_max_seg_no(struct representation > *pls, DASHContext *c) > int i = 0; > num = pls->first_seq_no + pls->n_timelines - 1; > for (i = 0; i < pls->n_timelines; i++) { > -num += pls->timelines[i]->repeat; > +if (pls->timelines[i]->repeat == -1) { > +int length_of_each_segment = pls->timelines[i]->duration / > pls->fragment_timescale; > +num = c->period_duration / length_of_each_segment; > +} else { > +num += pls->timelines[i]->repeat; > +} > } > } else if (c->is_live && pls->fragment_duration) { > num = pls->first_seq_no + (((get_current_time_in_sec() - > c->availability_start_time)) * pls->fragment_timescale) / > pls->fragment_duration; > -- > Thanks, > > 2.7.4 > > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel will apply Thanks Steven ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] start code is not [00 00 00 01] issue
hi all: i add log print in function "h264_decode_frame" in order to get the start code infomation of the input packet bitstream, and the log is below. but the result is not expected, for the doucument says each packet should be start with start code "00 00 01" or "00 00 00 01", if so, why the ffmpeg did not report any error messages to terminal? is there any mistake of my understanding? thanks for your kindly support. hi all: i add log print in function "h264_decode_frame" in order to get the start code infomation of the input packet bitstream, and the log is below. but the result is not expected, for the doucument says each packet should be start with start code "00 00 01" or "00 00 00 01", if so, why the ffmpeg did not report any error messages to terminal? is there any mistake of my understanding? thanks for your kindly support. 958 static int h264_decode_frame(AVCodecContext *avctx, void *data, 959 ¦ ¦ ¦ ¦ ¦ ¦ ¦int *got_frame, AVPacket *avpkt) 960 { 961 const uint8_t *buf = avpkt->data; 962 int buf_size = avpkt->size; 963 H264Context *h = avctx->priv_data; 964 AVFrame *pict = data; 965 int buf_index; 966 int ret; 967 968 printf("%s line %d, 0x%02x 0x%02x 0x%02x 0x%02x.\n", __func__, __LINE__, buf[0], buf[1], buf[2], buf[3]); h264_decode_frame line 968, 0x00 0x00 0x0d 0xd0. h264_decode_frame line 968, 0x00 0x00 0x07 0x69. h264_decode_frame line 968, 0x00 0x00 0x07 0x7a. h264_decode_frame line 968, 0x00 0x00 0x11 0x09. h264_decode_frame line 968, 0x00 0x00 0x0c 0xe0. h264_decode_frame line 968, 0x00 0x00 0x0d 0x9c. h264_decode_frame line 968, 0x00 0x00 0x0a 0x0f. h264_decode_frame line 968, 0x00 0x00 0x08 0xf3. h264_decode_frame line 968, 0x00 0x00 0x00 0xb1. h264_decode_frame line 968, 0x00 0x00 0x00 0x4b. h264_decode_frame line 968, 0x00 0x00 0x02 0xe5. h264_decode_frame line 968, 0x00 0x00 0x07 0x0a. h264_decode_frame line 968, 0x00 0x00 0x03 0x25. h264_decode_frame line 968, 0x00 0x00 0x0e 0x6a. h264_decode_frame line 968, 0x00 0x00 0x03 0xb7. h264_decode_frame line 968, 0x00 0x00 0x12 0xd1. h264_decode_frame line 968, 0x00 0x00 0x04 0x56. h264_decode_frame line 968, 0x00 0x00 0x06 0x20. h264_decode_frame line 968, 0x00 0x00 0x14 0xd7. h264_decode_frame line 968, 0x00 0x00 0x06 0xe8. h264_decode_frame line 968, 0x00 0x00 0x05 0xb1. h264_decode_frame line 968, 0x00 0x00 0x18 0xd0. h264_decode_frame line 968, 0x00 0x00 0x07 0x8b. h264_decode_frame line 968, 0x00 0x00 0x07 0xe8. h264_decode_frame line 968, 0x00 0x00 0x15 0x9a. h264_decode_frame line 968, 0x00 0x00 0x05 0x88. h264_decode_frame line 968, 0x00 0x00 0x14 0x58. h264_decode_frame line 968, 0x00 0x00 0x06 0xd4. h264_decode_frame line 968, 0x00 0x00 0x17 0x7a. h264_decode_frame line 968, 0x00 0x00 0x08 0x47. h264_decode_frame line 968, 0x00 0x00 0x07 0xcf. h264_decode_frame line 968, 0x00 0x00 0x23 0x9d. h264_decode_frame line 968, 0x00 0x00 0x0c 0x8d. h264_decode_frame line 968, 0x00 0x00 0x07 0x1a. h264_decode_frame line 968, 0x00 0x00 0x06 0xc3. h264_decode_frame line 968, 0x00 0x00 0x28 0xdf. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] start code is not [00 00 00 01] issue
On Sun, Aug 12, 2018 at 12:42 PM tugouxp <13824125...@163.com> wrote: > > hi all: > i add log print in function "h264_decode_frame" in order to get the start > code infomation of the input packet bitstream, > and the log is below. but the result is not expected, for the doucument says > each packet should be start with start code "00 00 01" or "00 00 00 01", > > if so, why the ffmpeg did not report any error messages to terminal? is > there any mistake of my understanding? > > thanks for your kindly support. hi all: > i add log print in function "h264_decode_frame" in order to get the start > code infomation of the input packet bitstream, > and the log is below. but the result is not expected, for the doucument says > each packet should be start with start code "00 00 01" or "00 00 00 01", > > if so, why the ffmpeg did not report any error messages to terminal? is > there any mistake of my understanding? > H264 can exist in two formats, either AnnexB with the start code you mention, or in MP4 format with a length prefix, but not the start code you are looking for. MP4 format is used in MP4/MKV and a variety of other containers, while AnnexB is often found in raw files and MPEG-TS and its derived formats. - Hendrik ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH] avcodec: v4l2_m2m: add MJPEG enc/dec support
Tested on an Odroid-C2 with a V4L2 M2M MJPEG decoder. Signed-off-by: Maxime Jourdan --- configure | 3 +++ libavcodec/Makefile | 2 ++ libavcodec/allcodecs.c| 2 ++ libavcodec/v4l2_m2m_dec.c | 1 + libavcodec/v4l2_m2m_enc.c | 1 + 5 files changed, 9 insertions(+) diff --git a/configure b/configure index e718c1531c..5a5ba1ebcf 100755 --- a/configure +++ b/configure @@ -2939,6 +2939,8 @@ hevc_vaapi_encoder_deps="VAEncPictureParameterBufferHEVC" hevc_vaapi_encoder_select="cbs_h265 vaapi_encode" hevc_v4l2m2m_decoder_deps="v4l2_m2m hevc_v4l2_m2m" hevc_v4l2m2m_encoder_deps="v4l2_m2m hevc_v4l2_m2m" +mjpeg_v4l2m2m_decoder_deps="v4l2_m2m mjpeg_v4l2_m2m" +mjpeg_v4l2m2m_encoder_deps="v4l2_m2m mjpeg_v4l2_m2m" mjpeg_cuvid_decoder_deps="cuvid" mjpeg_qsv_encoder_deps="libmfx" mjpeg_qsv_encoder_select="qsvenc" @@ -6252,6 +6254,7 @@ check_header linux/videodev2.h test_code cc linux/videodev2.h "struct v4l2_frmsizeenum vfse; vfse.discrete.width = 0;" && enable_sanitized struct_v4l2_frmivalenum_discrete check_cc v4l2_m2m linux/videodev2.h "int i = V4L2_CAP_VIDEO_M2M_MPLANE | V4L2_CAP_VIDEO_M2M | V4L2_BUF_FLAG_LAST;" check_cc vc1_v4l2_m2m linux/videodev2.h "int i = V4L2_PIX_FMT_VC1_ANNEX_G;" +check_cc mjpeg_v4l2_m2m linux/videodev2.h "int i = V4L2_PIX_FMT_MJPEG;" check_cc mpeg1_v4l2_m2m linux/videodev2.h "int i = V4L2_PIX_FMT_MPEG1;" check_cc mpeg2_v4l2_m2m linux/videodev2.h "int i = V4L2_PIX_FMT_MPEG2;" check_cc mpeg4_v4l2_m2m linux/videodev2.h "int i = V4L2_PIX_FMT_MPEG4;" diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 6e40702947..cd975739ef 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -415,7 +415,9 @@ OBJS-$(CONFIG_METASOUND_DECODER) += metasound.o metasound_data.o \ twinvq.o OBJS-$(CONFIG_MICRODVD_DECODER)+= microdvddec.o ass.o OBJS-$(CONFIG_MIMIC_DECODER) += mimic.o +OBJS-$(CONFIG_MJPEG_V4L2M2M_DECODER) += v4l2_m2m_dec.o OBJS-$(CONFIG_MJPEG_DECODER) += mjpegdec.o +OBJS-$(CONFIG_MJPEG_V4L2M2M_ENCODER) += v4l2_m2m_enc.o OBJS-$(CONFIG_MJPEG_ENCODER) += mjpegenc.o mjpegenc_common.o \ mjpegenc_huffman.o OBJS-$(CONFIG_MJPEGB_DECODER) += mjpegbdec.o diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index ab3ec04251..af4870a54d 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -173,7 +173,9 @@ extern AVCodec ff_magicyuv_encoder; extern AVCodec ff_magicyuv_decoder; extern AVCodec ff_mdec_decoder; extern AVCodec ff_mimic_decoder; +extern AVCodec ff_mjpeg_v4l2m2m_encoder; extern AVCodec ff_mjpeg_encoder; +extern AVCodec ff_mjpeg_v4l2m2m_decoder; extern AVCodec ff_mjpeg_decoder; extern AVCodec ff_mjpegb_decoder; extern AVCodec ff_mmvideo_decoder; diff --git a/libavcodec/v4l2_m2m_dec.c b/libavcodec/v4l2_m2m_dec.c index a4e2f02596..80a09f7a43 100644 --- a/libavcodec/v4l2_m2m_dec.c +++ b/libavcodec/v4l2_m2m_dec.c @@ -231,6 +231,7 @@ AVCodec ff_ ## NAME ## _v4l2m2m_decoder = { \ M2MDEC(h264, "H.264", AV_CODEC_ID_H264, "h264_mp4toannexb"); M2MDEC(hevc, "HEVC", AV_CODEC_ID_HEVC, "hevc_mp4toannexb"); +M2MDEC(mjpeg, "MJPEG", AV_CODEC_ID_MJPEG, NULL); M2MDEC(mpeg1, "MPEG1", AV_CODEC_ID_MPEG1VIDEO, NULL); M2MDEC(mpeg2, "MPEG2", AV_CODEC_ID_MPEG2VIDEO, NULL); M2MDEC(mpeg4, "MPEG4", AV_CODEC_ID_MPEG4, NULL); diff --git a/libavcodec/v4l2_m2m_enc.c b/libavcodec/v4l2_m2m_enc.c index 4c9ea1fd92..b025f59275 100644 --- a/libavcodec/v4l2_m2m_enc.c +++ b/libavcodec/v4l2_m2m_enc.c @@ -345,6 +345,7 @@ AVCodec ff_ ## NAME ## _v4l2m2m_encoder = { \ .wrapper_name = "v4l2m2m", \ }; +M2MENC(mjpeg,"MJPEG", AV_CODEC_ID_MJPEG); M2MENC(mpeg4,"MPEG4", AV_CODEC_ID_MPEG4); M2MENC(h263, "H.263", AV_CODEC_ID_H263); M2MENC(h264, "H.264", AV_CODEC_ID_H264); -- 2.18.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avcodec: v4l2_m2m: add MJPEG enc/dec support
On 08/12/2018 04:40 PM, Maxime Jourdan wrote: Tested on an Odroid-C2 with a V4L2 M2M MJPEG decoder. cool. did you also test the encoder? Signed-off-by: Maxime Jourdan --- configure | 3 +++ libavcodec/Makefile | 2 ++ libavcodec/allcodecs.c| 2 ++ libavcodec/v4l2_m2m_dec.c | 1 + libavcodec/v4l2_m2m_enc.c | 1 + 5 files changed, 9 insertions(+) diff --git a/configure b/configure index e718c1531c..5a5ba1ebcf 100755 --- a/configure +++ b/configure @@ -2939,6 +2939,8 @@ hevc_vaapi_encoder_deps="VAEncPictureParameterBufferHEVC" hevc_vaapi_encoder_select="cbs_h265 vaapi_encode" hevc_v4l2m2m_decoder_deps="v4l2_m2m hevc_v4l2_m2m" hevc_v4l2m2m_encoder_deps="v4l2_m2m hevc_v4l2_m2m" +mjpeg_v4l2m2m_decoder_deps="v4l2_m2m mjpeg_v4l2_m2m" +mjpeg_v4l2m2m_encoder_deps="v4l2_m2m mjpeg_v4l2_m2m" mjpeg_cuvid_decoder_deps="cuvid" mjpeg_qsv_encoder_deps="libmfx" mjpeg_qsv_encoder_select="qsvenc" @@ -6252,6 +6254,7 @@ check_header linux/videodev2.h test_code cc linux/videodev2.h "struct v4l2_frmsizeenum vfse; vfse.discrete.width = 0;" && enable_sanitized struct_v4l2_frmivalenum_discrete check_cc v4l2_m2m linux/videodev2.h "int i = V4L2_CAP_VIDEO_M2M_MPLANE | V4L2_CAP_VIDEO_M2M | V4L2_BUF_FLAG_LAST;" check_cc vc1_v4l2_m2m linux/videodev2.h "int i = V4L2_PIX_FMT_VC1_ANNEX_G;" +check_cc mjpeg_v4l2_m2m linux/videodev2.h "int i = V4L2_PIX_FMT_MJPEG;" check_cc mpeg1_v4l2_m2m linux/videodev2.h "int i = V4L2_PIX_FMT_MPEG1;" check_cc mpeg2_v4l2_m2m linux/videodev2.h "int i = V4L2_PIX_FMT_MPEG2;" check_cc mpeg4_v4l2_m2m linux/videodev2.h "int i = V4L2_PIX_FMT_MPEG4;" diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 6e40702947..cd975739ef 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -415,7 +415,9 @@ OBJS-$(CONFIG_METASOUND_DECODER) += metasound.o metasound_data.o \ twinvq.o OBJS-$(CONFIG_MICRODVD_DECODER)+= microdvddec.o ass.o OBJS-$(CONFIG_MIMIC_DECODER) += mimic.o +OBJS-$(CONFIG_MJPEG_V4L2M2M_DECODER) += v4l2_m2m_dec.o OBJS-$(CONFIG_MJPEG_DECODER) += mjpegdec.o +OBJS-$(CONFIG_MJPEG_V4L2M2M_ENCODER) += v4l2_m2m_enc.o OBJS-$(CONFIG_MJPEG_ENCODER) += mjpegenc.o mjpegenc_common.o \ mjpegenc_huffman.o OBJS-$(CONFIG_MJPEGB_DECODER) += mjpegbdec.o diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index ab3ec04251..af4870a54d 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -173,7 +173,9 @@ extern AVCodec ff_magicyuv_encoder; extern AVCodec ff_magicyuv_decoder; extern AVCodec ff_mdec_decoder; extern AVCodec ff_mimic_decoder; +extern AVCodec ff_mjpeg_v4l2m2m_encoder; extern AVCodec ff_mjpeg_encoder; +extern AVCodec ff_mjpeg_v4l2m2m_decoder; extern AVCodec ff_mjpeg_decoder; extern AVCodec ff_mjpegb_decoder; extern AVCodec ff_mmvideo_decoder; diff --git a/libavcodec/v4l2_m2m_dec.c b/libavcodec/v4l2_m2m_dec.c index a4e2f02596..80a09f7a43 100644 --- a/libavcodec/v4l2_m2m_dec.c +++ b/libavcodec/v4l2_m2m_dec.c @@ -231,6 +231,7 @@ AVCodec ff_ ## NAME ## _v4l2m2m_decoder = { \ M2MDEC(h264, "H.264", AV_CODEC_ID_H264, "h264_mp4toannexb"); M2MDEC(hevc, "HEVC", AV_CODEC_ID_HEVC, "hevc_mp4toannexb"); +M2MDEC(mjpeg, "MJPEG", AV_CODEC_ID_MJPEG, NULL); M2MDEC(mpeg1, "MPEG1", AV_CODEC_ID_MPEG1VIDEO, NULL); M2MDEC(mpeg2, "MPEG2", AV_CODEC_ID_MPEG2VIDEO, NULL); M2MDEC(mpeg4, "MPEG4", AV_CODEC_ID_MPEG4, NULL); diff --git a/libavcodec/v4l2_m2m_enc.c b/libavcodec/v4l2_m2m_enc.c index 4c9ea1fd92..b025f59275 100644 --- a/libavcodec/v4l2_m2m_enc.c +++ b/libavcodec/v4l2_m2m_enc.c @@ -345,6 +345,7 @@ AVCodec ff_ ## NAME ## _v4l2m2m_encoder = { \ .wrapper_name = "v4l2m2m", \ }; +M2MENC(mjpeg,"MJPEG", AV_CODEC_ID_MJPEG); M2MENC(mpeg4,"MPEG4", AV_CODEC_ID_MPEG4); M2MENC(h263, "H.263", AV_CODEC_ID_H263); M2MENC(h264, "H.264", AV_CODEC_ID_H264); ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avcodec: v4l2_m2m: add MJPEG enc/dec support
On 12/08/18 15:40, Maxime Jourdan wrote: > Tested on an Odroid-C2 with a V4L2 M2M MJPEG decoder. > > Signed-off-by: Maxime Jourdan > --- > configure | 3 +++ > libavcodec/Makefile | 2 ++ > libavcodec/allcodecs.c| 2 ++ > libavcodec/v4l2_m2m_dec.c | 1 + > libavcodec/v4l2_m2m_enc.c | 1 + > 5 files changed, 9 insertions(+) > > diff --git a/configure b/configure > index e718c1531c..5a5ba1ebcf 100755 > --- a/configure > +++ b/configure > @@ -2939,6 +2939,8 @@ > hevc_vaapi_encoder_deps="VAEncPictureParameterBufferHEVC" > hevc_vaapi_encoder_select="cbs_h265 vaapi_encode" > hevc_v4l2m2m_decoder_deps="v4l2_m2m hevc_v4l2_m2m" > hevc_v4l2m2m_encoder_deps="v4l2_m2m hevc_v4l2_m2m" > +mjpeg_v4l2m2m_decoder_deps="v4l2_m2m mjpeg_v4l2_m2m" > +mjpeg_v4l2m2m_encoder_deps="v4l2_m2m mjpeg_v4l2_m2m" > mjpeg_cuvid_decoder_deps="cuvid" > mjpeg_qsv_encoder_deps="libmfx" > mjpeg_qsv_encoder_select="qsvenc" > @@ -6252,6 +6254,7 @@ check_header linux/videodev2.h > test_code cc linux/videodev2.h "struct v4l2_frmsizeenum vfse; > vfse.discrete.width = 0;" && enable_sanitized struct_v4l2_frmivalenum_discrete > check_cc v4l2_m2m linux/videodev2.h "int i = V4L2_CAP_VIDEO_M2M_MPLANE | > V4L2_CAP_VIDEO_M2M | V4L2_BUF_FLAG_LAST;" > check_cc vc1_v4l2_m2m linux/videodev2.h "int i = V4L2_PIX_FMT_VC1_ANNEX_G;" > +check_cc mjpeg_v4l2_m2m linux/videodev2.h "int i = V4L2_PIX_FMT_MJPEG;" The existing format code unconditionally assumes this value is present (libavcodec/v4l2_fmt.c:54 - it's been around forever for input devices), so the check isn't needed. > check_cc mpeg1_v4l2_m2m linux/videodev2.h "int i = V4L2_PIX_FMT_MPEG1;" > check_cc mpeg2_v4l2_m2m linux/videodev2.h "int i = V4L2_PIX_FMT_MPEG2;" > check_cc mpeg4_v4l2_m2m linux/videodev2.h "int i = V4L2_PIX_FMT_MPEG4;" > diff --git a/libavcodec/Makefile b/libavcodec/Makefile > index 6e40702947..cd975739ef 100644 > --- a/libavcodec/Makefile > +++ b/libavcodec/Makefile > @@ -415,7 +415,9 @@ OBJS-$(CONFIG_METASOUND_DECODER) += metasound.o > metasound_data.o \ >twinvq.o > OBJS-$(CONFIG_MICRODVD_DECODER)+= microdvddec.o ass.o > OBJS-$(CONFIG_MIMIC_DECODER) += mimic.o > +OBJS-$(CONFIG_MJPEG_V4L2M2M_DECODER) += v4l2_m2m_dec.o > OBJS-$(CONFIG_MJPEG_DECODER) += mjpegdec.o > +OBJS-$(CONFIG_MJPEG_V4L2M2M_ENCODER) += v4l2_m2m_enc.o Use the same ordering as for other codecs. > OBJS-$(CONFIG_MJPEG_ENCODER) += mjpegenc.o mjpegenc_common.o \ >mjpegenc_huffman.o > OBJS-$(CONFIG_MJPEGB_DECODER) += mjpegbdec.o > diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c > index ab3ec04251..af4870a54d 100644 > --- a/libavcodec/allcodecs.c > +++ b/libavcodec/allcodecs.c > @@ -173,7 +173,9 @@ extern AVCodec ff_magicyuv_encoder; > extern AVCodec ff_magicyuv_decoder; > extern AVCodec ff_mdec_decoder; > extern AVCodec ff_mimic_decoder; This file gets parsed in order to make the table of decoders/encoders, so: > +extern AVCodec ff_mjpeg_v4l2m2m_encoder; > extern AVCodec ff_mjpeg_encoder; The new entry for the encoder should be in the non-default section at the bottom. > +extern AVCodec ff_mjpeg_v4l2m2m_decoder; > extern AVCodec ff_mjpeg_decoder; The new entry for the decoder should be after the normal decoder. > extern AVCodec ff_mjpegb_decoder; > extern AVCodec ff_mmvideo_decoder; > diff --git a/libavcodec/v4l2_m2m_dec.c b/libavcodec/v4l2_m2m_dec.c > index a4e2f02596..80a09f7a43 100644 > --- a/libavcodec/v4l2_m2m_dec.c > +++ b/libavcodec/v4l2_m2m_dec.c > @@ -231,6 +231,7 @@ AVCodec ff_ ## NAME ## _v4l2m2m_decoder = { \ > > M2MDEC(h264, "H.264", AV_CODEC_ID_H264, "h264_mp4toannexb"); > M2MDEC(hevc, "HEVC", AV_CODEC_ID_HEVC, "hevc_mp4toannexb"); > +M2MDEC(mjpeg, "MJPEG", AV_CODEC_ID_MJPEG, NULL); > M2MDEC(mpeg1, "MPEG1", AV_CODEC_ID_MPEG1VIDEO, NULL); > M2MDEC(mpeg2, "MPEG2", AV_CODEC_ID_MPEG2VIDEO, NULL); > M2MDEC(mpeg4, "MPEG4", AV_CODEC_ID_MPEG4, NULL); > diff --git a/libavcodec/v4l2_m2m_enc.c b/libavcodec/v4l2_m2m_enc.c > index 4c9ea1fd92..b025f59275 100644 > --- a/libavcodec/v4l2_m2m_enc.c > +++ b/libavcodec/v4l2_m2m_enc.c > @@ -345,6 +345,7 @@ AVCodec ff_ ## NAME ## _v4l2m2m_encoder = { \ > .wrapper_name = "v4l2m2m", \ > }; > > +M2MENC(mjpeg,"MJPEG", AV_CODEC_ID_MJPEG); > M2MENC(mpeg4,"MPEG4", AV_CODEC_ID_MPEG4); > M2MENC(h263, "H.263", AV_CODEC_ID_H263); > M2MENC(h264, "H.264", AV_CODEC_ID_H264); Since MJPEG is intra-only, it probably wants to avoid setting options like GOP size and B-frames (currently this gives me warnings for each of these options that it failed to set them, visible in log below). > Trying this on an Odroid XU4 (Exynos S5P running Linux 4.14.55), it looks like we need to somehow allow both "MJPG" and "JPEG" as fourccs. Reordering the two lines in libavcodec/v4l2_fmt.c to put "JPEG" first makes it get past that test, but obvio
Re: [FFmpeg-devel] [PATCH] lavfi: add erosion_opencl, dilation_opencl filters
On 09/08/18 03:41, Danil Iashchenko wrote: > Add erosion_opencl, dilation_opencl filters. Behave like existing erosion and > dilation filters. > --- > > Thanks! Fixed. > > configure| 2 + > libavfilter/Makefile | 4 + > libavfilter/allfilters.c | 2 + > libavfilter/opencl/neighbor.cl | 87 +++ > libavfilter/opencl_source.h | 1 + > libavfilter/vf_neighbor_opencl.c | 327 > +++ > 6 files changed, 423 insertions(+) > create mode 100644 libavfilter/opencl/neighbor.cl > create mode 100644 libavfilter/vf_neighbor_opencl.c > > ... > diff --git a/libavfilter/vf_neighbor_opencl.c > b/libavfilter/vf_neighbor_opencl.c > new file mode 100644 > index 000..7ba759b > --- /dev/null > +++ b/libavfilter/vf_neighbor_opencl.c > ... > +static int neighbor_opencl_make_filter_params(AVFilterContext *avctx) > +{ > +NeighborOpenCLContext *ctx = avctx->priv; > +int *matrix = NULL; > +size_t matrix_bytes; > +cl_mem buffer; > +cl_int cle; > +int i; > + > +for (i = 0; i < 4; i++) { > +ctx->threshold[i] /= 255.0; > +} > +for (i = 0; i < 9; i++) { > +matrix_bytes = sizeof(float)*9; sizeof(int)? > +matrix = av_malloc(matrix_bytes); > +} I don't think you want a loop around this? It allocates extra instances of matrix which never get freed. Since it's small it might be easier to just put "cl_int matrix[9]" on the stack. > +if (!matrix) { > +av_freep(&matrix); > +return AVERROR(ENOMEM); > +} > +matrix[4] = 0; > +for (i = 0; i < 8; i++) { > +if (ctx->coordinates & (1 << i)) { > +matrix[i > 3 ? i + 1: i] = 1; > +} > +} > +buffer = clCreateBuffer(ctx->ocf.hwctx->context, > +CL_MEM_READ_ONLY | > +CL_MEM_COPY_HOST_PTR | > +CL_MEM_HOST_NO_ACCESS, > +matrix_bytes, matrix, &cle); This buffer is never released. > +if (!buffer) { > +av_log(avctx, AV_LOG_ERROR, "Failed to create matrix buffer: " > + "%d.\n", cle); > +av_freep(&matrix); > +return AVERROR(EIO); > +} > +ctx->coord = buffer; > +av_freep(&matrix); > + > +return 0; > +} > ... Tested and has identical output to existing dilation/erosion filters, so otherwise LGTM. Thanks, - Mark ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 1/4] avcodec/microdvddec: limit style characters in parsing
On Sat, Aug 04, 2018 at 02:58:30AM +0200, Michael Niedermayer wrote: > Fixes: Timeout > Fixes: > 9293/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MICRODVD_fuzzer-5643972541153280 > > Found-by: continuous fuzzing process > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg > Signed-off-by: Michael Niedermayer > --- > libavcodec/microdvddec.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) will apply patchset [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Observe your enemies, for they first find out your faults. -- Antisthenes signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 1/9] avcodec/mpegaudio_parser: Initialize poutbuf*
On Sun, Aug 05, 2018 at 10:29:29PM +0200, Michael Niedermayer wrote: > Possibly fixes: null pointer dereference > Possibly fixes: > 9352/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MP3ADUFLOAT_fuzzer-5146068961460224 > Fixes: Heap-use-after-free > Fixes: > 9453/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MP3ADUFLOAT_fuzzer-5137954375729152 > > Found-by: continuous fuzzing process > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg > Signed-off-by: Michael Niedermayer > --- > libavcodec/mpegaudio_parser.c | 2 ++ > 1 file changed, 2 insertions(+) will apply [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Avoid a single point of failure, be that a person or equipment. signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH] lavfi: add erosion_opencl, dilation_opencl filters
Add erosion_opencl, dilation_opencl filters. Behave like existing erosion and dilation filters. --- Thanks, Fixed! Danil. configure| 2 + libavfilter/Makefile | 4 + libavfilter/allfilters.c | 2 + libavfilter/opencl/neighbor.cl | 87 +++ libavfilter/opencl_source.h | 1 + libavfilter/vf_neighbor_opencl.c | 319 +++ 6 files changed, 415 insertions(+) create mode 100644 libavfilter/opencl/neighbor.cl create mode 100644 libavfilter/vf_neighbor_opencl.c diff --git a/configure b/configure index 5783407..9ab2e9f 100755 --- a/configure +++ b/configure @@ -,10 +,12 @@ deinterlace_vaapi_filter_deps="vaapi" delogo_filter_deps="gpl" denoise_vaapi_filter_deps="vaapi VAProcPipelineParameterBuffer" deshake_filter_select="pixelutils" +dilation_opencl_filter_deps="opencl" drawtext_filter_deps="libfreetype" drawtext_filter_suggest="libfontconfig libfribidi" elbg_filter_deps="avcodec" eq_filter_deps="gpl" +erosion_opencl_filter_deps="opencl" fftfilt_filter_deps="avcodec" fftfilt_filter_select="rdft" fftdnoiz_filter_deps="avcodec" diff --git a/libavfilter/Makefile b/libavfilter/Makefile index 5d4549e..03df93b 100644 --- a/libavfilter/Makefile +++ b/libavfilter/Makefile @@ -196,6 +196,8 @@ OBJS-$(CONFIG_DESHAKE_FILTER)+= vf_deshake.o OBJS-$(CONFIG_DESPILL_FILTER)+= vf_despill.o OBJS-$(CONFIG_DETELECINE_FILTER) += vf_detelecine.o OBJS-$(CONFIG_DILATION_FILTER) += vf_neighbor.o +OBJS-$(CONFIG_DILATION_OPENCL_FILTER)+= vf_neighbor_opencl.o opencl.o \ +opencl/neighbor.o OBJS-$(CONFIG_DISPLACE_FILTER) += vf_displace.o framesync.o OBJS-$(CONFIG_DOUBLEWEAVE_FILTER)+= vf_weave.o OBJS-$(CONFIG_DRAWBOX_FILTER)+= vf_drawbox.o @@ -207,6 +209,8 @@ OBJS-$(CONFIG_ELBG_FILTER) += vf_elbg.o OBJS-$(CONFIG_ENTROPY_FILTER)+= vf_entropy.o OBJS-$(CONFIG_EQ_FILTER) += vf_eq.o OBJS-$(CONFIG_EROSION_FILTER)+= vf_neighbor.o +OBJS-$(CONFIG_EROSION_OPENCL_FILTER) += vf_neighbor_opencl.o opencl.o \ +opencl/neighbor.o OBJS-$(CONFIG_EXTRACTPLANES_FILTER) += vf_extractplanes.o OBJS-$(CONFIG_FADE_FILTER) += vf_fade.o OBJS-$(CONFIG_FFTDNOIZ_FILTER) += vf_fftdnoiz.o diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c index 521bc53..f33129c 100644 --- a/libavfilter/allfilters.c +++ b/libavfilter/allfilters.c @@ -185,6 +185,7 @@ extern AVFilter ff_vf_deshake; extern AVFilter ff_vf_despill; extern AVFilter ff_vf_detelecine; extern AVFilter ff_vf_dilation; +extern AVFilter ff_vf_dilation_opencl; extern AVFilter ff_vf_displace; extern AVFilter ff_vf_doubleweave; extern AVFilter ff_vf_drawbox; @@ -196,6 +197,7 @@ extern AVFilter ff_vf_elbg; extern AVFilter ff_vf_entropy; extern AVFilter ff_vf_eq; extern AVFilter ff_vf_erosion; +extern AVFilter ff_vf_erosion_opencl; extern AVFilter ff_vf_extractplanes; extern AVFilter ff_vf_fade; extern AVFilter ff_vf_fftdnoiz; diff --git a/libavfilter/opencl/neighbor.cl b/libavfilter/opencl/neighbor.cl new file mode 100644 index 000..2235e3e --- /dev/null +++ b/libavfilter/opencl/neighbor.cl @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2018 Danil Iashchenko + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +__kernel void erosion_global(__write_only image2d_t dst, + __read_only image2d_t src, + float threshold, + __constant int *coord) +{ +const sampler_t sampler = (CLK_NORMALIZED_COORDS_FALSE | +CLK_ADDRESS_CLAMP_TO_EDGE | +CLK_FILTER_NEAREST); + +int2 loc = (int2)(get_global_id(0), get_global_id(1)); + +float4 px = read_imagef(src, sampler, loc); +float limit = px.x - threshold; +if (limit < 0) { +limit = 0; +} + +for (int i = -1; i <= 1; i++) { +for (int j = -1; j <= 1; j++) { +if (coord[(j + 1) * 3 + (i + 1)] == 1) { +
Re: [FFmpeg-devel] [PATCH] lavfi: add erosion_opencl, dilation_opencl filters
On 12/08/18 21:12, Danil Iashchenko wrote: > Add erosion_opencl, dilation_opencl filters. Behave like existing erosion and > dilation filters. > > --- > > Thanks, Fixed! > > Danil. > > configure| 2 + > libavfilter/Makefile | 4 + > libavfilter/allfilters.c | 2 + > libavfilter/opencl/neighbor.cl | 87 +++ > libavfilter/opencl_source.h | 1 + > libavfilter/vf_neighbor_opencl.c | 319 > +++ > 6 files changed, 415 insertions(+) > create mode 100644 libavfilter/opencl/neighbor.cl > create mode 100644 libavfilter/vf_neighbor_opencl.c ... and applied. Thanks! - Mark ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 2/4] libavcodec: v4l2m2m: output AVDRMFrameDescriptor
On 08/06/2018 10:12 PM, Mark Thompson wrote: On 06/08/18 16:44, Jorge Ramirez-Ortiz wrote: On 08/04/2018 11:43 PM, Mark Thompson wrote: diff --git a/libavcodec/v4l2_context.c b/libavcodec/v4l2_context.c index efcb0426e4..9457fadb1e 100644 --- a/libavcodec/v4l2_context.c +++ b/libavcodec/v4l2_context.c @@ -393,22 +393,54 @@ static int v4l2_release_buffers(V4L2Context* ctx) struct v4l2_requestbuffers req = { .memory = V4L2_MEMORY_MMAP, .type = ctx->type, - .count = 0, /* 0 -> unmaps buffers from the driver */ + .count = 0, /* 0 -> unmap all buffers from the driver */ }; - int i, j; + int ret, i, j; for (i = 0; i < ctx->num_buffers; i++) { V4L2Buffer *buffer = &ctx->buffers[i]; for (j = 0; j < buffer->num_planes; j++) { struct V4L2Plane_info *p = &buffer->plane_info[j]; + + if (V4L2_TYPE_IS_OUTPUT(ctx->type)) { + /* output buffers are not EXPORTED */ + goto unmap; + } + + if (ctx_to_m2mctx(ctx)->output_drm) { + /* use the DRM frame to close */ + if (buffer->drm_frame.objects[j].fd >= 0) { + if (close(buffer->drm_frame.objects[j].fd) < 0) { + av_log(logger(ctx), AV_LOG_ERROR, "%s close drm fd " + "[buffer=%2d, plane=%d, fd=%2d] - %s \n", + ctx->name, i, j, buffer->drm_frame.objects[j].fd, + av_err2str(AVERROR(errno))); + } + } + } +unmap: if (p->mm_addr && p->length) if (munmap(p->mm_addr, p->length) < 0) - av_log(logger(ctx), AV_LOG_ERROR, "%s unmap plane (%s))\n", ctx->name, av_err2str(AVERROR(errno))); + av_log(logger(ctx), AV_LOG_ERROR, "%s unmap plane (%s))\n", + ctx->name, av_err2str(AVERROR(errno))); } (This whole function feels like it might fit better in v4l2_buffers.c?) To check my understanding here of what you've got currently (please correct me if I make a mistake here): * When making a new set of buffers (on start or format change), VIDIOC_EXPBUF is called once for each V4L2 buffer to make a DRM PRIME fd for it. * Whenever you want to return a buffer, return the fd instead if using DRM PRIME output. * When returning a set of buffers (on close or format change), wait for all references to disappear and then close all of the fds before releasing the V4L2 buffers. We kept it as a context operation since release_buffers is not a per buffer operation (it just an operation that applies on all buffers, like all context operations IIRC ). The problem is that even if we close the file descriptors when all references have gone, the client might still have GEM objects associated so we would fail at releasing the buffers. Ok. This was noticed during testing (fixed in the test code with this commit) [1] [1] https://github.com/BayLibre/ffmpeg-drm/commit/714288ab9d86397dd8230068fd9a7d3d4d76b802 And a reminder was added to ffmpeg below } - return ioctl(ctx_to_m2mctx(ctx)->fd, VIDIOC_REQBUFS, &req); + ret = ioctl(ctx_to_m2mctx(ctx)->fd, VIDIOC_REQBUFS, &req); + if (ret < 0) { + av_log(logger(ctx), AV_LOG_ERROR, "release all %s buffers (%s)\n", + ctx->name, av_err2str(AVERROR(errno))); + + if (ctx_to_m2mctx(ctx)->output_drm) + av_log(logger(ctx), AV_LOG_ERROR, + "Make sure the DRM client releases all FB/GEM objects before closing the codec (ie):\n" + "for all buffers: \n" + " 1. drmModeRmFB(..)\n" + " 2. drmIoctl(.., DRM_IOCTL_GEM_CLOSE,... )\n"); Is it possible to hit this case? Waiting for all references to disappear seems like it should cover it. (And if the user has freed an object they are still using then that's certainly undefined behaviour, so if that's the only case here it would probably be better to abort() so that it's caught immediately.) yes (as per the above explanation) Does errno indicate that we've hit this case specifically rather than e.g. some sort of hardware problem (decoder device physically disconnected or whatever)? it just returns the standard "Device or resource busy" when we try to release the buffers since they are still in use Since it's a use-after-free on the part of the API user and therefore undefined behaviour, we should av_assert0() that it doesn't happen if we can identify it. yes I agree. should we assert on top of the error message or better get rid of the message and just add a comment to the code? (The KMS/GEM comments would also be rather confusing if the sink is something else - GL/EGL seems likely to be common, and OpenCL or Vulkan are certainly possible too. Maybe make that more generic.) - Mark
Re: [FFmpeg-devel] [PATCH 3/5] Renamed reinterlace to tinterlace
Hello, I have updated patch 3 according to review, removed all code related to the new flags (MERGE_TFF, MERGE_BFF) and threading functionality. On Sat, Jul 28, 2018 at 5:04 PM, Thomas Mundt wrote: > Hi, > > 2018-07-24 12:17 GMT+02:00 Vasile Toncu : > > > Fixed tabs. > > Thank you for the feedback. > > > > > {} > > +case MODE_INTERLEAVE_BOTTOM: > > +case MODE_INTERLEAVE_TOP: > > +y = y * 2; > > + > > +if (tinterlace->flags & FLAG_VLPF || tinterlace->flags & > > FLAG_CVLPF) { > > + > > +int lines, cols, cvlfp; > > +AVFrame *from_frame; > > +uint8_t *from, *to; > > +int from_step, to_step; > > + > > +lines = (tinterlace_mode == MODE_INTERLEAVE_TOP) ? (2 * > > out->height / y + 1) / 2 : (2 * out->height / y + 0) / 2; > > +cols = out->width / x; > > +from_frame = first; > > +from = from_frame->data[plane]; > > +to = out->data[plane]; > > + > > +if (tinterlace_mode == MODE_INTERLEAVE_BOTTOM) { > > +from = from + from_frame->linesize[plane]; > > +to = to + out->linesize[plane]; > > +} > > + > > +from_step = 2 * from_frame->linesize[plane]; > > +to_step = 2 * out->linesize[plane]; > > + > > +// when i = lines - aka first line > > +tinterlace->lowpass_line(to, cols, from, > > from_frame->linesize[plane], 0, clip_max); > > +to += to_step; > > +from += from_step; > > + > > +cvlfp = !!(tinterlace->flags & FLAG_CVLPF); > > +if (cvlfp) { > > +tinterlace->lowpass_line(to, cols, from, > > from_frame->linesize[plane], 0, clip_max); > > +to += to_step; > > +from += from_step; > > +} > > + > > +for (i = lines - 2 - 2 * cvlfp; i; i--) { > > +tinterlace->lowpass_line(to, cols, from, > > from_frame->linesize[plane], -from_frame->linesize[plane], clip_max); > > +to += to_step; > > +from += from_step; > > +} > > + > > +// when i == 1 - aka last line > > +tinterlace->lowpass_line(to, cols, from, 0, > > -from_frame->linesize[plane], clip_max); > > +to += to_step; > > +from += from_step; > > + > > +if (cvlfp) { > > +tinterlace->lowpass_line(to, cols, from, 0, > > -from_frame->linesize[plane], clip_max); > > +to += to_step; > > +from += from_step; > > +} > > + > > + > > +lines = (tinterlace_mode == MODE_INTERLEAVE_BOTTOM) ? ((2 * > > out->height / y) + 1) / 2 : (2 * out->height / y + 0) / 2; > > +cols = out->width / x; > > +from_frame = second; > > +from = from_frame->data[plane]; > > +to = out->data[plane]; > > + > > +if (tinterlace_mode == MODE_INTERLEAVE_TOP) { > > +from = from + from_frame->linesize[plane]; > > +to = to + out->linesize[plane]; > > } > > + > > +from_step = 2 * from_frame->linesize[plane]; > > +to_step = 2 * out->linesize[plane]; > > + > > +// when i = lines > > +tinterlace->lowpass_line(to, cols, from, > > from_frame->linesize[plane], 0, clip_max); > > +to += to_step; > > +from += from_step; > > + > > +if (cvlfp) { > > +tinterlace->lowpass_line(to, cols, from, > > from_frame->linesize[plane], 0, clip_max); > > +to += to_step; > > +from += from_step; > > +} > > + > > + > > +for (i = lines - 2 - 2 * cvlfp; i; i--) { > > +tinterlace->lowpass_line(to, cols, from, > > from_frame->linesize[plane], -from_frame->linesize[plane], clip_max); > > +to += to_step; > > +from += from_step; > > +} > > + > > +// when i == 1 > > +tinterlace->lowpass_line(to, cols, from, 0, > > -from_frame->linesize[plane], clip_max); > > +to += to_step; > > +from += from_step; > > + > > +if (cvlfp) { > > +tinterlace->lowpass_line(to, cols, from, 0, > > -from_frame->linesize[plane], clip_max); > > +to += to_step; > > +from += from_step; > > +} > > > > Compared to the one simple "for"-loop in the GPL version, this looks very > complicated. Maybe it´s ok here to just keep the original code since it has > been modified in the past anyway. > But at least you need to factor it out for not having the same code two > times in a row. > > {} > > +case MODE_MERGE_TFF: > > +case MODE_MERGE_BFF: > > +offset1 = (tinterlace_mode == MODE_MERGE_TFF) ? 0 : > > out->linesize[plane]; > > +offset2 = (tinterlace_mode == MODE_MERGE_TFF) ? > > out->linesize[plane]
Re: [FFmpeg-devel] [PATCH] avcodec: v4l2_m2m: add MJPEG enc/dec support
Hi Jorge, unfortunately don't have a SBC that features a V4L2 M2M MJPEG/JPEG encoder so I couldn't test it. Hi Mark, thanks for the extensive review. Too bad neither scenario worked fully. 2018-08-12 19:24 GMT+02:00 Mark Thompson : > On 12/08/18 15:40, Maxime Jourdan wrote: >> Tested on an Odroid-C2 with a V4L2 M2M MJPEG decoder. >> >> Signed-off-by: Maxime Jourdan >> --- >> configure | 3 +++ >> libavcodec/Makefile | 2 ++ >> libavcodec/allcodecs.c| 2 ++ >> libavcodec/v4l2_m2m_dec.c | 1 + >> libavcodec/v4l2_m2m_enc.c | 1 + >> 5 files changed, 9 insertions(+) >> >> diff --git a/configure b/configure >> index e718c1531c..5a5ba1ebcf 100755 >> --- a/configure >> +++ b/configure >> @@ -2939,6 +2939,8 @@ >> hevc_vaapi_encoder_deps="VAEncPictureParameterBufferHEVC" >> hevc_vaapi_encoder_select="cbs_h265 vaapi_encode" >> hevc_v4l2m2m_decoder_deps="v4l2_m2m hevc_v4l2_m2m" >> hevc_v4l2m2m_encoder_deps="v4l2_m2m hevc_v4l2_m2m" >> +mjpeg_v4l2m2m_decoder_deps="v4l2_m2m mjpeg_v4l2_m2m" >> +mjpeg_v4l2m2m_encoder_deps="v4l2_m2m mjpeg_v4l2_m2m" >> mjpeg_cuvid_decoder_deps="cuvid" >> mjpeg_qsv_encoder_deps="libmfx" >> mjpeg_qsv_encoder_select="qsvenc" >> @@ -6252,6 +6254,7 @@ check_header linux/videodev2.h >> test_code cc linux/videodev2.h "struct v4l2_frmsizeenum vfse; >> vfse.discrete.width = 0;" && enable_sanitized >> struct_v4l2_frmivalenum_discrete >> check_cc v4l2_m2m linux/videodev2.h "int i = V4L2_CAP_VIDEO_M2M_MPLANE | >> V4L2_CAP_VIDEO_M2M | V4L2_BUF_FLAG_LAST;" >> check_cc vc1_v4l2_m2m linux/videodev2.h "int i = V4L2_PIX_FMT_VC1_ANNEX_G;" >> +check_cc mjpeg_v4l2_m2m linux/videodev2.h "int i = V4L2_PIX_FMT_MJPEG;" > > The existing format code unconditionally assumes this value is present > (libavcodec/v4l2_fmt.c:54 - it's been around forever for input devices), so > the check isn't needed. ack. >> check_cc mpeg1_v4l2_m2m linux/videodev2.h "int i = V4L2_PIX_FMT_MPEG1;" >> check_cc mpeg2_v4l2_m2m linux/videodev2.h "int i = V4L2_PIX_FMT_MPEG2;" >> check_cc mpeg4_v4l2_m2m linux/videodev2.h "int i = V4L2_PIX_FMT_MPEG4;" >> diff --git a/libavcodec/Makefile b/libavcodec/Makefile >> index 6e40702947..cd975739ef 100644 >> --- a/libavcodec/Makefile >> +++ b/libavcodec/Makefile >> @@ -415,7 +415,9 @@ OBJS-$(CONFIG_METASOUND_DECODER) += metasound.o >> metasound_data.o \ >>twinvq.o >> OBJS-$(CONFIG_MICRODVD_DECODER)+= microdvddec.o ass.o >> OBJS-$(CONFIG_MIMIC_DECODER) += mimic.o >> +OBJS-$(CONFIG_MJPEG_V4L2M2M_DECODER) += v4l2_m2m_dec.o >> OBJS-$(CONFIG_MJPEG_DECODER) += mjpegdec.o >> +OBJS-$(CONFIG_MJPEG_V4L2M2M_ENCODER) += v4l2_m2m_enc.o > > Use the same ordering as for other codecs. ack. >> OBJS-$(CONFIG_MJPEG_ENCODER) += mjpegenc.o mjpegenc_common.o \ >>mjpegenc_huffman.o >> OBJS-$(CONFIG_MJPEGB_DECODER) += mjpegbdec.o >> diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c >> index ab3ec04251..af4870a54d 100644 >> --- a/libavcodec/allcodecs.c >> +++ b/libavcodec/allcodecs.c >> @@ -173,7 +173,9 @@ extern AVCodec ff_magicyuv_encoder; >> extern AVCodec ff_magicyuv_decoder; >> extern AVCodec ff_mdec_decoder; >> extern AVCodec ff_mimic_decoder; > > This file gets parsed in order to make the table of decoders/encoders, so: > >> +extern AVCodec ff_mjpeg_v4l2m2m_encoder; >> extern AVCodec ff_mjpeg_encoder; > > The new entry for the encoder should be in the non-default section at the > bottom. > >> +extern AVCodec ff_mjpeg_v4l2m2m_decoder; >> extern AVCodec ff_mjpeg_decoder; > > The new entry for the decoder should be after the normal decoder. ack. >> extern AVCodec ff_mjpegb_decoder; >> extern AVCodec ff_mmvideo_decoder; >> diff --git a/libavcodec/v4l2_m2m_dec.c b/libavcodec/v4l2_m2m_dec.c >> index a4e2f02596..80a09f7a43 100644 >> --- a/libavcodec/v4l2_m2m_dec.c >> +++ b/libavcodec/v4l2_m2m_dec.c >> @@ -231,6 +231,7 @@ AVCodec ff_ ## NAME ## _v4l2m2m_decoder = { \ >> >> M2MDEC(h264, "H.264", AV_CODEC_ID_H264, "h264_mp4toannexb"); >> M2MDEC(hevc, "HEVC", AV_CODEC_ID_HEVC, "hevc_mp4toannexb"); >> +M2MDEC(mjpeg, "MJPEG", AV_CODEC_ID_MJPEG, NULL); >> M2MDEC(mpeg1, "MPEG1", AV_CODEC_ID_MPEG1VIDEO, NULL); >> M2MDEC(mpeg2, "MPEG2", AV_CODEC_ID_MPEG2VIDEO, NULL); >> M2MDEC(mpeg4, "MPEG4", AV_CODEC_ID_MPEG4, NULL); >> diff --git a/libavcodec/v4l2_m2m_enc.c b/libavcodec/v4l2_m2m_enc.c >> index 4c9ea1fd92..b025f59275 100644 >> --- a/libavcodec/v4l2_m2m_enc.c >> +++ b/libavcodec/v4l2_m2m_enc.c >> @@ -345,6 +345,7 @@ AVCodec ff_ ## NAME ## _v4l2m2m_encoder = { \ >> .wrapper_name = "v4l2m2m", \ >> }; >> >> +M2MENC(mjpeg,"MJPEG", AV_CODEC_ID_MJPEG); >> M2MENC(mpeg4,"MPEG4", AV_CODEC_ID_MPEG4); >> M2MENC(h263, "H.263", AV_CODEC_ID_H263); >> M2MENC(h264, "H.264", AV_CODEC_ID_H264); > > Since MJPEG is intra-only, it probably wants to avoid setting options like > GOP size and B-frames
[FFmpeg-devel] [GSOC] [PATCH 1/2] lavfi/vf_colorconstancy: changing options ranges
Hi, This patch changes the maximum value for minknorm to a more sane value and fixes check for sigma value when difford > 0. It also itroduces some minor cosmetic edits(spaces and so). Thanks. >From 8f4270e4aad285a8652e1831e828439cdb13620a Mon Sep 17 00:00:00 2001 From: Mina Date: Mon, 13 Aug 2018 01:29:28 +0200 Subject: [PATCH 1/2] lavfi/vf_colorconstancy: changing options ranges Signed-off-by: Mina --- doc/filters.texi| 6 +++--- libavfilter/vf_colorconstancy.c | 20 ++-- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/doc/filters.texi b/doc/filters.texi index d6c15837f2..267bd04a43 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -9955,13 +9955,13 @@ The order of differentiation to be applied on the scene. Must be chosen in the r @item minknorm The Minkowski parameter to be used for calculating the Minkowski distance. Must -be chosen in the range [0,65535] and default value is 1. Set to 0 for getting +be chosen in the range [0,20] and default value is 1. Set to 0 for getting max value instead of calculating Minkowski distance. @item sigma The standard deviation of Gaussian blur to be applied on the scene. Must be -chosen in the range [0,1024.0] and default value = 1. Sigma can't be set to 0 -if @var{difford} is greater than 0. +chosen in the range [0,1024.0] and default value = 1. floor( @var{sigma} * break_off_sigma(3) ) +can't be euqal to 0 if @var{difford} is greater than 0. @end table @subsection Examples diff --git a/libavfilter/vf_colorconstancy.c b/libavfilter/vf_colorconstancy.c index 7194688dfa..e3bb39e51b 100644 --- a/libavfilter/vf_colorconstancy.c +++ b/libavfilter/vf_colorconstancy.c @@ -28,7 +28,6 @@ * J. van de Weijer, Th. Gevers, A. Gijsenij "Edge-Based Color Constancy". */ -#include "libavutil/bprint.h" #include "libavutil/imgutils.h" #include "libavutil/opt.h" #include "libavutil/pixdesc.h" @@ -42,6 +41,8 @@ #define GREY_EDGE "greyedge" +#define SQRT3 1.73205080757 + #define NUM_PLANES3 #define MAX_DIFF_ORD 2 #define MAX_META_DATA 4 @@ -145,7 +146,7 @@ static int set_gauss(AVFilterContext *ctx) sum1 = 0.0; for (i = 0; i < filtersize; ++i) { s->gauss[1][i] = - (GINDX(filtersize, i) / pow(sigma, 2)) * s->gauss[0][i]; -sum1 += s->gauss[1][i] *GINDX(filtersize, i); +sum1 += s->gauss[1][i] * GINDX(filtersize, i); } for (i = 0; i < filtersize; ++i) { @@ -595,7 +596,6 @@ static int diagonal_transformation(AVFilterContext *ctx, void *arg, int jobnr, i ThreadData *td = arg; AVFrame *in = td->in; AVFrame *out = td->out; -double sqrt3 = pow(3.0, 0.5); int plane; for (plane = 0; plane < NUM_PLANES; ++plane) { @@ -610,7 +610,7 @@ static int diagonal_transformation(AVFilterContext *ctx, void *arg, int jobnr, i unsigned i; for (i = slice_start; i < slice_end; ++i) { -temp = src[i] / (s->white[plane] * sqrt3); +temp = src[i] / (s->white[plane] * SQRT3); dst[i] = av_clip_uint8((int)(temp + 0.5)); } } @@ -657,12 +657,12 @@ static int config_props(AVFilterLink *inlink) double sigma = s->sigma; int ret; -if (!sigma && s->difford) { -av_log(ctx, AV_LOG_ERROR, "Sigma can't be set to 0 when difford > 0.\n"); +if (!floor(break_off_sigma * sigma + 0.5) && s->difford) { +av_log(ctx, AV_LOG_ERROR, "floor(%f * sigma) must be > 0 when difford > 0.\n", break_off_sigma); return AVERROR(EINVAL); } -s->filtersize = 2 * floor(break_off_sigma * s->sigma + 0.5) + 1; +s->filtersize = 2 * floor(break_off_sigma * sigma + 0.5) + 1; if (ret=set_gauss(ctx)) { return ret; } @@ -735,9 +735,9 @@ static const AVFilterPad colorconstancy_outputs[] = { #if CONFIG_GREYEDGE_FILTER static const AVOption greyedge_options[] = { -{ "difford", "set differentiation order", OFFSET(difford), AV_OPT_TYPE_INT,{.i64=1}, 0, 2, FLAGS }, -{ "minknorm", "set Minkowski norm",OFFSET(minknorm), AV_OPT_TYPE_INT,{.i64=1}, 0, 65535, FLAGS }, -{ "sigma","set sigma", OFFSET(sigma),AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0.0, 1024.0, FLAGS }, +{ "difford", "set differentiation order", OFFSET(difford), AV_OPT_TYPE_INT,{.i64=1}, 0, 2, FLAGS }, +{ "minknorm", "set Minkowski norm",OFFSET(minknorm), AV_OPT_TYPE_INT,{.i64=1}, 0, 20, FLAGS }, +{ "sigma","set sigma", OFFSET(sigma),AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0.0, 1024.0, FLAGS }, { NULL } }; -- 2.17.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [GSOC] [PATCH 1/2] lavfi/vf_colorconstancy: adding weighted_ greyedge
Hi, This patch introduces a new improved color constancy algorithm based on previously implemented greyedge algorithm. Thanks. >From ec68204b9b081e0f0861ab50767c41559ed7e7b6 Mon Sep 17 00:00:00 2001 From: Mina Date: Mon, 13 Aug 2018 01:49:24 +0200 Subject: [PATCH 2/2] lavfi/vf_colorconstancy: adding weighted_ greyedge Signed-off-by: Mina --- doc/filters.texi| 39 libavfilter/Makefile| 1 + libavfilter/allfilters.c| 1 + libavfilter/vf_colorconstancy.c | 322 4 files changed, 288 insertions(+), 75 deletions(-) diff --git a/doc/filters.texi b/doc/filters.texi index 267bd04a43..07dacec831 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -17154,6 +17154,45 @@ separatefields,select=eq(mod(n,4),0)+eq(mod(n,4),3),weave @end example @end itemize +@section weighted_greyedge +A color constancy variation filter which estimates scene illumination via weighted grey edge +algorithm and corrects the scene colors accordingly. + +See: @url{http://refbase.cvc.uab.es/files/GGW2012.pdf} + +The filter accepts the following options: + +@table @option +@item minknorm +The Minkowski parameter to be used for calculating the Minkowski distance. Must +be chosen in the range [1,20] and default value is 1. + +@item sigma +The standard deviation of Gaussian blur to be applied on the scene. Must be +chosen in the range [0.2,1024.0] and default value = 1. + +@item wmap_k +The power applied to the weight map to emphasis heigher weights. Must be chosen +in the range [1,20] and default value = 2. + +@item iters +The max number of iterations for performing the algorithm. Must be chosen in the +range [1,20] and default value = 5. + +@item angerr +The angular error threshold in degrees for stoping the algorithm. Must be chosen +in the range [0,360] and default value = 0.001. +@end table + +@subsection Examples +@itemize + +@item +@example +weighted_greyedge=minknorm=5:sigma=2:wmap_k=10:iters=10:angerr=0.0005 +@end example +@end itemize + @section xbr Apply the xBR high-quality magnification filter which is designed for pixel art. It follows a set of edge-detection rules, see diff --git a/libavfilter/Makefile b/libavfilter/Makefile index e5d3a57af7..4086e941fa 100644 --- a/libavfilter/Makefile +++ b/libavfilter/Makefile @@ -392,6 +392,7 @@ OBJS-$(CONFIG_VSTACK_FILTER) += vf_stack.o framesync.o OBJS-$(CONFIG_W3FDIF_FILTER) += vf_w3fdif.o OBJS-$(CONFIG_WAVEFORM_FILTER) += vf_waveform.o OBJS-$(CONFIG_WEAVE_FILTER) += vf_weave.o +OBJS-$(CONFIG_WEIGHTED_GREYEDGE_FILTER) += vf_colorconstancy.o OBJS-$(CONFIG_XBR_FILTER)+= vf_xbr.o OBJS-$(CONFIG_YADIF_FILTER) += vf_yadif.o OBJS-$(CONFIG_ZMQ_FILTER)+= f_zmq.o diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c index 9732ae5345..8c088e2c1e 100644 --- a/libavfilter/allfilters.c +++ b/libavfilter/allfilters.c @@ -373,6 +373,7 @@ extern AVFilter ff_vf_vstack; extern AVFilter ff_vf_w3fdif; extern AVFilter ff_vf_waveform; extern AVFilter ff_vf_weave; +extern AVFilter ff_vf_weighted_greyedge; extern AVFilter ff_vf_xbr; extern AVFilter ff_vf_yadif; extern AVFilter ff_vf_zmq; diff --git a/libavfilter/vf_colorconstancy.c b/libavfilter/vf_colorconstancy.c index e3bb39e51b..3b84a637c7 100644 --- a/libavfilter/vf_colorconstancy.c +++ b/libavfilter/vf_colorconstancy.c @@ -26,6 +26,14 @@ * * @cite * J. van de Weijer, Th. Gevers, A. Gijsenij "Edge-Based Color Constancy". + * + * @cite + * J. van de Weijer, Th. Gevers, and J. Geusebroek, + * âEdge and corner detection by photometric quasi-invariantsâ. + * + * @cite + * A. Gijsenij, Th. Gevers, J. van de Weijer, + * "Improving Color Constancy by Photometric Edge Weighting". */ #include "libavutil/imgutils.h" @@ -39,7 +47,8 @@ #include -#define GREY_EDGE "greyedge" +#define GREY_EDGE "greyedge" +#define WEIGHTED_GREY_EDGE "weighted_greyedge" #define SQRT3 1.73205080757 @@ -79,6 +88,10 @@ typedef struct ColorConstancyContext { int minknorm; /**< @minknorm = 0 : getMax instead */ double sigma; +int wmap_k; +int iters; +double angerr_thresh; + int nb_threads; int planeheight[4]; int planewidth[4]; @@ -477,53 +490,73 @@ static int filter_slice_grey_edge(AVFilterContext* ctx, void* arg, int jobnr, in } /** - * Main control function for grey edge algorithm. + * Slice function for weighted grey edge algorithm that is called iteratively to + * calculate and apply weight scheme. * * @param ctx the filter context. - * @param in frame to perfrom grey edge on. + * @param arg data to be passed between threads. + * @param jobnr current job nubmer. + * @param nb_jobs total number of jobs. * - * @return 0 in case of success, a negative value corresponding to an - * AVERROR code in case of failure. + * @return 0. */ -static int filter_grey_edge(AVFilte
[FFmpeg-devel] [PATCH 5/6] avcodec/cfhd: Move peak_table() and difference_coding() calls after the existing coefficient count check
Fixes: out of array access Fixes: 9509/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CFHD_fuzzer-5283250636324864 Fixes: 9572/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CFHD_fuzzer-4920757409808384 Fixes: 9596/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CFHD_fuzzer-5114917580439552 Fixes: 9640/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CFHD_fuzzer-6247840698335232 Fixes: 9659/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CFHD_fuzzer-6079554987753472 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/cfhd.c | 14 -- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/libavcodec/cfhd.c b/libavcodec/cfhd.c index 76838f0869..1959762f0e 100644 --- a/libavcodec/cfhd.c +++ b/libavcodec/cfhd.c @@ -668,11 +668,6 @@ static int cfhd_decode(AVCodecContext *avctx, void *data, int *got_frame, for (i = 0; i < run; i++) *coeff_data++ = coeff; } -if (s->peak.level) -peak_table(coeff_data - expected, &s->peak, expected); -if (s->difference_coding) - difference_coding(s->plane[s->channel_num].subband[s->subband_num_actual], highpass_width, highpass_height); - } else { while (1) { UPDATE_CACHE(re, &s->gb); @@ -692,11 +687,6 @@ static int cfhd_decode(AVCodecContext *avctx, void *data, int *got_frame, for (i = 0; i < run; i++) *coeff_data++ = coeff; } -if (s->peak.level) -peak_table(coeff_data - expected, &s->peak, expected); -if (s->difference_coding) - difference_coding(s->plane[s->channel_num].subband[s->subband_num_actual], highpass_width, highpass_height); - } CLOSE_READER(re, &s->gb); } @@ -706,6 +696,10 @@ static int cfhd_decode(AVCodecContext *avctx, void *data, int *got_frame, ret = AVERROR(EINVAL); goto end; } +if (s->peak.level) +peak_table(coeff_data - expected, &s->peak, expected); +if (s->difference_coding) + difference_coding(s->plane[s->channel_num].subband[s->subband_num_actual], highpass_width, highpass_height); bytes = FFALIGN(AV_CEIL_RSHIFT(get_bits_count(&s->gb), 3), 4); if (bytes > bytestream2_get_bytes_left(&gb)) { -- 2.18.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 6/6] avcodec/cfhd: Use the actual count instead of the expected in peak_table()
Fixes: out of array access (no testcase) Signed-off-by: Michael Niedermayer --- libavcodec/cfhd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/cfhd.c b/libavcodec/cfhd.c index 1959762f0e..846d334b9b 100644 --- a/libavcodec/cfhd.c +++ b/libavcodec/cfhd.c @@ -697,7 +697,7 @@ static int cfhd_decode(AVCodecContext *avctx, void *data, int *got_frame, goto end; } if (s->peak.level) -peak_table(coeff_data - expected, &s->peak, expected); +peak_table(coeff_data - count, &s->peak, count); if (s->difference_coding) difference_coding(s->plane[s->channel_num].subband[s->subband_num_actual], highpass_width, highpass_height); -- 2.18.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 4/6] avcodec/lagarith: Optimize FRAME_SOLID_RGBA
Fixes: Timeout Fixes: 9484/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_LAGARITH_fuzzer-5707859156271104 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/lagarith.c | 8 +++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libavcodec/lagarith.c b/libavcodec/lagarith.c index 510a6ff2d6..b9a0649c31 100644 --- a/libavcodec/lagarith.c +++ b/libavcodec/lagarith.c @@ -572,8 +572,14 @@ static int lag_decode_frame(AVCodecContext *avctx, dst = p->data[0]; if (frametype == FRAME_SOLID_RGBA) { +int w2 = avctx->width>>2; +uint64_t c = ((uint64_t)offset_gu << 32) | offset_gu; for (j = 0; j < avctx->height; j++) { -for (i = 0; i < avctx->width; i++) +for (i = 0; i < w2; i++) { +AV_WN64(dst + i * 16, c); +AV_WN64(dst + i * 16 + 8, c); +} +for (i = 4*w2; i < avctx->width; i++) AV_WN32(dst + i * 4, offset_gu); dst += p->linesize[0]; } -- 2.18.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 3/6] avcodec/shorten: Fix signed 32bit overflow in shift in shorten_decode_frame()
Fixes: runtime error: left shift of 1 by 31 places cannot be represented in type 'int' Fixes: 9480/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SHORTEN_fuzzer-6647324284551168 -rss_limit_mb=2000 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/shorten.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/shorten.c b/libavcodec/shorten.c index 054494f8ce..1ffb7d8d79 100644 --- a/libavcodec/shorten.c +++ b/libavcodec/shorten.c @@ -715,7 +715,7 @@ static int shorten_decode_frame(AVCodecContext *avctx, void *data, if (s->version < 2) s->offset[channel][s->nmean - 1] = sum / s->blocksize; else -s->offset[channel][s->nmean - 1] = s->bitshift == 32 ? 0 : (sum / s->blocksize) * (1 << s->bitshift); +s->offset[channel][s->nmean - 1] = s->bitshift == 32 ? 0 : (sum / s->blocksize) * (1LL << s->bitshift); } /* copy wrap samples for use with next block */ -- 2.18.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 2/6] avcodec/shorten: Fix integer overflow in residual/LPC combination
Fixes: signed integer overflow: -540538872 + -2012739576 cannot be represented in type 'int' Fixes: 9255/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SHORTEN_fuzzer-5758630052757504 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/shorten.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/shorten.c b/libavcodec/shorten.c index 9094d3fc55..054494f8ce 100644 --- a/libavcodec/shorten.c +++ b/libavcodec/shorten.c @@ -391,7 +391,7 @@ static int decode_subframe_lpc(ShortenContext *s, int command, int channel, for (j = 0; j < pred_order; j++) sum += coeffs[j] * (unsigned)s->decoded[channel][i - j - 1]; s->decoded[channel][i] = get_sr_golomb_shorten(&s->gb, residual_size) + - (sum >> qshift); + (unsigned)(sum >> qshift); } /* add offset to current samples */ -- 2.18.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 1/6] avcodec/shorten: Check verbatim length
Fixes: Timeout Fixes: 9252/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SHORTEN_fuzzer-5780720709533696 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/shorten.c | 5 + 1 file changed, 5 insertions(+) diff --git a/libavcodec/shorten.c b/libavcodec/shorten.c index 0f491090fd..9094d3fc55 100644 --- a/libavcodec/shorten.c +++ b/libavcodec/shorten.c @@ -623,6 +623,11 @@ static int shorten_decode_frame(AVCodecContext *avctx, void *data, switch (cmd) { case FN_VERBATIM: len = get_ur_golomb_shorten(&s->gb, VERBATIM_CKSIZE_SIZE); +if (len < 0 || len > get_bits_left(&s->gb)) { +av_log(avctx, AV_LOG_ERROR, "verbatim length %d invalid\n", + len); +return AVERROR_INVALIDDATA; +} while (len--) get_ur_golomb_shorten(&s->gb, VERBATIM_BYTE_SIZE); break; -- 2.18.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avcodec: v4l2_m2m: add MJPEG enc/dec support
On 13/08/18 00:33, Maxime Jourdan wrote: > Hi Jorge, unfortunately don't have a SBC that features a V4L2 M2M > MJPEG/JPEG encoder so I couldn't test it. > > Hi Mark, thanks for the extensive review. Too bad neither scenario worked > fully. > > 2018-08-12 19:24 GMT+02:00 Mark Thompson : >> On 12/08/18 15:40, Maxime Jourdan wrote: >>> Tested on an Odroid-C2 with a V4L2 M2M MJPEG decoder. >>> >>> Signed-off-by: Maxime Jourdan >>> --- >>> configure | 3 +++ >>> libavcodec/Makefile | 2 ++ >>> libavcodec/allcodecs.c| 2 ++ >>> libavcodec/v4l2_m2m_dec.c | 1 + >>> libavcodec/v4l2_m2m_enc.c | 1 + >>> 5 files changed, 9 insertions(+) >>> >>> ... >>> diff --git a/libavcodec/v4l2_m2m_enc.c b/libavcodec/v4l2_m2m_enc.c >>> index 4c9ea1fd92..b025f59275 100644 >>> --- a/libavcodec/v4l2_m2m_enc.c >>> +++ b/libavcodec/v4l2_m2m_enc.c >>> @@ -345,6 +345,7 @@ AVCodec ff_ ## NAME ## _v4l2m2m_encoder = { \ >>> .wrapper_name = "v4l2m2m", \ >>> }; >>> >>> +M2MENC(mjpeg,"MJPEG", AV_CODEC_ID_MJPEG); >>> M2MENC(mpeg4,"MPEG4", AV_CODEC_ID_MPEG4); >>> M2MENC(h263, "H.263", AV_CODEC_ID_H263); >>> M2MENC(h264, "H.264", AV_CODEC_ID_H264); >> >> Since MJPEG is intra-only, it probably wants to avoid setting options like >> GOP size and B-frames (currently this gives me warnings for each of these >> options that it failed to set them, visible in log below). > > Ack, although right now I'm not sure what's the cleanest way to enforce this. I guess make an intra-only flag based on the codec and then add "if (!intra-only)" around applying those settings in the encoder. >> Trying this on an Odroid XU4 (Exynos S5P running Linux 4.14.55), it looks >> like we need to somehow allow both "MJPG" and "JPEG" as fourccs. Reordering >> the two lines in libavcodec/v4l2_fmt.c to put "JPEG" first makes it get past >> that test, but obviously that will stop it from working on an "MJPG" device. > > I see, so some rework will be needed to account for AV_CODECs that > appear multiple times in the list. Yeah, probably. (Assuming there isn't some special difference between them which I have missed.) >> >> So, for testing I used this patch: >> >> diff --git a/libavcodec/v4l2_fmt.c b/libavcodec/v4l2_fmt.c >> index 6df47e3..06b57db 100644 >> --- a/libavcodec/v4l2_fmt.c >> +++ b/libavcodec/v4l2_fmt.c >> @@ -51,8 +51,8 @@ static const struct fmt_conversion { >> { AV_FMT(YUV410P), AV_CODEC(RAWVIDEO),V4L2_FMT(YUV410) }, >> { AV_FMT(YUV410P), AV_CODEC(RAWVIDEO),V4L2_FMT(YVU410) }, >> { AV_FMT(NV12),AV_CODEC(RAWVIDEO),V4L2_FMT(NV12) }, >> -{ AV_FMT(NONE),AV_CODEC(MJPEG), V4L2_FMT(MJPEG) }, >> { AV_FMT(NONE),AV_CODEC(MJPEG), V4L2_FMT(JPEG) }, >> +{ AV_FMT(NONE),AV_CODEC(MJPEG), V4L2_FMT(MJPEG) }, >> #ifdef V4L2_PIX_FMT_SRGGB8 >> { AV_FMT(BAYER_BGGR8), AV_CODEC(RAWVIDEO),V4L2_FMT(SBGGR8) }, >> { AV_FMT(BAYER_GBRG8), AV_CODEC(RAWVIDEO),V4L2_FMT(SGBRG8) }, >> >> >> After getting past that, the decoder seems to hang for me pretty much >> immediately on a DQBUF call. > > Did dmesg have anything interesting to say ? Huh, I did not think to look there. Running again, I get the following when SIGINTing to kill the decoder (nothing before that): [ 196.346037] [ cut here ] [ 196.346137] WARNING: CPU: 0 PID: 972 at drivers/media/v4l2-core/videobuf2-core.c:1655 __vb2_queue_cancel+0x17c/0x1e4 [ 196.346154] Modules linked in: cpufreq_conservative cpufreq_userspace cpufreq_powersave spidev spi_s3c64xx evdev gpio_keys uio_pdrv_genirq uio extcon_usb_gpio exynos_gpiomem uvcvideo snd_usb_audio snd_hwdep snd_usbmidi_lib videobuf2_vmalloc snd_rawmidi snd_seq_device ipv6 [ 196.346424] CPU: 0 PID: 972 Comm: ffmpeg_g Tainted: GW 4.14.55-133 #1 [ 196.346441] Hardware name: ODROID-XU4 [ 196.346522] [] (unwind_backtrace) from [] (show_stack+0x10/0x14) [ 196.346585] [] (show_stack) from [] (dump_stack+0x84/0x98) [ 196.346655] [] (dump_stack) from [] (__warn+0xec/0x104) [ 196.346717] [] (__warn) from [] (warn_slowpath_null+0x20/0x28) [ 196.346780] [] (warn_slowpath_null) from [] (__vb2_queue_cancel+0x17c/0x1e4) [ 196.346846] [] (__vb2_queue_cancel) from [] (vb2_core_queue_release+0x18/0x38) [ 196.346906] [] (vb2_core_queue_release) from [] (v4l2_m2m_ctx_release+0x1c/0x28) [ 196.346969] [] (v4l2_m2m_ctx_release) from [] (s5p_jpeg_release+0x28/0x58) [ 196.347030] [] (s5p_jpeg_release) from [] (v4l2_release+0x38/0x74) [ 196.347096] [] (v4l2_release) from [] (__fput+0x84/0x1cc) [ 196.347156] [] (__fput) from [] (task_work_run+0x90/0xb0) [ 196.347209] [] (task_work_run) from [] (do_exit+0x390/0xb50) [ 196.347259] [] (do_exit) from [] (do_group_exit+0x3c/0xbc) [ 196.347310] [] (do_group_exit) from [] (get_signal+0x300/0x678) [ 196.347373] [] (get_signal) from [] (do_signal+0x64/0x430) [ 196.347433] [] (do_signal) from [] (do_work_pending+0xac/0xc4) [ 19
Re: [FFmpeg-devel] [PATCH 0/3] enable multi-slices in vaapi_h264/265 encoder
On Mon, Jul 30, 2018 at 7:49 PM Jun Zhao wrote: > > V6: - Use rectangular slices and refine the code. > > V5: - In h265_vaapi encoder, when setting slice number > max slice number > supported by driver, report error and return. Same as h264_vaapi. > - Clean the logic when setting first_slice_segment_in_pic_flags. > > V4: - Change the array malloc function. > - Clean the pointless condition check when free the memory. > > V3: - Making pic->slices be VAAPIEncodeSlice* instead of VAAPIEncodeSlice**. > - Fix resource (vaBuffer) lead when realloc pic->param_buffers fail. > - Adjust max_slices location in VAAPIEncodeContext. > - Re-work distributing the macro-blocks for multi-slices function. > > V2: - Change the slice/parameter buffers to dynamic alloc and split the > mutil-slice support for AVC/HEVC. > > Jun Zhao (3): > lavc/vaapi_encode: Add max slices number query. > lavc/vaapi_encode_h264: respect "slices" option in h264 vaapi encoder > lavc/vaapi_encode_h265: respect "slices" option in h265 vaapi encoder > > libavcodec/vaapi_encode.c |4 > libavcodec/vaapi_encode.h |4 > libavcodec/vaapi_encode_h264.c | 31 +-- > libavcodec/vaapi_encode_h265.c | 30 -- > 4 files changed, 57 insertions(+), 12 deletions(-) > Ping, some guys can you help to review the patches? ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel