[FFmpeg-cvslog] doc/filters: Add entry for sr filter.
ffmpeg | branch: master | Sergey Lavrushkin | Wed Aug 15 19:35:09 2018 +0300| [4f8e65c45884d91ac300caac37b55c8ca504288b] | committer: Gyan Doshi doc/filters: Add entry for sr filter. Signed-off-by: Gyan Doshi > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4f8e65c45884d91ac300caac37b55c8ca504288b --- doc/filters.texi | 59 1 file changed, 59 insertions(+) diff --git a/doc/filters.texi b/doc/filters.texi index 267bd04a43..32c95b591c 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -15403,6 +15403,65 @@ option may cause flicker since the B-Frames have often larger QP. Default is @code{0} (not enabled). @end table +@section sr + +Scale the input by applying one of the super-resolution methods based on +convolutional neural networks. + +Training scripts as well as scripts for model generation are provided in +the repository at @url{https://github.com/HighVoltageRocknRoll/sr.git}. + +The filter accepts the following options: + +@table @option +@item model +Specify which super-resolution model to use. This option accepts the following values: + +@table @samp +@item srcnn +Super-Resolution Convolutional Neural Network model. +See @url{https://arxiv.org/abs/1501.00092}. + +@item espcn +Efficient Sub-Pixel Convolutional Neural Network model. +See @url{https://arxiv.org/abs/1609.05158}. + +@end table + +Default value is @samp{srcnn}. + +@item dnn_backend +Specify which DNN backend to use for model loading and execution. This option accepts +the following values: + +@table @samp +@item native +Native implementation of DNN loading and execution. + +@item tensorflow +TensorFlow backend. To enable this backend you +need to install the TensorFlow for C library (see +@url{https://www.tensorflow.org/install/install_c}) and configure FFmpeg with +@code{--enable-libtensorflow} + +@end table + +Default value is @samp{native}. + +@item scale_factor +Set scale factor for SRCNN model, for which custom model file was provided. +Allowed values are @code{2}, @code{3} and @code{4}. Default value is @code{2}. +Scale factor is necessary for SRCNN model, because it accepts input upscaled +using bicubic upscaling with proper scale factor. + +@item model_filename +Set path to model file specifying network architecture and its parameters. +Note that different backends use different file formats. TensorFlow backend +can load files for both formats, while native backend can load files for only +its format. + +@end table + @anchor{subtitles} @section subtitles ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avformat/asfdec_o: Check size_bmp more fully
ffmpeg | branch: release/3.2 | Michael Niedermayer | Tue Jul 3 21:01:23 2018 +0200| [67149cb2f68e3e96cd75804d83827ccd03386695] | committer: James Almer avformat/asfdec_o: Check size_bmp more fully Fixes: integer overflow and out of array access Fixes: asfo-crash-46080c4341572a7137a162331af77f6ded45cbd7 Found-by: Paul Ch Signed-off-by: Michael Niedermayer (cherry picked from commit 2b46ebdbff1d8dec7a3d8ea280a612b91a582869) Signed-off-by: James Almer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=67149cb2f68e3e96cd75804d83827ccd03386695 --- libavformat/asfdec_o.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavformat/asfdec_o.c b/libavformat/asfdec_o.c index 593c010204..3f43fd1b47 100644 --- a/libavformat/asfdec_o.c +++ b/libavformat/asfdec_o.c @@ -704,7 +704,8 @@ static int parse_video_info(AVIOContext *pb, AVStream *st) st->codecpar->codec_id = ff_codec_get_id(ff_codec_bmp_tags, tag); size_bmp = FFMAX(size_asf, size_bmp); -if (size_bmp > BMP_HEADER_SIZE) { +if (size_bmp > BMP_HEADER_SIZE && +size_bmp < INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE) { int ret; st->codecpar->extradata_size = size_bmp - BMP_HEADER_SIZE; if (!(st->codecpar->extradata = av_malloc(st->codecpar->extradata_size + ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] asfdec: Account for different Format Data sizes
ffmpeg | branch: release/3.2 | Alexandra Hájková | Wed Feb 8 12:51:37 2017 +0100| [32e8eed1ae5fe694c070dacfa517295be786dfbe] | committer: James Almer asfdec: Account for different Format Data sizes Some muxers may use the BMP_HEADER Format Data size instead of the ASF-specific one. Signed-off-by: Diego Biurrun (cherry picked from commit 42f27d1b8eab9ea88d2e9faeb35f72dd72eca7b4) Signed-off-by: James Almer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=32e8eed1ae5fe694c070dacfa517295be786dfbe --- libavformat/asfdec_o.c | 12 +++- libavformat/riff.h | 3 ++- libavformat/riffdec.c | 7 --- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/libavformat/asfdec_o.c b/libavformat/asfdec_o.c index 56f8446b5f..593c010204 100644 --- a/libavformat/asfdec_o.c +++ b/libavformat/asfdec_o.c @@ -691,20 +691,22 @@ static int asf_read_properties(AVFormatContext *s, const GUIDParseTable *g) static int parse_video_info(AVIOContext *pb, AVStream *st) { -uint16_t size; +uint16_t size_asf; // ASF-specific Format Data size +uint32_t size_bmp; // BMP_HEADER-specific Format Data size unsigned int tag; st->codecpar->width = avio_rl32(pb); st->codecpar->height = avio_rl32(pb); avio_skip(pb, 1); // skip reserved flags -size = avio_rl16(pb); // size of the Format Data -tag = ff_get_bmp_header(pb, st, NULL); +size_asf = avio_rl16(pb); +tag = ff_get_bmp_header(pb, st, &size_bmp); st->codecpar->codec_tag = tag; st->codecpar->codec_id = ff_codec_get_id(ff_codec_bmp_tags, tag); +size_bmp = FFMAX(size_asf, size_bmp); -if (size > BMP_HEADER_SIZE) { +if (size_bmp > BMP_HEADER_SIZE) { int ret; -st->codecpar->extradata_size = size - BMP_HEADER_SIZE; +st->codecpar->extradata_size = size_bmp - BMP_HEADER_SIZE; if (!(st->codecpar->extradata = av_malloc(st->codecpar->extradata_size + AV_INPUT_BUFFER_PADDING_SIZE))) { st->codecpar->extradata_size = 0; diff --git a/libavformat/riff.h b/libavformat/riff.h index fe87e81933..995867a989 100644 --- a/libavformat/riff.h +++ b/libavformat/riff.h @@ -41,9 +41,10 @@ void ff_end_tag(AVIOContext *pb, int64_t start); /** * Read BITMAPINFOHEADER structure and set AVStream codec width, height and * bits_per_encoded_sample fields. Does not read extradata. + * Writes the size of the BMP file to *size. * @return codec tag */ -int ff_get_bmp_header(AVIOContext *pb, AVStream *st, unsigned *esize); +int ff_get_bmp_header(AVIOContext *pb, AVStream *st, uint32_t *size); void ff_put_bmp_header(AVIOContext *pb, AVCodecParameters *par, const AVCodecTag *tags, int for_asf, int ignore_extradata); diff --git a/libavformat/riffdec.c b/libavformat/riffdec.c index 1602c31169..8e9827f65b 100644 --- a/libavformat/riffdec.c +++ b/libavformat/riffdec.c @@ -205,11 +205,12 @@ enum AVCodecID ff_wav_codec_get_id(unsigned int tag, int bps) return id; } -int ff_get_bmp_header(AVIOContext *pb, AVStream *st, unsigned *esize) +int ff_get_bmp_header(AVIOContext *pb, AVStream *st, uint32_t *size) { int tag1; -if(esize) *esize = avio_rl32(pb); -elseavio_rl32(pb); +uint32_t size_ = avio_rl32(pb); +if (size) +*size = size_; st->codecpar->width = avio_rl32(pb); st->codecpar->height = (int32_t)avio_rl32(pb); avio_rl16(pb); /* planes */ ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avfilter/vf_hue: 10bit support
ffmpeg | branch: master | Michael Niedermayer | Wed Aug 1 19:48:08 2018 +0200| [2612431d1b2b442d9bf5bb639577ad2c506ae66e] | committer: Michael Niedermayer avfilter/vf_hue: 10bit support Tested-by: Tobias Rapp Tested-by: Reto Kromer Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2612431d1b2b442d9bf5bb639577ad2c506ae66e --- libavfilter/vf_hue.c | 103 +-- 1 file changed, 92 insertions(+), 11 deletions(-) diff --git a/libavfilter/vf_hue.c b/libavfilter/vf_hue.c index 45a5a1a92f..32b33c 100644 --- a/libavfilter/vf_hue.c +++ b/libavfilter/vf_hue.c @@ -80,6 +80,9 @@ typedef struct HueContext { uint8_t lut_l[256]; uint8_t lut_u[256][256]; uint8_t lut_v[256][256]; +uint16_t lut_l16[65536]; +uint16_t lut_u10[1024][1024]; +uint16_t lut_v10[1024][1024]; } HueContext; #define OFFSET(x) offsetof(HueContext, x) @@ -117,6 +120,9 @@ static inline void create_luma_lut(HueContext *h) for (i = 0; i < 256; i++) { h->lut_l[i] = av_clip_uint8(i + b * 25.5); } +for (i = 0; i < 65536; i++) { +h->lut_l16[i] = av_clip_uintp2(i + b * 102.4, 10); +} } static inline void create_chrominance_lut(HueContext *h, const int32_t c, @@ -148,6 +154,25 @@ static inline void create_chrominance_lut(HueContext *h, const int32_t c, h->lut_v[i][j] = av_clip_uint8(new_v); } } +for (i = 0; i < 1024; i++) { +for (j = 0; j < 1024; j++) { +u = i - 512; +v = j - 512; +/* + * Apply the rotation of the vector : (c * u) - (s * v) + *(s * u) + (c * v) + * De-normalize the components (without forgetting to scale 512 + * by << 16) + * Finally scale back the result by >> 16 + */ +new_u = ((c * u) - (s * v) + (1 << 15) + (512 << 16)) >> 16; +new_v = ((s * u) + (c * v) + (1 << 15) + (512 << 16)) >> 16; + +/* Prevent a potential overflow */ +h->lut_u10[i][j] = av_clip_uintp2(new_u, 10); +h->lut_v10[i][j] = av_clip_uintp2(new_v, 10); +} +} } static int set_expr(AVExpr **pexpr_ptr, char **expr_ptr, @@ -231,6 +256,11 @@ static int query_formats(AVFilterContext *ctx) AV_PIX_FMT_YUV410P, AV_PIX_FMT_YUV440P, AV_PIX_FMT_YUVA444P, AV_PIX_FMT_YUVA422P, AV_PIX_FMT_YUVA420P, +AV_PIX_FMT_YUV444P10, AV_PIX_FMT_YUV422P10, +AV_PIX_FMT_YUV420P10, +AV_PIX_FMT_YUV440P10, +AV_PIX_FMT_YUVA444P10, AV_PIX_FMT_YUVA422P10, +AV_PIX_FMT_YUVA420P10, AV_PIX_FMT_NONE }; AVFilterFormats *fmts_list = ff_make_format_list(pix_fmts); @@ -271,6 +301,22 @@ static void apply_luma_lut(HueContext *s, } } +static void apply_luma_lut10(HueContext *s, + uint16_t *ldst, const int dst_linesize, + uint16_t *lsrc, const int src_linesize, + int w, int h) +{ +int i; + +while (h--) { +for (i = 0; i < w; i++) +ldst[i] = s->lut_l16[lsrc[i]]; + +lsrc += src_linesize; +ldst += dst_linesize; +} +} + static void apply_lut(HueContext *s, uint8_t *udst, uint8_t *vdst, const int dst_linesize, uint8_t *usrc, uint8_t *vsrc, const int src_linesize, @@ -294,6 +340,29 @@ static void apply_lut(HueContext *s, } } +static void apply_lut10(HueContext *s, + uint16_t *udst, uint16_t *vdst, const int dst_linesize, + uint16_t *usrc, uint16_t *vsrc, const int src_linesize, + int w, int h) +{ +int i; + +while (h--) { +for (i = 0; i < w; i++) { +const int u = av_clip_uintp2(usrc[i], 10); +const int v = av_clip_uintp2(vsrc[i], 10); + +udst[i] = s->lut_u10[u][v]; +vdst[i] = s->lut_v10[u][v]; +} + +usrc += src_linesize; +vsrc += src_linesize; +udst += dst_linesize; +vdst += dst_linesize; +} +} + #define TS2D(ts) ((ts) == AV_NOPTS_VALUE ? NAN : (double)(ts)) #define TS2T(ts, tb) ((ts) == AV_NOPTS_VALUE ? NAN : (double)(ts) * av_q2d(tb)) @@ -305,6 +374,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *inpic) const int32_t old_hue_sin = hue->hue_sin, old_hue_cos = hue->hue_cos; const float old_brightness = hue->brightness; int direct = 0; +const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format); +const int bps = desc->comp[0].depth > 8 ? 2 : 1; if (av_frame_is_writable(inpic)) { direct = 1; @@ -367,21 +438,31 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *inpic) if (!direct) { if (!hue->brightness) av_image_copy_plane(outpic->data[0], out
[FFmpeg-cvslog] avcodec/scpr: Check for min > max in decompress_p()
ffmpeg | branch: master | Michael Niedermayer | Sat Aug 4 23:45:52 2018 +0200| [3378194ce8e9a126a7cc6ed57bedde1221790469] | committer: Michael Niedermayer avcodec/scpr: Check for min > max in decompress_p() Fixes: Timeout Fixes: 9342/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SCPR_fuzzer-4795990841229312 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=3378194ce8e9a126a7cc6ed57bedde1221790469 --- libavcodec/scpr.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libavcodec/scpr.c b/libavcodec/scpr.c index 72f59d5917..d76148998b 100644 --- a/libavcodec/scpr.c +++ b/libavcodec/scpr.c @@ -526,6 +526,9 @@ static int decompress_p(AVCodecContext *avctx, return ret; max += temp << 8; +if (min > max) +return AVERROR_INVALIDDATA; + memset(s->blocks, 0, sizeof(*s->blocks) * s->nbcount); while (min <= max) { ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avcodec/shorten: Fix signed 32bit overflow in shift in shorten_decode_frame()
ffmpeg | branch: master | Michael Niedermayer | Sun Aug 12 23:06:55 2018 +0200| [9b604e96a51a1fca92bbabfe4f7ac53f0470ee41] | committer: Michael Niedermayer 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 > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9b604e96a51a1fca92bbabfe4f7ac53f0470ee41 --- 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 */ ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avcodec/shorten: Check verbatim length
ffmpeg | branch: master | Michael Niedermayer | Sun Aug 12 22:43:33 2018 +0200| [7007dabec08f2f9f81661e71ef482dde394e17a8] | committer: Michael Niedermayer 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 > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=7007dabec08f2f9f81661e71ef482dde394e17a8 --- 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; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avcodec/shorten: Fix integer overflow in residual/LPC combination
ffmpeg | branch: master | Michael Niedermayer | Sun Aug 12 22:55:59 2018 +0200| [db7e9082e1a1479c6a8844f7adf77eae03cc2aa7] | committer: Michael Niedermayer 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 > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=db7e9082e1a1479c6a8844f7adf77eae03cc2aa7 --- 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 */ ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avcodec/frame_thread_encoder: fix memory leak that occurs when close encoder without sending eof and receiving to end
ffmpeg | branch: master | lee ju | Sat Aug 4 10:19:45 2018 +| [6a0feafebe0e74bf7ce2d12a8177c670ebf2379a] | committer: Michael Niedermayer avcodec/frame_thread_encoder: fix memory leak that occurs when close encoder without sending eof and receiving to end Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=6a0feafebe0e74bf7ce2d12a8177c670ebf2379a --- libavcodec/frame_thread_encoder.c | 17 + 1 file changed, 17 insertions(+) diff --git a/libavcodec/frame_thread_encoder.c b/libavcodec/frame_thread_encoder.c index 5ff3f7863c..55756c4c54 100644 --- a/libavcodec/frame_thread_encoder.c +++ b/libavcodec/frame_thread_encoder.c @@ -251,6 +251,23 @@ void ff_frame_thread_encoder_free(AVCodecContext *avctx){ pthread_join(c->worker[i], NULL); } +while (av_fifo_size(c->task_fifo) > 0) { +Task task; +AVFrame *frame; +av_fifo_generic_read(c->task_fifo, &task, sizeof(task), NULL); +frame = task.indata; +av_frame_free(&frame); +task.indata = NULL; +} + +for (i=0; ifinished_tasks[i].outdata != NULL) { +AVPacket *pkt = c->finished_tasks[i].outdata; +av_packet_free(&pkt); +c->finished_tasks[i].outdata = NULL; +} +} + pthread_mutex_destroy(&c->task_fifo_mutex); pthread_mutex_destroy(&c->finished_task_mutex); pthread_mutex_destroy(&c->buffer_mutex); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog