Re: [FFmpeg-devel] [PATCH v5 1/3] libavfilter/vf_find_rect: convert the object image to gray8 format instead of failed directly
On Sat, Jun 15, 2019 at 3:16 AM Michael Niedermayer wrote: > On Wed, Jun 12, 2019 at 06:57:29PM +0800, lance.lmw...@gmail.com wrote: > > From: Limin Wang > > > > Signed-off-by: Limin Wang > > --- > > doc/filters.texi | 2 +- > > libavfilter/vf_find_rect.c | 39 +++--- > > 2 files changed, 29 insertions(+), 12 deletions(-) > > > > diff --git a/doc/filters.texi b/doc/filters.texi > > index ec1c7c7591..90c57430a6 100644 > > --- a/doc/filters.texi > > +++ b/doc/filters.texi > > @@ -10150,7 +10150,7 @@ It accepts the following options: > > > > @table @option > > @item object > > -Filepath of the object image, needs to be in gray8. > > +Filepath of the object image. > > > > @item threshold > > Detection threshold, default is 0.5. > > diff --git a/libavfilter/vf_find_rect.c b/libavfilter/vf_find_rect.c > > index d7e6579af7..ee6c3f4b45 100644 > > --- a/libavfilter/vf_find_rect.c > > +++ b/libavfilter/vf_find_rect.c > > @@ -28,6 +28,7 @@ > > #include "internal.h" > > > > #include "lavfutils.h" > > +#include "lswsutils.h" > > > > #define MAX_MIPMAPS 5 > > > > @@ -244,6 +245,9 @@ static av_cold int init(AVFilterContext *ctx) > > { > > FOCContext *foc = ctx->priv; > > int ret, i; > > +uint8_t *tmp_data[4] = { NULL }; > > +int tmp_linesize[4], width, height; > > +enum AVPixelFormat pix_fmt; > > > > if (!foc->obj_filename) { > > av_log(ctx, AV_LOG_ERROR, "object filename not set\n"); > > @@ -254,24 +258,37 @@ static av_cold int init(AVFilterContext *ctx) > > if (!foc->obj_frame) > > return AVERROR(ENOMEM); > > > > -if ((ret = ff_load_image(foc->obj_frame->data, > foc->obj_frame->linesize, > > - >obj_frame->width, > >obj_frame->height, > > - >obj_frame->format, > foc->obj_filename, ctx)) < 0) > > -return ret; > > - > > -if (foc->obj_frame->format != AV_PIX_FMT_GRAY8) { > > -av_log(ctx, AV_LOG_ERROR, "object image is not a grayscale > image\n"); > > -return AVERROR(EINVAL); > > -} > > +if ((ret = ff_load_image(tmp_data, tmp_linesize, > > + , , > > + _fmt, foc->obj_filename, ctx)) < 0) > > +goto error; > > + > > +/* convert object image to gray8 format with same width and height > */ > > +foc->obj_frame->format = AV_PIX_FMT_GRAY8; > > +foc->obj_frame->width = width; > > +foc->obj_frame->height = height; > > +if ((ret = ff_scale_image(foc->obj_frame->data, > foc->obj_frame->linesize, > > +foc->obj_frame->width, foc->obj_frame->height, > foc->obj_frame->format, > > +tmp_data, tmp_linesize, width, height, pix_fmt, > ctx)) < 0) > > +goto error; > > +av_freep(_data[0]); > > Iam not sure i understand what this patch is intending to do > > Before a grayscale image was needed, after the patch anything is accepted > but > only grayscale is used. This is quite unexpected for a user who might > expect > color to be used if color is accpeted. > Generally, doing something that is unexpected by the user is not good > > The goal is make the common user to use it more friendly. When I'm do the testing, I have got some object file isn't gray image, I had to use ffmpeg convert it to gray every time. although I don't care for only gray color is used clearly. How about to add description to explain we use gray color only for the compare now. > [...] > -- > Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB > > Those who are best at talking, realize last or never when they are wrong. > ___ > 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".
Re: [FFmpeg-devel] [PATCH v5 3/3] libavfilter/vf_find_rect: convert the object image to gray8 format instead of failed directly
On Sat, Jun 15, 2019 at 3:10 AM Michael Niedermayer wrote: > On Sat, Jun 15, 2019 at 12:48:26AM +0800, lance.lmw...@gmail.com wrote: > > From: Limin Wang > > > > Signed-off-by: Limin Wang > > --- > > doc/filters.texi| 2 +- > > libavfilter/vf_cover_rect.c | 40 > > > 2 files changed, 33 insertions(+), 9 deletions(-) > > The subject is "libavfilter/vf_find_rect: convert the object image to > gray8 format instead of failed directly" > while this changes vf_cover_rect instead of vf_find_rect > > Sorry, when I split the patch, I copy the subject from patch wrongly. Have update the subject. > [...] > -- > Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB > > Does the universe only have a finite lifespan? No, its going to go on > forever, its just that you wont like living in it. -- Hiranya Peiri > ___ > 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".
Re: [FFmpeg-devel] [PATCH v5 2/3] vf_find_rect.c: use the optimized sad function to improve the find performance
On Sat, Jun 15, 2019 at 3:02 AM Michael Niedermayer wrote: > Hi > > On Wed, Jun 12, 2019 at 06:57:30PM +0800, lance.lmw...@gmail.com wrote: > > From: Limin Wang > > > > benchmark on x86_64: 6.4 -> 16 with below command: > > ./ffmpeg -i 1920x1080.mp4 -vf > find_rect=./find.tif,cover_rect=./cover.jpg:mode=cover -f null - > > 6.4 fps -> 16fps > > > > Signed-off-by: Limin Wang > > --- > > libavfilter/vf_find_rect.c | 53 +++--- > > 1 file changed, 21 insertions(+), 32 deletions(-) > > > > diff --git a/libavfilter/vf_find_rect.c b/libavfilter/vf_find_rect.c > > index ee6c3f4b45..ed15885bc2 100644 > > --- a/libavfilter/vf_find_rect.c > > +++ b/libavfilter/vf_find_rect.c > > @@ -26,6 +26,7 @@ > > #include "libavutil/imgutils.h" > > #include "libavutil/opt.h" > > #include "internal.h" > > +#include "scene_sad.h" > > > > #include "lavfutils.h" > > #include "lswsutils.h" > > @@ -36,6 +37,8 @@ typedef struct FOCContext { > > AVClass *class; > > float threshold; > > int mipmaps; > > +ff_scene_sad_fn sad; > > +int bitdepth; > > int xmin, ymin, xmax, ymax; > > char *obj_filename; > > int last_x, last_y; > > @@ -103,54 +106,40 @@ static AVFrame *downscale(AVFrame *in) > > return frame; > > } > > > > -static float compare(const AVFrame *haystack, const AVFrame *obj, int > offx, int offy) > > +static float compare_sad(FOCContext *foc, AVFrame *haystack, AVFrame > *obj, int offx, int offy) > > { > > -int x,y; > > -int o_sum_v = 0; > > -int h_sum_v = 0; > > -int64_t oo_sum_v = 0; > > -int64_t hh_sum_v = 0; > > -int64_t oh_sum_v = 0; > > -float c; > > +uint64_t sad = 0; > > int n = obj->height * obj->width; > > -const uint8_t *odat = obj ->data[0]; > > +double mafd; > > +const uint8_t *odat = obj->data[0]; > > const uint8_t *hdat = haystack->data[0] + offx + offy * > haystack->linesize[0]; > > -int64_t o_sigma, h_sigma; > > - > > -for(y = 0; y < obj->height; y++) { > > -for(x = 0; x < obj->width; x++) { > > -int o_v = odat[x]; > > -int h_v = hdat[x]; > > -o_sum_v += o_v; > > -h_sum_v += h_v; > > -oo_sum_v += o_v * o_v; > > -hh_sum_v += h_v * h_v; > > -oh_sum_v += o_v * h_v; > > -} > > -odat += obj->linesize[0]; > > -hdat += haystack->linesize[0]; > > -} > > -o_sigma = n*oo_sum_v - o_sum_v*(int64_t)o_sum_v; > > -h_sigma = n*hh_sum_v - h_sum_v*(int64_t)h_sum_v; > > > > -if (o_sigma == 0 || h_sigma == 0) > > -return 1.0; > > +foc->sad(hdat, haystack->linesize[0], odat, obj->linesize[0], > > +obj->width, obj->height, ); > > +emms_c(); > > +mafd = (double)sad / n / (1ULL << foc->bitdepth); > > mixing floating point and MMX in the same function is likely not > safe > The code is changed from vf_freezedetect.c, it's OK on my testing system. That's why we had to use emms_c to avoid it. > > also SAD wont recognize objects that are a different contrast or brightness > > I haven't chance to test these condition, that's the issue. Please ignore the patch function. > [...] > > -- > Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB > > Many that live deserve death. And some that die deserve life. Can you give > it to them? Then do not be too eager to deal out death in judgement. For > even the very wise cannot see all ends. -- Gandalf > ___ > 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".
[FFmpeg-devel] [PATCH v5 3/3] libavfilter/vf_cover_rect: support for cover image with more pixel format and different width and height
From: Limin Wang Signed-off-by: Limin Wang --- doc/filters.texi| 2 +- libavfilter/vf_cover_rect.c | 40 2 files changed, 33 insertions(+), 9 deletions(-) diff --git a/doc/filters.texi b/doc/filters.texi index 4d48068..4594a61 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -10180,7 +10180,7 @@ It accepts the following options: @table @option @item cover -Filepath of the optional cover image, needs to be in yuv420. +Filepath of the optional cover image. @item mode Set covering mode. diff --git a/libavfilter/vf_cover_rect.c b/libavfilter/vf_cover_rect.c index b66c40b..502939f 100644 --- a/libavfilter/vf_cover_rect.c +++ b/libavfilter/vf_cover_rect.c @@ -28,6 +28,7 @@ #include "internal.h" #include "lavfutils.h" +#include "lswsutils.h" enum mode { MODE_COVER, @@ -40,6 +41,7 @@ typedef struct CoverContext { int mode; char *cover_filename; AVFrame *cover_frame; +AVFrame *match_frame; int width, height; } CoverContext; @@ -139,8 +141,10 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) CoverContext *cover = ctx->priv; AVDictionaryEntry *ex, *ey, *ew, *eh; int x = -1, y = -1, w = -1, h = -1; +enum AVPixelFormat in_format; char *xendptr = NULL, *yendptr = NULL, *wendptr = NULL, *hendptr = NULL; AVFrame *cover_frame = NULL; +int ret; ex = av_dict_get(in->metadata, "lavfi.rect.x", NULL, AV_DICT_MATCH_CASE); ey = av_dict_get(in->metadata, "lavfi.rect.y", NULL, AV_DICT_MATCH_CASE); @@ -169,14 +173,35 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) } w = FFMIN(w, in->width - x); h = FFMIN(h, in->height - y); +in_format = in->format; if (w > in->width || h > in->height || w <= 0 || h <= 0) return AVERROR(EINVAL); if (cover->cover_frame) { -if (w != cover->cover_frame->width || h != cover->cover_frame->height) -return AVERROR(EINVAL); -cover_frame = cover->cover_frame; +if (w != cover->cover_frame->width || h != cover->cover_frame->height || +in_format != cover->cover_frame->format) { +if (!cover->match_frame || (w != cover->match_frame->width || h != cover->match_frame->height +|| in_format != cover->match_frame->format)) { +if (cover->match_frame) +av_freep(>match_frame->data[0]); +else if (!(cover->match_frame = av_frame_alloc())) +return AVERROR(ENOMEM); + +if ((ret = ff_scale_image(cover->match_frame->data, cover->match_frame->linesize, +w, h, in_format, cover->cover_frame->data, cover->cover_frame->linesize, +cover->cover_frame->width, cover->cover_frame->height, +cover->cover_frame->format, ctx)) < 0) +return AVERROR(ENOMEM); + +cover->match_frame->width = w; +cover->match_frame->height = h; +cover->match_frame->format = in_format; +} + +cover_frame = cover->match_frame; +} else +cover_frame = cover->cover_frame; } cover->width = w; @@ -202,6 +227,10 @@ static av_cold void uninit(AVFilterContext *ctx) if (cover->cover_frame) av_freep(>cover_frame->data[0]); av_frame_free(>cover_frame); + +if (cover->match_frame) +av_freep(>match_frame->data[0]); +av_frame_free(>match_frame); } static av_cold int init(AVFilterContext *ctx) @@ -223,11 +252,6 @@ static av_cold int init(AVFilterContext *ctx) >cover_frame->width, >cover_frame->height, >cover_frame->format, cover->cover_filename, ctx)) < 0) return ret; - -if (cover->cover_frame->format != AV_PIX_FMT_YUV420P && cover->cover_frame->format != AV_PIX_FMT_YUVJ420P) { -av_log(ctx, AV_LOG_ERROR, "cover image is not a YUV420 image\n"); -return AVERROR(EINVAL); -} } return 0; -- 2.6.4 ___ 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/rpl: Fix detection of 8-bit linear formats
Was previously broken by commit 8cf5f94. Fixes ticket #7859 Signed-off-by: Cameron Cawley --- libavformat/rpl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavformat/rpl.c b/libavformat/rpl.c index 7aec3503da..683b3a835a 100644 --- a/libavformat/rpl.c +++ b/libavformat/rpl.c @@ -210,10 +210,10 @@ static int rpl_read_header(AVFormatContext *s) ast->codecpar->codec_id = AV_CODEC_ID_PCM_S16LE; break; } else if (ast->codecpar->bits_per_coded_sample == 8) { -if(av_strcasecmp(audio_type, "unsigned") >= 0) { +if(av_stristr(audio_type, "unsigned") != NULL) { ast->codecpar->codec_id = AV_CODEC_ID_PCM_U8; break; -} else if(av_strcasecmp(audio_type, "linear") >= 0) { +} else if(av_stristr(audio_type, "linear") != NULL) { ast->codecpar->codec_id = AV_CODEC_ID_PCM_S8; break; } else { -- 2.11.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] avformat/rpl: Allow a file to have audio, but not video
Signed-off-by: Cameron Cawley --- libavformat/rpl.c | 78 +++ 1 file changed, 44 insertions(+), 34 deletions(-) diff --git a/libavformat/rpl.c b/libavformat/rpl.c index 683b3a835a..dbbcd13b41 100644 --- a/libavformat/rpl.c +++ b/libavformat/rpl.c @@ -124,7 +124,7 @@ static int rpl_read_header(AVFormatContext *s) uint32_t i; -int32_t audio_format, chunk_catalog_offset, number_of_chunks; +int32_t video_format, audio_format, chunk_catalog_offset, number_of_chunks; AVRational fps; char line[RPL_LINE_LENGTH]; @@ -144,39 +144,47 @@ static int rpl_read_header(AVFormatContext *s) av_dict_set(>metadata, "author" , line, 0); // video headers -vst = avformat_new_stream(s, NULL); -if (!vst) -return AVERROR(ENOMEM); -vst->codecpar->codec_type = AVMEDIA_TYPE_VIDEO; -vst->codecpar->codec_tag = read_line_and_int(pb, ); // video format -vst->codecpar->width = read_line_and_int(pb, ); // video width -vst->codecpar->height = read_line_and_int(pb, ); // video height -vst->codecpar->bits_per_coded_sample = read_line_and_int(pb, ); // video bits per sample -error |= read_line(pb, line, sizeof(line)); // video frames per second -fps = read_fps(line, ); -avpriv_set_pts_info(vst, 32, fps.den, fps.num); - -// Figure out the video codec -switch (vst->codecpar->codec_tag) { +video_format = read_line_and_int(pb, ); +if (video_format) { +vst = avformat_new_stream(s, NULL); +if (!vst) +return AVERROR(ENOMEM); +vst->codecpar->codec_type = AVMEDIA_TYPE_VIDEO; +vst->codecpar->codec_tag = video_format; +vst->codecpar->width = read_line_and_int(pb, ); // video width +vst->codecpar->height = read_line_and_int(pb, ); // video height +vst->codecpar->bits_per_coded_sample = read_line_and_int(pb, ); // video bits per sample + +// Figure out the video codec +switch (vst->codecpar->codec_tag) { #if 0 -case 122: -vst->codecpar->codec_id = AV_CODEC_ID_ESCAPE122; -break; +case 122: +vst->codecpar->codec_id = AV_CODEC_ID_ESCAPE122; +break; #endif -case 124: -vst->codecpar->codec_id = AV_CODEC_ID_ESCAPE124; -// The header is wrong here, at least sometimes -vst->codecpar->bits_per_coded_sample = 16; -break; -case 130: -vst->codecpar->codec_id = AV_CODEC_ID_ESCAPE130; -break; -default: -avpriv_report_missing_feature(s, "Video format %s", - av_fourcc2str(vst->codecpar->codec_tag)); -vst->codecpar->codec_id = AV_CODEC_ID_NONE; +case 124: +vst->codecpar->codec_id = AV_CODEC_ID_ESCAPE124; +// The header is wrong here, at least sometimes +vst->codecpar->bits_per_coded_sample = 16; +break; +case 130: +vst->codecpar->codec_id = AV_CODEC_ID_ESCAPE130; +break; +default: +avpriv_report_missing_feature(s, "Video format %s", + av_fourcc2str(vst->codecpar->codec_tag)); +vst->codecpar->codec_id = AV_CODEC_ID_NONE; +} +} else { +for (i = 0; i < 3; i++) +error |= read_line(pb, line, sizeof(line)); } +error |= read_line(pb, line, sizeof(line)); // video frames per second +fps = read_fps(line, ); +if (vst) +avpriv_set_pts_info(vst, 32, fps.den, fps.num); + // Audio headers // ARMovie supports multiple audio tracks; I don't have any @@ -246,7 +254,7 @@ static int rpl_read_header(AVFormatContext *s) } rpl->frames_per_chunk = read_line_and_int(pb, ); // video frames per chunk -if (rpl->frames_per_chunk > 1 && vst->codecpar->codec_tag != 124) +if (vst && rpl->frames_per_chunk > 1 && vst->codecpar->codec_tag != 124) av_log(s, AV_LOG_WARNING, "Don't know how to split frames for video format %s. " "Video stream will be broken!\n", av_fourcc2str(vst->codecpar->codec_tag)); @@ -261,7 +269,8 @@ static int rpl_read_header(AVFormatContext *s) read_line_and_int(pb, ); // (file index) error |= read_line(pb, line, sizeof(line)); // offset to "helpful" sprite error |= read_line(pb, line, sizeof(line)); // size of "helpful" sprite -error |= read_line(pb, line, sizeof(line)); // offset to key frame list +if (vst) +error |= read_line(pb, line, sizeof(line)); // offset to key frame list // Read the index avio_seek(pb, chunk_catalog_offset, SEEK_SET); @@ -274,8 +283,9 @@ static int
Re: [FFmpeg-devel] [PATCH v5 1/3] libavfilter/vf_find_rect: convert the object image to gray8 format instead of failed directly
On Wed, Jun 12, 2019 at 06:57:29PM +0800, lance.lmw...@gmail.com wrote: > From: Limin Wang > > Signed-off-by: Limin Wang > --- > doc/filters.texi | 2 +- > libavfilter/vf_find_rect.c | 39 +++--- > 2 files changed, 29 insertions(+), 12 deletions(-) > > diff --git a/doc/filters.texi b/doc/filters.texi > index ec1c7c7591..90c57430a6 100644 > --- a/doc/filters.texi > +++ b/doc/filters.texi > @@ -10150,7 +10150,7 @@ It accepts the following options: > > @table @option > @item object > -Filepath of the object image, needs to be in gray8. > +Filepath of the object image. > > @item threshold > Detection threshold, default is 0.5. > diff --git a/libavfilter/vf_find_rect.c b/libavfilter/vf_find_rect.c > index d7e6579af7..ee6c3f4b45 100644 > --- a/libavfilter/vf_find_rect.c > +++ b/libavfilter/vf_find_rect.c > @@ -28,6 +28,7 @@ > #include "internal.h" > > #include "lavfutils.h" > +#include "lswsutils.h" > > #define MAX_MIPMAPS 5 > > @@ -244,6 +245,9 @@ static av_cold int init(AVFilterContext *ctx) > { > FOCContext *foc = ctx->priv; > int ret, i; > +uint8_t *tmp_data[4] = { NULL }; > +int tmp_linesize[4], width, height; > +enum AVPixelFormat pix_fmt; > > if (!foc->obj_filename) { > av_log(ctx, AV_LOG_ERROR, "object filename not set\n"); > @@ -254,24 +258,37 @@ static av_cold int init(AVFilterContext *ctx) > if (!foc->obj_frame) > return AVERROR(ENOMEM); > > -if ((ret = ff_load_image(foc->obj_frame->data, foc->obj_frame->linesize, > - >obj_frame->width, >obj_frame->height, > - >obj_frame->format, foc->obj_filename, > ctx)) < 0) > -return ret; > - > -if (foc->obj_frame->format != AV_PIX_FMT_GRAY8) { > -av_log(ctx, AV_LOG_ERROR, "object image is not a grayscale image\n"); > -return AVERROR(EINVAL); > -} > +if ((ret = ff_load_image(tmp_data, tmp_linesize, > + , , > + _fmt, foc->obj_filename, ctx)) < 0) > +goto error; > + > +/* convert object image to gray8 format with same width and height */ > +foc->obj_frame->format = AV_PIX_FMT_GRAY8; > +foc->obj_frame->width = width; > +foc->obj_frame->height = height; > +if ((ret = ff_scale_image(foc->obj_frame->data, foc->obj_frame->linesize, > +foc->obj_frame->width, foc->obj_frame->height, > foc->obj_frame->format, > +tmp_data, tmp_linesize, width, height, pix_fmt, ctx)) < > 0) > +goto error; > +av_freep(_data[0]); Iam not sure i understand what this patch is intending to do Before a grayscale image was needed, after the patch anything is accepted but only grayscale is used. This is quite unexpected for a user who might expect color to be used if color is accpeted. Generally, doing something that is unexpected by the user is not good [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Those who are best at talking, realize last or never when they are wrong. signature.asc Description: PGP signature ___ 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 v5 3/3] libavfilter/vf_find_rect: convert the object image to gray8 format instead of failed directly
On Sat, Jun 15, 2019 at 12:48:26AM +0800, lance.lmw...@gmail.com wrote: > From: Limin Wang > > Signed-off-by: Limin Wang > --- > doc/filters.texi| 2 +- > libavfilter/vf_cover_rect.c | 40 > 2 files changed, 33 insertions(+), 9 deletions(-) The subject is "libavfilter/vf_find_rect: convert the object image to gray8 format instead of failed directly" while this changes vf_cover_rect instead of vf_find_rect [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Does the universe only have a finite lifespan? No, its going to go on forever, its just that you wont like living in it. -- Hiranya Peiri signature.asc Description: PGP signature ___ 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 v5 2/3] vf_find_rect.c: use the optimized sad function to improve the find performance
Hi On Wed, Jun 12, 2019 at 06:57:30PM +0800, lance.lmw...@gmail.com wrote: > From: Limin Wang > > benchmark on x86_64: 6.4 -> 16 with below command: > ./ffmpeg -i 1920x1080.mp4 -vf > find_rect=./find.tif,cover_rect=./cover.jpg:mode=cover -f null - > 6.4 fps -> 16fps > > Signed-off-by: Limin Wang > --- > libavfilter/vf_find_rect.c | 53 +++--- > 1 file changed, 21 insertions(+), 32 deletions(-) > > diff --git a/libavfilter/vf_find_rect.c b/libavfilter/vf_find_rect.c > index ee6c3f4b45..ed15885bc2 100644 > --- a/libavfilter/vf_find_rect.c > +++ b/libavfilter/vf_find_rect.c > @@ -26,6 +26,7 @@ > #include "libavutil/imgutils.h" > #include "libavutil/opt.h" > #include "internal.h" > +#include "scene_sad.h" > > #include "lavfutils.h" > #include "lswsutils.h" > @@ -36,6 +37,8 @@ typedef struct FOCContext { > AVClass *class; > float threshold; > int mipmaps; > +ff_scene_sad_fn sad; > +int bitdepth; > int xmin, ymin, xmax, ymax; > char *obj_filename; > int last_x, last_y; > @@ -103,54 +106,40 @@ static AVFrame *downscale(AVFrame *in) > return frame; > } > > -static float compare(const AVFrame *haystack, const AVFrame *obj, int offx, > int offy) > +static float compare_sad(FOCContext *foc, AVFrame *haystack, AVFrame *obj, > int offx, int offy) > { > -int x,y; > -int o_sum_v = 0; > -int h_sum_v = 0; > -int64_t oo_sum_v = 0; > -int64_t hh_sum_v = 0; > -int64_t oh_sum_v = 0; > -float c; > +uint64_t sad = 0; > int n = obj->height * obj->width; > -const uint8_t *odat = obj ->data[0]; > +double mafd; > +const uint8_t *odat = obj->data[0]; > const uint8_t *hdat = haystack->data[0] + offx + offy * > haystack->linesize[0]; > -int64_t o_sigma, h_sigma; > - > -for(y = 0; y < obj->height; y++) { > -for(x = 0; x < obj->width; x++) { > -int o_v = odat[x]; > -int h_v = hdat[x]; > -o_sum_v += o_v; > -h_sum_v += h_v; > -oo_sum_v += o_v * o_v; > -hh_sum_v += h_v * h_v; > -oh_sum_v += o_v * h_v; > -} > -odat += obj->linesize[0]; > -hdat += haystack->linesize[0]; > -} > -o_sigma = n*oo_sum_v - o_sum_v*(int64_t)o_sum_v; > -h_sigma = n*hh_sum_v - h_sum_v*(int64_t)h_sum_v; > > -if (o_sigma == 0 || h_sigma == 0) > -return 1.0; > +foc->sad(hdat, haystack->linesize[0], odat, obj->linesize[0], > +obj->width, obj->height, ); > +emms_c(); > +mafd = (double)sad / n / (1ULL << foc->bitdepth); mixing floating point and MMX in the same function is likely not safe also SAD wont recognize objects that are a different contrast or brightness [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Many that live deserve death. And some that die deserve life. Can you give it to them? Then do not be too eager to deal out death in judgement. For even the very wise cannot see all ends. -- Gandalf signature.asc Description: PGP signature ___ 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] lavf/tls_gnutls: retry gnutls_handshake on non fatal errors
On Sat, Jun 1, 2019 at 8:38 PM Jan Ekström wrote: > > On Wed, Mar 27, 2019 at 2:09 PM Remita Amine wrote: > > > > fixes #7801 > > > > Signed-off-by: Remita Amine > > This seems to fix switching the cipher suite, and quickly looking at > the gnutls API docs this seems to be the way to do it. > > Just tested this with the following as I got a report that opening > Facebook HTTPS URLs didn't work in a libavformat API client: > 1. youtube-dl -g > "https://www.facebook.com/downshiftaus/videos/418766325569703/; >(you receive a URL) > 2. ffprobe 'THAT_URL' > > Without this patch the handshake fails (as there is a cipher > re-negotiation?), and with the patch it works. > > Additionally, this doesn't seem to enable bad TLS configurations such > https://rc4.badssl.com/ to get opened. Which is expected from the > gnutls docs, but still I felt like testing. > > In other words, I think this is LGTM and since there already are > reports from people on distros running into this, this should be > back-ported to the versions still maintained by us (whatever those > are) ? > > Best regards, > Jan Applied to master, as I consider this a pretty important fix and there were no further comments in the span of two weeks. Additionally, after checking wget's and curl's usage of gnutls, this indeed seems to be the modus operandi. The only thing is that they also happen to check how many ms are left towards the I/O timeout, but I am not sure if we can effectively apply it here. Additionally, there were voices on IRC that timing out in the middle of a TLS handshake would be overkill and that fixing the connectivity issues should be prioritized. References of gnutls usage: https://github.com/curl/curl/blob/master/lib/vtls/gtls.c#L332 http://git.savannah.gnu.org/cgit/wget.git/tree/src/gnutls.c#n476 Thanks, Jan ___ 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/segment: fix increment_tc
Fixes an issue brought to my attention at Super User. Gyan From 0052366464cabfcd4de7f924adc905984762fe60 Mon Sep 17 00:00:00 2001 From: Gyan Doshi Date: Fri, 14 Jun 2019 22:36:27 +0530 Subject: [PATCH] avformat/segment: fix increment_tc inner stream avg_frame_rate wasn't populated, so tc formation failed. Also, extends increment_tc to stream timecode as well --- libavformat/segment.c | 19 +-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/libavformat/segment.c b/libavformat/segment.c index 6e37707f9f..34942e745f 100644 --- a/libavformat/segment.c +++ b/libavformat/segment.c @@ -180,6 +180,7 @@ static int segment_mux_init(AVFormatContext *s) } st->sample_aspect_ratio = s->streams[i]->sample_aspect_ratio; st->time_base = s->streams[i]->time_base; +st->avg_frame_rate = s->streams[i]->avg_frame_rate; av_dict_copy(>metadata, s->streams[i]->metadata, 0); } @@ -421,7 +422,7 @@ static int segment_end(AVFormatContext *s, int write_trailer, int is_last) rate = s->streams[i]->avg_frame_rate;/* Get fps from the video stream */ err = av_timecode_init_from_string(, rate, tcr->value, s); if (err < 0) { -av_log(s, AV_LOG_WARNING, "Could not increment timecode, error occurred during timecode creation."); +av_log(s, AV_LOG_WARNING, "Could not increment global timecode, error occurred during timecode creation.\n"); break; } tc.start += (int)((seg->cur_entry.end_time - seg->cur_entry.start_time) * av_q2d(rate));/* increment timecode */ @@ -431,7 +432,21 @@ static int segment_end(AVFormatContext *s, int write_trailer, int is_last) } } } else { -av_log(s, AV_LOG_WARNING, "Could not increment timecode, no timecode metadata found"); +av_log(s, AV_LOG_WARNING, "Could not increment global timecode, no global timecode metadata found.\n"); +} +for (i = 0; i < s->nb_streams; i++) { +if (s->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) { +char st_buf[AV_TIMECODE_STR_SIZE]; +AVTimecode st_tc; +AVRational st_rate = s->streams[i]->avg_frame_rate; +AVDictionaryEntry *st_tcr = av_dict_get(s->streams[i]->metadata, "timecode", NULL, 0); +if (st_tcr && (av_timecode_init_from_string(_tc, st_rate, st_tcr->value, s) < 0)) { +av_log(s, AV_LOG_WARNING, "Could not increment stream %d timecode, error occurred during timecode creation.\n", i); +continue; +} +st_tc.start += (int)((seg->cur_entry.end_time - seg->cur_entry.start_time) * av_q2d(st_rate));// increment timecode +av_dict_set(>streams[i]->metadata, "timecode", av_timecode_make_string(_tc, st_buf, 0), 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 v5 2/3] ibavfilter/vf_cover_rect.c: change the cover_rect function for support cover frame can be changed
From: Limin Wang Signed-off-by: Limin Wang --- libavfilter/vf_cover_rect.c | 17 ++--- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/libavfilter/vf_cover_rect.c b/libavfilter/vf_cover_rect.c index 898debf..b66c40b 100644 --- a/libavfilter/vf_cover_rect.c +++ b/libavfilter/vf_cover_rect.c @@ -71,24 +71,25 @@ static int config_input(AVFilterLink *inlink) return 0; } -static void cover_rect(CoverContext *cover, AVFrame *in, int offx, int offy) +static void cover_rect(AVFrame *cover_frame, AVFrame *in, int offx, int offy) { int x, y, p; for (p = 0; p < 3; p++) { uint8_t *data = in->data[p] + (offx>>!!p) + (offy>>!!p) * in->linesize[p]; -const uint8_t *src = cover->cover_frame->data[p]; -int w = AV_CEIL_RSHIFT(cover->cover_frame->width , !!p); -int h = AV_CEIL_RSHIFT(cover->cover_frame->height, !!p); +const uint8_t *src = cover_frame->data[p]; +int w = AV_CEIL_RSHIFT(cover_frame->width , !!p); +int h = AV_CEIL_RSHIFT(cover_frame->height, !!p); for (y = 0; y < h; y++) { for (x = 0; x < w; x++) { data[x] = src[x]; } data += in->linesize[p]; -src += cover->cover_frame->linesize[p]; +src += cover_frame->linesize[p]; } } } + static void blur(CoverContext *cover, AVFrame *in, int offx, int offy) { int x, y, p; @@ -139,6 +140,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) AVDictionaryEntry *ex, *ey, *ew, *eh; int x = -1, y = -1, w = -1, h = -1; char *xendptr = NULL, *yendptr = NULL, *wendptr = NULL, *hendptr = NULL; +AVFrame *cover_frame = NULL; ex = av_dict_get(in->metadata, "lavfi.rect.x", NULL, AV_DICT_MATCH_CASE); ey = av_dict_get(in->metadata, "lavfi.rect.y", NULL, AV_DICT_MATCH_CASE); @@ -174,6 +176,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) if (cover->cover_frame) { if (w != cover->cover_frame->width || h != cover->cover_frame->height) return AVERROR(EINVAL); +cover_frame = cover->cover_frame; } cover->width = w; @@ -186,8 +189,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) if (cover->mode == MODE_BLUR) { blur (cover, in, x, y); -} else { -cover_rect(cover, in, x, y); +} else if (cover_frame) { +cover_rect(cover_frame, in, x, y); } return ff_filter_frame(ctx->outputs[0], in); } -- 2.6.4 ___ 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 v5 1/3] doc/filters.texi: Fix the confusing description for find_rect and cover_rect command
From: Limin Wang Signed-off-by: Limin Wang --- doc/filters.texi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/filters.texi b/doc/filters.texi index ec1c7c7..4d48068 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -10166,7 +10166,7 @@ Specifies the rectangle in which to search. @itemize @item -Generate a representative palette of a given video using @command{ffmpeg}: +Cover a rectangular object by the supplied image of a given video using @command{ffmpeg}: @example ffmpeg -i file.ts -vf find_rect=newref.pgm,cover_rect=cover.jpg:mode=cover new.mkv @end example @@ -10200,7 +10200,7 @@ Default value is @var{blur}. @itemize @item -Generate a representative palette of a given video using @command{ffmpeg}: +Cover a rectangular object by the supplied image of a given video using @command{ffmpeg}: @example ffmpeg -i file.ts -vf find_rect=newref.pgm,cover_rect=cover.jpg:mode=cover new.mkv @end example -- 2.6.4 ___ 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 v5 3/3] libavfilter/vf_find_rect: convert the object image to gray8 format instead of failed directly
From: Limin Wang Signed-off-by: Limin Wang --- doc/filters.texi| 2 +- libavfilter/vf_cover_rect.c | 40 2 files changed, 33 insertions(+), 9 deletions(-) diff --git a/doc/filters.texi b/doc/filters.texi index 4d48068..4594a61 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -10180,7 +10180,7 @@ It accepts the following options: @table @option @item cover -Filepath of the optional cover image, needs to be in yuv420. +Filepath of the optional cover image. @item mode Set covering mode. diff --git a/libavfilter/vf_cover_rect.c b/libavfilter/vf_cover_rect.c index b66c40b..502939f 100644 --- a/libavfilter/vf_cover_rect.c +++ b/libavfilter/vf_cover_rect.c @@ -28,6 +28,7 @@ #include "internal.h" #include "lavfutils.h" +#include "lswsutils.h" enum mode { MODE_COVER, @@ -40,6 +41,7 @@ typedef struct CoverContext { int mode; char *cover_filename; AVFrame *cover_frame; +AVFrame *match_frame; int width, height; } CoverContext; @@ -139,8 +141,10 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) CoverContext *cover = ctx->priv; AVDictionaryEntry *ex, *ey, *ew, *eh; int x = -1, y = -1, w = -1, h = -1; +enum AVPixelFormat in_format; char *xendptr = NULL, *yendptr = NULL, *wendptr = NULL, *hendptr = NULL; AVFrame *cover_frame = NULL; +int ret; ex = av_dict_get(in->metadata, "lavfi.rect.x", NULL, AV_DICT_MATCH_CASE); ey = av_dict_get(in->metadata, "lavfi.rect.y", NULL, AV_DICT_MATCH_CASE); @@ -169,14 +173,35 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) } w = FFMIN(w, in->width - x); h = FFMIN(h, in->height - y); +in_format = in->format; if (w > in->width || h > in->height || w <= 0 || h <= 0) return AVERROR(EINVAL); if (cover->cover_frame) { -if (w != cover->cover_frame->width || h != cover->cover_frame->height) -return AVERROR(EINVAL); -cover_frame = cover->cover_frame; +if (w != cover->cover_frame->width || h != cover->cover_frame->height || +in_format != cover->cover_frame->format) { +if (!cover->match_frame || (w != cover->match_frame->width || h != cover->match_frame->height +|| in_format != cover->match_frame->format)) { +if (cover->match_frame) +av_freep(>match_frame->data[0]); +else if (!(cover->match_frame = av_frame_alloc())) +return AVERROR(ENOMEM); + +if ((ret = ff_scale_image(cover->match_frame->data, cover->match_frame->linesize, +w, h, in_format, cover->cover_frame->data, cover->cover_frame->linesize, +cover->cover_frame->width, cover->cover_frame->height, +cover->cover_frame->format, ctx)) < 0) +return AVERROR(ENOMEM); + +cover->match_frame->width = w; +cover->match_frame->height = h; +cover->match_frame->format = in_format; +} + +cover_frame = cover->match_frame; +} else +cover_frame = cover->cover_frame; } cover->width = w; @@ -202,6 +227,10 @@ static av_cold void uninit(AVFilterContext *ctx) if (cover->cover_frame) av_freep(>cover_frame->data[0]); av_frame_free(>cover_frame); + +if (cover->match_frame) +av_freep(>match_frame->data[0]); +av_frame_free(>match_frame); } static av_cold int init(AVFilterContext *ctx) @@ -223,11 +252,6 @@ static av_cold int init(AVFilterContext *ctx) >cover_frame->width, >cover_frame->height, >cover_frame->format, cover->cover_filename, ctx)) < 0) return ret; - -if (cover->cover_frame->format != AV_PIX_FMT_YUV420P && cover->cover_frame->format != AV_PIX_FMT_YUVJ420P) { -av_log(ctx, AV_LOG_ERROR, "cover image is not a YUV420 image\n"); -return AVERROR(EINVAL); -} } return 0; -- 2.6.4 ___ 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 v4] libavfilter/vf_cover_rect: support for cover image with more pixel format and different width and height
On Fri, Jun 14, 2019 at 5:31 PM Michael Niedermayer wrote: > On Wed, Jun 12, 2019 at 06:50:18PM +0800, lance.lmw...@gmail.com wrote: > > From: Limin Wang > > > > Signed-off-by: Limin Wang > > --- > > doc/filters.texi| 6 ++-- > > libavfilter/vf_cover_rect.c | 56 +++-- > > 2 files changed, 44 insertions(+), 18 deletions(-) > > > > diff --git a/doc/filters.texi b/doc/filters.texi > > index ec1c7c7591..4594a61c13 100644 > > --- a/doc/filters.texi > > +++ b/doc/filters.texi > > @@ -10166,7 +10166,7 @@ Specifies the rectangle in which to search. > > > > @itemize > > @item > > -Generate a representative palette of a given video using > @command{ffmpeg}: > > +Cover a rectangular object by the supplied image of a given video using > @command{ffmpeg}: > > @example > > ffmpeg -i file.ts -vf > find_rect=newref.pgm,cover_rect=cover.jpg:mode=cover new.mkv > > @end example > > @@ -10180,7 +10180,7 @@ It accepts the following options: > > > > @table @option > > @item cover > > -Filepath of the optional cover image, needs to be in yuv420. > > +Filepath of the optional cover image. > > > > @item mode > > Set covering mode. > > @@ -10200,7 +10200,7 @@ Default value is @var{blur}. > > > > @itemize > > @item > > -Generate a representative palette of a given video using > @command{ffmpeg}: > > +Cover a rectangular object by the supplied image of a given video using > @command{ffmpeg}: > > @example > > ffmpeg -i file.ts -vf > find_rect=newref.pgm,cover_rect=cover.jpg:mode=cover new.mkv > > @end example > > diff --git a/libavfilter/vf_cover_rect.c b/libavfilter/vf_cover_rect.c > > index 898debf09d..36c650dd21 100644 > > --- a/libavfilter/vf_cover_rect.c > > +++ b/libavfilter/vf_cover_rect.c > > @@ -28,6 +28,7 @@ > > #include "internal.h" > > > > #include "lavfutils.h" > > +#include "lswsutils.h" > > > > enum mode { > > MODE_COVER, > > @@ -40,6 +41,7 @@ typedef struct CoverContext { > > int mode; > > char *cover_filename; > > AVFrame *cover_frame; > > +AVFrame *match_frame; > > int width, height; > > } CoverContext; > > > > > @@ -71,21 +73,21 @@ static int config_input(AVFilterLink *inlink) > > return 0; > > } > > > > -static void cover_rect(CoverContext *cover, AVFrame *in, int offx, int > offy) > > +static void cover_rect(AVFrame *cover_frame, AVFrame *in, int offx, int > offy) > > { > > int x, y, p; > > > > for (p = 0; p < 3; p++) { > > uint8_t *data = in->data[p] + (offx>>!!p) + (offy>>!!p) * > in->linesize[p]; > > -const uint8_t *src = cover->cover_frame->data[p]; > > -int w = AV_CEIL_RSHIFT(cover->cover_frame->width , !!p); > > -int h = AV_CEIL_RSHIFT(cover->cover_frame->height, !!p); > > +const uint8_t *src = cover_frame->data[p]; > > +int w = AV_CEIL_RSHIFT(cover_frame->width , !!p); > > +int h = AV_CEIL_RSHIFT(cover_frame->height, !!p); > > for (y = 0; y < h; y++) { > > for (x = 0; x < w; x++) { > > data[x] = src[x]; > > } > > data += in->linesize[p]; > > -src += cover->cover_frame->linesize[p]; > > +src += cover_frame->linesize[p]; > > } > > } > > } > > This hunk is independant and can be done in a seperate patch before > > OK, I'll split the patch. > > > @@ -138,7 +140,10 @@ static int filter_frame(AVFilterLink *inlink, > AVFrame *in) > > CoverContext *cover = ctx->priv; > > AVDictionaryEntry *ex, *ey, *ew, *eh; > > int x = -1, y = -1, w = -1, h = -1; > > +enum AVPixelFormat in_format; > > char *xendptr = NULL, *yendptr = NULL, *wendptr = NULL, *hendptr = > NULL; > > +AVFrame *cover_frame = NULL; > > +int ret; > > > > ex = av_dict_get(in->metadata, "lavfi.rect.x", NULL, > AV_DICT_MATCH_CASE); > > ey = av_dict_get(in->metadata, "lavfi.rect.y", NULL, > AV_DICT_MATCH_CASE); > > > @@ -167,14 +172,34 @@ static int filter_frame(AVFilterLink *inlink, > AVFrame *in) > > } > > w = FFMIN(w, in->width - x); > > h = FFMIN(h, in->height - y); > > +in_format = in->format; > > > > if (w > in->width || h > in->height || w <= 0 || h <= 0) > > return AVERROR(EINVAL); > > > > -if (cover->cover_frame) { > > -if (w != cover->cover_frame->width || h != > cover->cover_frame->height) > > -return AVERROR(EINVAL); > > -} > > +if (w != cover->cover_frame->width || h != > cover->cover_frame->height || > > +in_format != cover->cover_frame->format) { > > This segfaults > cover->cover_frame is checked in the init function, if it's null, it'll failed already, so I remove the checking and haven't got any segments issue. anyway, I'll add it for the updated patch. > > > > +if (!cover->match_frame || (w != cover->match_frame->width || h > != cover->match_frame->height > > +|| in_format != cover->match_frame->format)) { > > +
Re: [FFmpeg-devel] [PATCH] avformat/oggparseogm: unknown codec triggers error
On 6/14/2019 11:52 AM, Reimar Döffinger wrote: > > > On 14.06.2019, at 03:15, Chris Cunningham wrote: > >> Only "succeed" to read a header if the codec is valid. Otherwise >> return AVERROR_INVALIDDATA. > > That doesn't sound right to me, an unknown codec in (possibly) a single > stream is not an error. > I understood the discussion more to say the if it's an unknown codec, we > should not try to override valid codec configuration with a broken one. I did request this change, seeing that returning codec_id none in this scenario results in a crash at a later point due to conflicting parameters. Do you suggest we should limit the change to only reject any duplicate header that may show up after the first one (and before the first data packet)? ___ 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/oggparseogm: unknown codec triggers error
On 14.06.2019, at 03:15, Chris Cunningham wrote: > Only "succeed" to read a header if the codec is valid. Otherwise > return AVERROR_INVALIDDATA. That doesn't sound right to me, an unknown codec in (possibly) a single stream is not an error. I understood the discussion more to say the if it's an unknown codec, we should not try to override valid codec configuration with a broken one. ___ 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] set AVFrame decode_error_flags in case of decoding error by h264dec
thanks Moritz i submitted two new patches On Fri, Jun 14, 2019 at 2:43 AM Moritz Barsnick wrote: > On Thu, Jun 13, 2019 at 08:52:22 -0700, Amir Pauker wrote: > > doc/APIchanges | 3 +++ > > libavcodec/h264dec.c | 5 + > > libavutil/frame.h| 1 + > > libavutil/version.h | 2 +- > > You should split the introduction of the API (libavutil and doc) and > the use of the API (libavcodec) into two separate patches. > > > +if( (ret < 0 || h->slice_ctx->er.error_occurred) && h->cur_pic_ptr){ > > Please fix the bracket/whitespace style: > https://ffmpeg.org/developer.html#Code-formatting-conventions > > -> > if ((ret < 0 || h->slice_ctx->er.error_occurred) && h->cur_pic_ptr) { > > Moritz > ___ > 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".
[FFmpeg-devel] [PATCH] set AVFrame decode_error_flags to FF_DECODE_ERROR_CONCEALMENT_ACTIVE in case of concealed errors
set AVFrame decode_error_flags to FF_DECODE_ERROR_CONCEALMENT_ACTIVE in case h->slice_ctx->er.error_occurred is set after the call to ff_h264_execute_decode_slices. This allows the user to detect concealed decoding errors in the call to avcodec_receive_frame Signed-off-by: Amir Pauker --- libavcodec/h264dec.c | 5 + 1 file changed, 5 insertions(+) diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c index 837c3b7..98b7d79 100644 --- a/libavcodec/h264dec.c +++ b/libavcodec/h264dec.c @@ -761,6 +761,11 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size) if (ret < 0 && (h->avctx->err_recognition & AV_EF_EXPLODE)) goto end; +// set decode_error_flags to allow users to detect concealed decoding errors +if ((ret < 0 || h->slice_ctx->er.error_occurred) && h->cur_pic_ptr) { +h->cur_pic_ptr->f->decode_error_flags |= FF_DECODE_ERROR_CONCEALMENT_ACTIVE; +} + ret = 0; end: -- 2.1.4 ___ 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] add FF_DECODE_ERROR_CONCEALMENT_ACTIVE flag for AVFrame.decode_error_flags
FF_DECODE_ERROR_CONCEALMENT_ACTIVE is set when the decoded frame has error(s) but the returned value from avcodec_receive_frame is zero i.e. concealed errors Signed-off-by: Amir Pauker --- doc/APIchanges | 3 +++ libavutil/frame.h | 1 + libavutil/version.h | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/doc/APIchanges b/doc/APIchanges index cf426e2..ac89c6b 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -15,6 +15,9 @@ libavutil: 2017-10-21 API changes, most recent first: +2019-06-14 - XX - lavu 56.29.100 - frame.h + Add FF_DECODE_ERROR_CONCEALMENT_ACTIVE + 2019-05-15 - b79b29ddb1 - lavu 56.28.100 - tx.h Add av_tx_init(), av_tx_uninit() and related definitions. diff --git a/libavutil/frame.h b/libavutil/frame.h index 8aa3e88..54e682e 100644 --- a/libavutil/frame.h +++ b/libavutil/frame.h @@ -563,6 +563,7 @@ typedef struct AVFrame { int decode_error_flags; #define FF_DECODE_ERROR_INVALID_BITSTREAM 1 #define FF_DECODE_ERROR_MISSING_REFERENCE 2 +#define FF_DECODE_ERROR_CONCEALMENT_ACTIVE 4 /** * number of audio channels, only used for audio. diff --git a/libavutil/version.h b/libavutil/version.h index 91ab716..dccbb38 100644 --- a/libavutil/version.h +++ b/libavutil/version.h @@ -79,7 +79,7 @@ */ #define LIBAVUTIL_VERSION_MAJOR 56 -#define LIBAVUTIL_VERSION_MINOR 28 +#define LIBAVUTIL_VERSION_MINOR 29 #define LIBAVUTIL_VERSION_MICRO 100 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ -- 2.1.4 ___ 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 v4] libavfilter/vf_cover_rect: support for cover image with more pixel format and different width and height
On Wed, Jun 12, 2019 at 06:50:18PM +0800, lance.lmw...@gmail.com wrote: > From: Limin Wang > > Signed-off-by: Limin Wang > --- > doc/filters.texi| 6 ++-- > libavfilter/vf_cover_rect.c | 56 +++-- > 2 files changed, 44 insertions(+), 18 deletions(-) > > diff --git a/doc/filters.texi b/doc/filters.texi > index ec1c7c7591..4594a61c13 100644 > --- a/doc/filters.texi > +++ b/doc/filters.texi > @@ -10166,7 +10166,7 @@ Specifies the rectangle in which to search. > > @itemize > @item > -Generate a representative palette of a given video using @command{ffmpeg}: > +Cover a rectangular object by the supplied image of a given video using > @command{ffmpeg}: > @example > ffmpeg -i file.ts -vf find_rect=newref.pgm,cover_rect=cover.jpg:mode=cover > new.mkv > @end example > @@ -10180,7 +10180,7 @@ It accepts the following options: > > @table @option > @item cover > -Filepath of the optional cover image, needs to be in yuv420. > +Filepath of the optional cover image. > > @item mode > Set covering mode. > @@ -10200,7 +10200,7 @@ Default value is @var{blur}. > > @itemize > @item > -Generate a representative palette of a given video using @command{ffmpeg}: > +Cover a rectangular object by the supplied image of a given video using > @command{ffmpeg}: > @example > ffmpeg -i file.ts -vf find_rect=newref.pgm,cover_rect=cover.jpg:mode=cover > new.mkv > @end example > diff --git a/libavfilter/vf_cover_rect.c b/libavfilter/vf_cover_rect.c > index 898debf09d..36c650dd21 100644 > --- a/libavfilter/vf_cover_rect.c > +++ b/libavfilter/vf_cover_rect.c > @@ -28,6 +28,7 @@ > #include "internal.h" > > #include "lavfutils.h" > +#include "lswsutils.h" > > enum mode { > MODE_COVER, > @@ -40,6 +41,7 @@ typedef struct CoverContext { > int mode; > char *cover_filename; > AVFrame *cover_frame; > +AVFrame *match_frame; > int width, height; > } CoverContext; > > @@ -71,21 +73,21 @@ static int config_input(AVFilterLink *inlink) > return 0; > } > > -static void cover_rect(CoverContext *cover, AVFrame *in, int offx, int offy) > +static void cover_rect(AVFrame *cover_frame, AVFrame *in, int offx, int offy) > { > int x, y, p; > > for (p = 0; p < 3; p++) { > uint8_t *data = in->data[p] + (offx>>!!p) + (offy>>!!p) * > in->linesize[p]; > -const uint8_t *src = cover->cover_frame->data[p]; > -int w = AV_CEIL_RSHIFT(cover->cover_frame->width , !!p); > -int h = AV_CEIL_RSHIFT(cover->cover_frame->height, !!p); > +const uint8_t *src = cover_frame->data[p]; > +int w = AV_CEIL_RSHIFT(cover_frame->width , !!p); > +int h = AV_CEIL_RSHIFT(cover_frame->height, !!p); > for (y = 0; y < h; y++) { > for (x = 0; x < w; x++) { > data[x] = src[x]; > } > data += in->linesize[p]; > -src += cover->cover_frame->linesize[p]; > +src += cover_frame->linesize[p]; > } > } > } This hunk is independant and can be done in a seperate patch before > @@ -138,7 +140,10 @@ static int filter_frame(AVFilterLink *inlink, AVFrame > *in) > CoverContext *cover = ctx->priv; > AVDictionaryEntry *ex, *ey, *ew, *eh; > int x = -1, y = -1, w = -1, h = -1; > +enum AVPixelFormat in_format; > char *xendptr = NULL, *yendptr = NULL, *wendptr = NULL, *hendptr = NULL; > +AVFrame *cover_frame = NULL; > +int ret; > > ex = av_dict_get(in->metadata, "lavfi.rect.x", NULL, AV_DICT_MATCH_CASE); > ey = av_dict_get(in->metadata, "lavfi.rect.y", NULL, AV_DICT_MATCH_CASE); > @@ -167,14 +172,34 @@ static int filter_frame(AVFilterLink *inlink, AVFrame > *in) > } > w = FFMIN(w, in->width - x); > h = FFMIN(h, in->height - y); > +in_format = in->format; > > if (w > in->width || h > in->height || w <= 0 || h <= 0) > return AVERROR(EINVAL); > > -if (cover->cover_frame) { > -if (w != cover->cover_frame->width || h != > cover->cover_frame->height) > -return AVERROR(EINVAL); > -} > +if (w != cover->cover_frame->width || h != cover->cover_frame->height || > +in_format != cover->cover_frame->format) { This segfaults > +if (!cover->match_frame || (w != cover->match_frame->width || h != > cover->match_frame->height > +|| in_format != cover->match_frame->format)) { > +if (cover->match_frame) > +av_freep(>match_frame->data[0]); > +else if (!(cover->match_frame = av_frame_alloc())) > +return AVERROR(ENOMEM); > + > +if ((ret = ff_scale_image(cover->match_frame->data, > cover->match_frame->linesize, > +w, h, in_format, cover->cover_frame->data, > cover->cover_frame->linesize, > +cover->cover_frame->width, > cover->cover_frame->height, > +
Re: [FFmpeg-devel] [PATCH 3/4] avcodec/fitsdec: Fix division be 0 in size check
On Thu, Jun 13, 2019 at 20:32:35 +0200, Michael Niedermayer wrote: > avcodec/fitsdec: Fix division be 0 in size check Nit:^ by Moritz ___ 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] set AVFrame decode_error_flags in case of decoding error by h264dec
On Thu, Jun 13, 2019 at 08:52:22 -0700, Amir Pauker wrote: > doc/APIchanges | 3 +++ > libavcodec/h264dec.c | 5 + > libavutil/frame.h| 1 + > libavutil/version.h | 2 +- You should split the introduction of the API (libavutil and doc) and the use of the API (libavcodec) into two separate patches. > +if( (ret < 0 || h->slice_ctx->er.error_occurred) && h->cur_pic_ptr){ Please fix the bracket/whitespace style: https://ffmpeg.org/developer.html#Code-formatting-conventions -> if ((ret < 0 || h->slice_ctx->er.error_occurred) && h->cur_pic_ptr) { Moritz ___ 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 v4] vaapi_encode_mjpeg: fix bad component id bug
On Thu, Jun 13, 2019 at 15:41:55 +, Eoff, Ullysses A wrote: > According to comments in the gcc request, it looks like we > could use " -fsanitize=address". Anyone care to test it > out to see if it will work? The AddressSanatizer does not make this a warning at compile time (or perhaps it may, additionally), but it instruments the binary with code for analyzing and debugging address accesses, similar to valgrind: https://github.com/google/sanitizers/wiki/AddressSanitizer So this is not a permanent solution, but might be something for fate. Moritz ___ 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, v3] lavf/qsvvpp:allocate continuous memory
> From: Fu, Linjie > Sent: Friday, June 14, 2019 1:39 PM > To: Li, Zhong ; FFmpeg development discussions and > patches > Subject: RE: [FFmpeg-devel] [PATCH,v3] lavf/qsvvpp:allocate continuous > memory > > > -Original Message- > > From: Li, Zhong > > Sent: Friday, June 14, 2019 11:34 > > To: FFmpeg development discussions and patches > de...@ffmpeg.org> > > Cc: Fu, Linjie > > Subject: RE: [FFmpeg-devel] [PATCH,v3] lavf/qsvvpp:allocate continuous > > memory > > > > > From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On > > Behalf > > > Of Linjie Fu > > > Sent: Tuesday, June 4, 2019 11:59 PM > > > To: ffmpeg-devel@ffmpeg.org > > > Cc: Fu, Linjie > > > Subject: [FFmpeg-devel] [PATCH,v3] lavf/qsvvpp:allocate continuous > > > memory > > > > > > Mediasdk calls CMRT to copy from video to system memory and requires > > > memory to be continuously allocated across Y and UV. > > > > > > Add a new path to allocate continuous memory when using system out. > > > Use av_frame_get_buffer to arrange data according to pixfmt, and > > > remove the introduced plane_padding. > > > > > > Signed-off-by: Linjie Fu > > > --- > > > libavfilter/qsvvpp.c | 26 -- > > > 1 file changed, 20 insertions(+), 6 deletions(-) > > > > > > diff --git a/libavfilter/qsvvpp.c b/libavfilter/qsvvpp.c index > > > 5cd1d5d345..c06171444f 100644 > > > --- a/libavfilter/qsvvpp.c > > > +++ b/libavfilter/qsvvpp.c > > > @@ -350,7 +350,7 @@ static QSVFrame *query_frame(QSVVPPContext > *s, > > > AVFilterLink *outlink) { > > > AVFilterContext *ctx = outlink->src; > > > QSVFrame*out_frame; > > > -int ret; > > > +int i, ret; > > > > > > clear_unused_frames(s->out_frame_list); > > > > > > @@ -374,12 +374,26 @@ static QSVFrame > *query_frame(QSVVPPContext *s, > > > AVFilterLink *outlink) > > > out_frame->surface = (mfxFrameSurface1 > > > *)out_frame->frame->data[3]; > > > } else { > > > /* Get a frame with aligned dimensions. > > > - * Libmfx need system memory being 128x64 aligned */ > > > -out_frame->frame = ff_get_video_buffer(outlink, > > > - > > > FFALIGN(outlink->w, 128), > > > - > > > FFALIGN(outlink->h, 64)); > > > -if (!out_frame->frame) > > > + * Libmfx need system memory being 128x64 aligned > > > + * and continuously allocated across Y and UV */ > > > +out_frame->frame = av_frame_alloc(); > > > +if (!out_frame->frame) { > > > return NULL; > > > +} > > > + > > > +out_frame->frame->width = FFALIGN(outlink->w, 128); > > > +out_frame->frame->height = FFALIGN(outlink->h, 64); > > > +out_frame->frame->format = outlink->format; > > > + > > > +ret = av_frame_get_buffer(out_frame->frame, 128); > > > +if (ret < 0) > > > +return NULL; > > > + > > > +/* remove plane_padding introduced by av_frame_get_buffer > > > + */ > > Should be well explained in the comments why need to reomove. > > Tried to explain that continuous memory is need for libmfx in commit > message and before av_frame_get_buffer was called. > > If that's not enough, would you please offer some advices on how to explain > better? > > > > > > +for (i = 1; i < 4; i++) { > > > +if (out_frame->frame->data[i]) > > > +out_frame->frame->data[i] -= i * 128; > > > +} > > > > Looks like tricky workaround. If padding bytes size changed in > > av_frame_get_buffer, will break qsv vpp. > > Calls av_frame_get_buffer-> get_video_buffer could allocate memory at > one time and make the code clearer, but will introduce plane_padding: > > plane_padding = FFMAX(16 + 16/*STRIDE_ALIGN*/, align); > > The padding bytes was initialized by variable "align", and "align" was set to > 128 as a requirement. > So the padding bytes will always be set to align and I think it won't break > vpp > pipeline. This is just current status, if you check git log of frame.c, plane_padding size was changed serval times. If it is continuous to change, then will break qsv vpp. ___ 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".