[FFmpeg-devel] [PATCH] mpeg2dec: Fix motion vector rounding for chroma components
In 16x8 motion compensation, for lower 16x8 region, the input to mpeg_motion() for motion_y was "motion_y + 16", which causes wrong rounding. For 4:2:0, chroma scaling for y is dividing by two and rounding toward zero. When motion_y < 0 and motion_y + 16 > 0, the rounding direction of "motion_y" and "motion_y + 16" is different and rounding "motion_y + 16" would be incorrect. We should input "motion_y" as is to round correctly. I add "is_16x8" flag to do that. --- libavcodec/mpegvideo_motion.c| 30 - tests/ref/fate/filter-mcdeint-fast | 60 +- tests/ref/fate/filter-mcdeint-medium | 60 +- tests/ref/fate/filter-w3fdif-complex | 60 +- tests/ref/fate/filter-w3fdif-simple | 60 +- tests/ref/fate/filter-yadif-mode0| 60 +- tests/ref/fate/filter-yadif-mode1| 118 +-- tests/ref/fate/filter-yadif10| 60 +- tests/ref/fate/filter-yadif16| 60 +- tests/ref/fate/mpeg2-field-enc | 60 +- tests/ref/fate/mpeg2-ticket6677 | 12 ++-- 11 files changed, 321 insertions(+), 319 deletions(-) diff --git a/libavcodec/mpegvideo_motion.c b/libavcodec/mpegvideo_motion.c index c913504..5624c10 100644 --- a/libavcodec/mpegvideo_motion.c +++ b/libavcodec/mpegvideo_motion.c @@ -239,20 +239,22 @@ void mpeg_motion_internal(MpegEncContext *s, int motion_y, int h, int is_mpeg12, + int is_16x8, int mb_y) { uint8_t *ptr_y, *ptr_cb, *ptr_cr; int dxy, uvdxy, mx, my, src_x, src_y, -uvsrc_x, uvsrc_y, v_edge_pos; +uvsrc_x, uvsrc_y, v_edge_pos, block_y_half; ptrdiff_t uvlinesize, linesize; v_edge_pos = s->v_edge_pos >> field_based; linesize = s->current_picture.f->linesize[0] << field_based; uvlinesize = s->current_picture.f->linesize[1] << field_based; +block_y_half = (field_based | is_16x8); dxy = ((motion_y & 1) << 1) | (motion_x & 1); src_x = s->mb_x * 16 + (motion_x >> 1); -src_y = (mb_y << (4 - field_based)) + (motion_y >> 1); +src_y = (mb_y << (4 - block_y_half)) + (motion_y >> 1); if (!is_mpeg12 && s->out_format == FMT_H263) { if ((s->workaround_bugs & FF_BUG_HPEL_CHROMA) && field_based) { @@ -260,7 +262,7 @@ void mpeg_motion_internal(MpegEncContext *s, my = motion_y >> 1; uvdxy = ((my & 1) << 1) | (mx & 1); uvsrc_x = s->mb_x * 8 + (mx >> 1); -uvsrc_y = (mb_y << (3 - field_based)) + (my >> 1); +uvsrc_y = (mb_y << (3 - block_y_half)) + (my >> 1); } else { uvdxy = dxy | (motion_y & 2) | ((motion_x & 2) >> 1); uvsrc_x = src_x >> 1; @@ -279,7 +281,7 @@ void mpeg_motion_internal(MpegEncContext *s, my = motion_y / 2; uvdxy = ((my & 1) << 1) | (mx & 1); uvsrc_x = s->mb_x * 8 + (mx >> 1); -uvsrc_y = (mb_y << (3 - field_based)) + (my >> 1); +uvsrc_y = (mb_y << (3 - block_y_half)) + (my >> 1); } else { if (s->chroma_x_shift) { // Chroma422 @@ -370,18 +372,18 @@ static void mpeg_motion(MpegEncContext *s, uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, int field_select, uint8_t **ref_picture, op_pixels_func (*pix_op)[4], -int motion_x, int motion_y, int h, int mb_y) +int motion_x, int motion_y, int h, int is_16x8, int mb_y) { #if !CONFIG_SMALL if (s->out_format == FMT_MPEG1) mpeg_motion_internal(s, dest_y, dest_cb, dest_cr, 0, 0, field_select, ref_picture, pix_op, - motion_x, motion_y, h, 1, mb_y); + motion_x, motion_y, h, 1, is_16x8, mb_y); else #endif mpeg_motion_internal(s, dest_y, dest_cb, dest_cr, 0, 0, field_select, ref_picture, pix_op, - motion_x, motion_y, h, 0, mb_y); + motion_x, motion_y, h, 0, is_16x8, mb_y); } static void mpeg_motion_field(MpegEncContext *s, uint8_t *dest_y, @@ -395,12 +397,12 @@ static void mpeg_motion_field(MpegEncContext *s, uint8_t *dest_y, if (s->out_format == FMT_MPEG1) mpeg_motion_internal(s, dest_y, dest_cb, dest_cr, 1, bottom_field, field_select, ref_picture, pix_op, - motion_x, motion_y, h, 1, mb_y); + motion_x, motion_y, h, 1, 0, mb_y); else #endif mpeg_motion_internal(s, dest_y, dest_cb, dest_cr, 1, bottom_field, field_select, ref_picture, pix_op, -
Re: [FFmpeg-devel] [PATCH 1/2] avcodec/mpeg4videodec: Ignore multiple VOL headers
On Fri, Feb 09, 2018 at 10:24:58PM +0100, Michael Niedermayer wrote: > Fixes: Ticket7005 > > Signed-off-by: Michael Niedermayer > --- > libavcodec/mpeg4videodec.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) applied [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Let us carefully observe those good qualities wherein our enemies excel us and endeavor to excel them, by avoiding what is faulty, and imitating what is excellent in them. -- Plutarch signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] mpeg2dec: Fix motion vector rounding for chroma components
On Sun, Feb 11, 2018 at 05:15:54PM +0900, Nekopanda wrote: > In 16x8 motion compensation, for lower 16x8 region, the input to > mpeg_motion() for motion_y was "motion_y + 16", which causes wrong rounding. > For 4:2:0, chroma scaling for y is dividing by two and rounding toward zero. > When motion_y < 0 and motion_y + 16 > 0, the rounding direction of "motion_y" > and "motion_y + 16" is different and rounding "motion_y + 16" would be > incorrect. > > We should input "motion_y" as is to round correctly. I add "is_16x8" flag to > do that. > --- > libavcodec/mpegvideo_motion.c| 30 - > tests/ref/fate/filter-mcdeint-fast | 60 +- > tests/ref/fate/filter-mcdeint-medium | 60 +- > tests/ref/fate/filter-w3fdif-complex | 60 +- > tests/ref/fate/filter-w3fdif-simple | 60 +- > tests/ref/fate/filter-yadif-mode0| 60 +- > tests/ref/fate/filter-yadif-mode1| 118 > +-- > tests/ref/fate/filter-yadif10| 60 +- > tests/ref/fate/filter-yadif16| 60 +- > tests/ref/fate/mpeg2-field-enc | 60 +- > tests/ref/fate/mpeg2-ticket6677 | 12 ++-- > 11 files changed, 321 insertions(+), 319 deletions(-) will apply thanks [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Into a blind darkness they enter who follow after the Ignorance, they as if into a greater darkness enter who devote themselves to the Knowledge alone. -- Isha Upanishad signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] How to pass metadata between filters
On Fri, 9 Feb 2018 18:43:11 + Mujib Haider wrote: > Dear ffmpeg-devel, > > I have a general question about the capabilities of avfilter. > > Is it possible to send meta-data between avfilters? Specifically, I want to > create a filter to take a single input image, and produce a single output > image along with metadata which encodes information about the image. Currently only via the fields AVFrames provides. There's AVFrame.metadata, and also new side data types could be added for important enough things. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] How to pass metadata between filters
On 2/11/2018 9:31 AM, wm4 wrote: > On Fri, 9 Feb 2018 18:43:11 + > Mujib Haider wrote: > >> Dear ffmpeg-devel, >> >> I have a general question about the capabilities of avfilter. >> >> Is it possible to send meta-data between avfilters? Specifically, I want to >> create a filter to take a single input image, and produce a single output >> image along with metadata which encodes information about the image. > > Currently only via the fields AVFrames provides. There's > AVFrame.metadata, and also new side data types could be added for > important enough things. There's also AVFrame.side_data if the metadata he has in mind is not an AVDictionary. This is apparently what vf_mestimate does to propagate motion vectors. New AVFrameSideDataType entries can be added if reasonable and useful, assuming what he needs is not already defined. Maybe even AVFrame.private_ref to store a pointer to some buffer, i think, but using it requires some changes so the field is guaranteed to be NULL before ownership of the frame leaves avfilter. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 1/2] avformat/aviobuf: add ff_read_line_to_bprint and ff_read_line_to_bprint_overwrite functions
Marton Balint (2018-02-10): > To be able to read lines longer than a static buffer size. > > Signed-off-by: Marton Balint > --- > libavformat/aviobuf.c | 46 ++ > libavformat/internal.h | 26 ++ > 2 files changed, 72 insertions(+) > > diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c > index 86eb6579f4..12cd73745d 100644 > --- a/libavformat/aviobuf.c > +++ b/libavformat/aviobuf.c > @@ -821,6 +821,52 @@ int ff_get_line(AVIOContext *s, char *buf, int maxlen) > return i; > } > > +int64_t ff_read_line_to_bprint(AVIOContext *s, AVBPrint *bp) > +{ > +int len, end; > +int64_t read = 0; > +char tmp[1024]; > +char c; > + > +do { > +len = 0; > +do { > +c = avio_r8(s); > +end = (c == '\r' || c == '\n' || c == '\0'); > +if (!end) > +tmp[len++] = c; > +} while (!end && len < sizeof(tmp)); > +av_bprint_append_data(bp, tmp, len); > +read += len; > +} while (!end); I think the code would be much simpler if you just call av_bprint_chars() for each read character. The loop-within-loop makes the logic a little hard to understand. If speed is critic, then you could read directly into the bprint buffer, but I do not think this is necessary. > + > +if (c == '\r' && avio_r8(s) != '\n' && !avio_feof(s)) > +avio_skip(s, -1); > + > +if (!c && s->error) > +return s->error; > + > +if (!c && !read && avio_feof(s)) > +return AVERROR_EOF; > + > +return read; > +} > + > +int64_t ff_read_line_to_bprint_overwrite(AVIOContext *s, AVBPrint *bp) > +{ > +int64_t ret; > + > +av_bprint_clear(bp); > +ret = ff_read_line_to_bprint(s, bp); > +if (ret < 0) > +return ret; > + > +if (!av_bprint_is_complete(bp)) > +return AVERROR(ENOMEM); > + > +return bp->len; > +} > + > int avio_get_str(AVIOContext *s, int maxlen, char *buf, int buflen) > { > int i; > diff --git a/libavformat/internal.h b/libavformat/internal.h > index 0d08576c29..2ac7e2e1a0 100644 > --- a/libavformat/internal.h > +++ b/libavformat/internal.h > @@ -299,6 +299,32 @@ void ff_put_v(AVIOContext *bc, uint64_t val); > */ > int ff_get_line(AVIOContext *s, char *buf, int maxlen); > > +/** > + * Read a whole line of text from AVIOContext to an AVBPrint buffer. Stop > + * reading after reaching a \\r, a \\n, a \\r\\n, a \\0 or EOF. The line > + * ending characters are NOT included in the buffer, but they are skipped on > + * the input. > + * > + * @param s the read-only AVIOContext > + * @param bp the AVBPrint buffer > + * @return the length of the read line, not including the line endings, > + * negative on error. > + */ > +int64_t ff_read_line_to_bprint(AVIOContext *s, AVBPrint *bp); > + > +/** > + * Read a whole line of text from AVIOContext to an AVBPrint buffer > overwriting > + * its contents. Stop reading after reaching a \\r, a \\n, a \\r\\n, a \\0 or > + * EOF. The line ending characters are NOT included in the buffer, but they > + * are skipped on the input. > + * > + * @param s the read-only AVIOContext > + * @param bp the AVBPrint buffer > + * @return the length of the read line not including the line endings, > + * negative on error, or if the buffer becomes truncated. > + */ > +int64_t ff_read_line_to_bprint_overwrite(AVIOContext *s, AVBPrint *bp); > + > #define SPACE_CHARS " \t\r\n" > > /** Looks reasonable except for the remark above. Regards, -- Nicolas George signature.asc Description: Digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 2/2] avformat/concatdec: add support for very long line sizes
Marton Balint (2018-02-10): > Fixes ticket #6761. > > Signed-off-by: Marton Balint > --- > libavformat/concatdec.c | 19 +++ > 1 file changed, 11 insertions(+), 8 deletions(-) > > diff --git a/libavformat/concatdec.c b/libavformat/concatdec.c > index 178fac86cb..3e41a62a36 100644 > --- a/libavformat/concatdec.c > +++ b/libavformat/concatdec.c > @@ -24,6 +24,7 @@ > #include "libavutil/opt.h" > #include "libavutil/parseutils.h" > #include "libavutil/timestamp.h" > +#include "libavutil/bprint.h" Nit: alphabetic order. > #include "avformat.h" > #include "internal.h" > #include "url.h" > @@ -386,18 +387,18 @@ static int concat_read_close(AVFormatContext *avf) > static int concat_read_header(AVFormatContext *avf) > { > ConcatContext *cat = avf->priv_data; > -uint8_t buf[4096]; > +AVBPrint bp; > uint8_t *cursor, *keyword; > -int ret, line = 0, i; > +int line = 0, i; > unsigned nb_files_alloc = 0; > ConcatFile *file = NULL; > -int64_t time = 0; > +int64_t ret, time = 0; > > -while (1) { > -if ((ret = ff_get_line(avf->pb, buf, sizeof(buf))) <= 0) > -break; > +av_bprint_init(&bp, 0, AV_BPRINT_SIZE_UNLIMITED); > + > +while ((ret = ff_read_line_to_bprint_overwrite(avf->pb, &bp)) >= 0) { > line++; > -cursor = buf; > +cursor = bp.str; > keyword = get_keyword(&cursor); > if (!*keyword || *keyword == '#') > continue; > @@ -473,7 +474,7 @@ static int concat_read_header(AVFormatContext *avf) > FAIL(AVERROR_INVALIDDATA); > } > } > -if (ret < 0) > +if (ret != AVERROR_EOF && ret < 0) > goto fail; > if (!cat->nb_files) > FAIL(AVERROR_INVALIDDATA); > @@ -499,9 +500,11 @@ static int concat_read_header(AVFormatContext *avf) > MATCH_ONE_TO_ONE; > if ((ret = open_file(avf, 0)) < 0) > goto fail; > +av_bprint_finalize(&bp, NULL); > return 0; > > fail: > +av_bprint_finalize(&bp, NULL); > concat_read_close(avf); > return ret; > } LGTM, thanks. Regards, -- Nicolas George signature.asc Description: Digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 3/3] mpegvideo_parser: fix indentation of an if statement
From: Masaki Tanaka --- libavcodec/mpegvideo_parser.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/mpegvideo_parser.c b/libavcodec/mpegvideo_parser.c index 4f554b684e..ecf7c28e72 100644 --- a/libavcodec/mpegvideo_parser.c +++ b/libavcodec/mpegvideo_parser.c @@ -63,7 +63,7 @@ static void mpegvideo_extract_headers(AVCodecParserContext *s, s->output_picture_number = (buf[0] << 2) | (buf[1] >> 6); s->pict_type = (buf[1] >> 3) & 7; if (bytes_left >= 4) -vbv_delay = ((buf[1] & 0x07) << 13) | (buf[2] << 5) | (buf[3] >> 3); +vbv_delay = ((buf[1] & 0x07) << 13) | (buf[2] << 5) | (buf[3] >> 3); } break; case SEQ_START_CODE: -- 2.14.3 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 0/3] MPEG-2 video parser improvements
These were brought to my knowledge by Yusuke, and they seemed correct according to the specification, as well as the picture structure parsing patch apparently fixes the detected field order with field coded picture MPEG-2 video streams. Masaki Tanaka (3): mpegvideo_parser: implement parsing of the picture structure field mpegvideo_parser: parse the output picture number mpegvideo_parser: fix indentation of an if statement libavcodec/mpegvideo_parser.c | 19 +-- 1 file changed, 17 insertions(+), 2 deletions(-) -- 2.14.3 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 1/3] mpegvideo_parser: implement parsing of the picture structure field
From: Masaki Tanaka Lets one receive the proper field order from pictures coded in field picture mode, until now forcibly set to BFF. --- libavcodec/mpegvideo_parser.c | 16 +++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/libavcodec/mpegvideo_parser.c b/libavcodec/mpegvideo_parser.c index be240b6890..3406346a8b 100644 --- a/libavcodec/mpegvideo_parser.c +++ b/libavcodec/mpegvideo_parser.c @@ -41,7 +41,7 @@ static void mpegvideo_extract_headers(AVCodecParserContext *s, uint32_t start_code; int frame_rate_index, ext_type, bytes_left; int frame_rate_ext_n, frame_rate_ext_d; -int top_field_first, repeat_first_field, progressive_frame; +int picture_structure, top_field_first, repeat_first_field, progressive_frame; int horiz_size_ext, vert_size_ext, bit_rate_ext; int did_set_size=0; int set_dim_ret = 0; @@ -51,6 +51,7 @@ static void mpegvideo_extract_headers(AVCodecParserContext *s, enum AVPixelFormat pix_fmt = AV_PIX_FMT_NONE; //FIXME replace the crap with get_bits() s->repeat_pict = 0; +s->picture_structure = AV_PICTURE_STRUCTURE_UNKNOWN; while (buf < buf_end) { start_code= -1; @@ -114,6 +115,7 @@ static void mpegvideo_extract_headers(AVCodecParserContext *s, break; case 0x8: /* picture coding extension */ if (bytes_left >= 5) { +picture_structure = buf[2] & 0x03; top_field_first = buf[3] & (1 << 7); repeat_first_field = buf[3] & (1 << 1); progressive_frame = buf[4] & (1 << 7); @@ -138,6 +140,18 @@ static void mpegvideo_extract_headers(AVCodecParserContext *s, s->field_order = AV_FIELD_BB; } else s->field_order = AV_FIELD_PROGRESSIVE; + +switch (picture_structure) { +case PICT_TOP_FIELD: +s->picture_structure = AV_PICTURE_STRUCTURE_TOP_FIELD; +break; +case PICT_BOTTOM_FIELD: +s->picture_structure = AV_PICTURE_STRUCTURE_BOTTOM_FIELD; +break; +case PICT_FRAME: +s->picture_structure = AV_PICTURE_STRUCTURE_FRAME; +break; +} } break; } -- 2.14.3 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 2/3] mpegvideo_parser: parse the output picture number
From: Masaki Tanaka Utilizes the temporal_reference field from the picture header. --- libavcodec/mpegvideo_parser.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavcodec/mpegvideo_parser.c b/libavcodec/mpegvideo_parser.c index 3406346a8b..4f554b684e 100644 --- a/libavcodec/mpegvideo_parser.c +++ b/libavcodec/mpegvideo_parser.c @@ -60,6 +60,7 @@ static void mpegvideo_extract_headers(AVCodecParserContext *s, switch(start_code) { case PICTURE_START_CODE: if (bytes_left >= 2) { +s->output_picture_number = (buf[0] << 2) | (buf[1] >> 6); s->pict_type = (buf[1] >> 3) & 7; if (bytes_left >= 4) vbv_delay = ((buf[1] & 0x07) << 13) | (buf[2] << 5) | (buf[3] >> 3); -- 2.14.3 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avcodec/vp3: Error out on invalid num_coeffs in unpack_vlcs()
On Sun, Feb 11, 2018 at 03:38:54AM +0100, Michael Niedermayer wrote: > This fixes a hypothetical integer overflow > > Signed-off-by: Michael Niedermayer > --- > libavcodec/vp3.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) will apply and backport soon and then make a new release from 3.4 [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB "You are 36 times more likely to die in a bathtub than at the hands of a terrorist. Also, you are 2.5 times more likely to become a president and 2 times more likely to become an astronaut, than to die in a terrorist attack." -- Thoughty2 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/3] mpegvideo_parser: implement parsing of the picture structure field
On Sun, Feb 11, 2018 at 04:37:50PM +0200, Jan Ekström wrote: > From: Masaki Tanaka > > Lets one receive the proper field order from pictures coded in > field picture mode, until now forcibly set to BFF. > --- > libavcodec/mpegvideo_parser.c | 16 +++- > 1 file changed, 15 insertions(+), 1 deletion(-) probably ok [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Democracy is the form of government in which you can choose your dictator signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 2/3] mpegvideo_parser: parse the output picture number
On Sun, Feb 11, 2018 at 04:37:51PM +0200, Jan Ekström wrote: > From: Masaki Tanaka > > Utilizes the temporal_reference field from the picture header. > --- > libavcodec/mpegvideo_parser.c | 1 + > 1 file changed, 1 insertion(+) should be ok unless its intended to also restore the MSB Theres no code using output_picture_number currently thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB "You are 36 times more likely to die in a bathtub than at the hands of a terrorist. Also, you are 2.5 times more likely to become a president and 2 times more likely to become an astronaut, than to die in a terrorist attack." -- Thoughty2 signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 2/3] mpegvideo_parser: parse the output picture number
On Sun, Feb 11, 2018 at 7:52 PM, Michael Niedermayer wrote: > > should be ok unless its intended to also restore the MSB > The value seemed to be 10bit and if the pointer is at the position right after the picture_start_code, then `buf[0] << 2` would move the 8 bits left of data two bits leftwards, and `buf[1] >> 6` would then move the topmost bits of the following byte to be the bottom-most bits. Unless you mean that there's a forgotten `(uint16_t)` there as the end value has 10 bits of effective data, making the correct way of doing it something a la `(((uint16_t)buf[0]) << 2) | (((uint16_t)buf[1]) >> 6)`? > Theres no code using output_picture_number currently > Seems like some API users utilize this value. Jan ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 1/2] avcodec/mpeg4videodec: Ignore multiple VOL headers
2018-02-09 22:24 GMT+01:00 Michael Niedermayer : > Fixes: Ticket7005 > > Signed-off-by: Michael Niedermayer > --- > libavcodec/mpeg4videodec.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c > index 756753e2fc..19210d97fe 100644 > --- a/libavcodec/mpeg4videodec.c > +++ b/libavcodec/mpeg4videodec.c > @@ -2707,8 +2707,8 @@ int ff_mpeg4_decode_picture_header(Mpeg4DecContext > *ctx, GetBitContext *gb) > > if (startcode >= 0x120 && startcode <= 0x12F) { > if (vol) { > -av_log(s->avctx, AV_LOG_ERROR, "Multiple VOL headers"); > -return AVERROR_INVALIDDATA; > +av_log(s->avctx, AV_LOG_WARNING, "Ignoring multiple VOL > headers\n"); > +continue; > } Is it expected that the warning is printed as following on decoding now (context switches between NULL and mpeg4)? Carl Eugen $ ffmpeg -i mpeg-4.avi -f null - ffmpeg version N-90001-gf2318ae Copyright (c) 2000-2018 the FFmpeg developers built with gcc 6.3.0 (GCC) configuration: --enable-gpl libavutil 56. 7.100 / 56. 7.100 libavcodec 58. 10.100 / 58. 10.100 libavformat58. 9.100 / 58. 9.100 libavdevice58. 1.100 / 58. 1.100 libavfilter 7. 11.101 / 7. 11.101 libswscale 5. 0.101 / 5. 0.101 libswresample 3. 0.101 / 3. 0.101 libpostproc55. 0.100 / 55. 0.100 [mpeg4 @ 0x3eb2a00] Ignoring multiple VOL headers Last message repeated 3 times Input #0, avi, from '../Samples/tickets/ticket7005/mpeg-4.avi': Duration: 00:00:03.08, start: 0.00, bitrate: 2415 kb/s Stream #0:0: Video: mpeg4 (Simple Profile) (XVID / 0x44495658), yuv420p, 640x480 [SAR 10:11 DAR 40:33], 2431 kb/s, 25 fps, 25 tbr, 25 tbn, 25 tbc Stream mapping: Stream #0:0 -> #0:0 (mpeg4 (native) -> wrapped_avframe (native)) Press [q] to stop, [?] for help [mpeg4 @ 0x3ec63c0] Ignoring multiple VOL headers Last message repeated 2 times Output #0, null, to 'pipe:': Metadata: encoder : Lavf58.9.100 Stream #0:0: Video: wrapped_avframe, yuv420p, 640x480 [SAR 10:11 DAR 40:33], q=2-31, 200 kb/s, 25 fps, 25 tbn, 25 tbc Metadata: encoder : Lavc58.10.100 wrapped_avframe [NULL @ 0x3eb2a00] Ignoring multiple VOL headers [mpeg4 @ 0x3ec63c0] Ignoring multiple VOL headers [NULL @ 0x3eb2a00] Ignoring multiple VOL headers [mpeg4 @ 0x3ec63c0] Ignoring multiple VOL headers [NULL @ 0x3eb2a00] Ignoring multiple VOL headers [mpeg4 @ 0x3ec63c0] Ignoring multiple VOL headers [NULL @ 0x3eb2a00] Ignoring multiple VOL headers [mpeg4 @ 0x3ec63c0] Ignoring multiple VOL headers [NULL @ 0x3eb2a00] Ignoring multiple VOL headers [mpeg4 @ 0x3ec63c0] Ignoring multiple VOL headers [NULL @ 0x3eb2a00] Ignoring multiple VOL headers [mpeg4 @ 0x3ec63c0] Ignoring multiple VOL headers [NULL @ 0x3eb2a00] Ignoring multiple VOL headers [mpeg4 @ 0x3ec63c0] Ignoring multiple VOL headers [NULL @ 0x3eb2a00] Ignoring multiple VOL headers [mpeg4 @ 0x3ec63c0] Ignoring multiple VOL headers frame= 77 fps=0.0 q=-0.0 Lsize=N/A time=00:00:03.08 bitrate=N/A speed= 164x video:40kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avformat/opensrt: add Haivision Open SRT protocol
Hi. I had a look at the whole code. There are a few remarks below. Sorry for the delay, a lot of things on my place these days. Nablet Developer (2018-01-30): > protocol requires libsrt (https://github.com/Haivision/srt) to be > installed > > Signed-off-by: Nablet Developer > --- > MAINTAINERS | 1 + > configure | 9 + > doc/protocols.texi | 116 + > libavformat/Makefile| 1 + > libavformat/opensrt.c | 621 > > libavformat/protocols.c | 1 + > 6 files changed, 749 insertions(+) > create mode 100644 libavformat/opensrt.c > > diff --git a/MAINTAINERS b/MAINTAINERS > index ba7a728..0317f24 100644 > --- a/MAINTAINERS > +++ b/MAINTAINERS > @@ -498,6 +498,7 @@ Protocols: >http.cRonald S. Bultje >libssh.c Lukasz Marek >mms*.cRonald S. Bultje > + opensrt.c Nablet Developer >udp.c Luca Abeni >icecast.c Marvin Scholz > > diff --git a/configure b/configure > index fcfa7aa..57705ee 100755 > --- a/configure > +++ b/configure > @@ -294,6 +294,7 @@ External library support: >--enable-opengl enable OpenGL rendering [no] >--enable-openssl enable openssl, needed for https support > if gnutls or libtls is not used [no] > + --enable-opensrt enable Haivision Open SRT protocol [no] >--disable-sndio disable sndio support [autodetect] >--disable-schannel disable SChannel SSP, needed for TLS support on > Windows if openssl and gnutls are not used > [autodetect] > @@ -1641,6 +1642,7 @@ EXTERNAL_LIBRARY_LIST=" > mediacodec > openal > opengl > +opensrt > " > > HWACCEL_AUTODETECT_LIBRARY_LIST=" > @@ -3148,6 +3150,8 @@ libssh_protocol_deps="libssh" > libtls_conflict="openssl gnutls" > mmsh_protocol_select="http_protocol" > mmst_protocol_select="network" > +opensrt_protocol_select="network" > +opensrt_protocol_deps="opensrt" > rtmp_protocol_conflict="librtmp_protocol" > rtmp_protocol_select="tcp_protocol" > rtmp_protocol_suggest="zlib" > @@ -5986,6 +5990,7 @@ enabled omx && require_header OMX_Core.h > enabled omx_rpi && { check_header OMX_Core.h || > { ! enabled cross_compile && add_cflags > -isystem/opt/vc/include/IL && check_header OMX_Core.h ; } || > die "ERROR: OpenMAX IL headers not found"; } > && enable omx > +enabled opensrt && require_pkg_config libsrt "srt >= 1.2.0" > srt/srt.h srt_socket > enabled openssl && { check_pkg_config openssl openssl > openssl/ssl.h OPENSSL_init_ssl || > check_pkg_config openssl openssl > openssl/ssl.h SSL_library_init || > check_lib openssl openssl/ssl.h > SSL_library_init -lssl -lcrypto || > @@ -6036,6 +6041,10 @@ if enabled decklink; then > esac > fi > > +if enabled opensrt; then > +opensrt_protocol_extralibs="$opensrt_protocol_extralibs -lsrt" > +fi This looks suspicious: pkg-config should have added -lsrt automatically. > + > enabled securetransport && > check_func SecIdentityCreate "-Wl,-framework,CoreFoundation > -Wl,-framework,Security" && > check_lib securetransport "Security/SecureTransport.h > Security/Security.h" "SSLCreateContext" "-Wl,-framework,CoreFoundation > -Wl,-framework,Security" || > diff --git a/doc/protocols.texi b/doc/protocols.texi > index 98deb73..2e5e630 100644 > --- a/doc/protocols.texi > +++ b/doc/protocols.texi > @@ -755,6 +755,122 @@ Set the workgroup used for making connections. By > default workgroup is not speci > > For more information see: @url{http://www.samba.org/}. > > +@section srt > + > +Haivision Secure Reliable Transport Protocol via libsrt. > + > +The required syntax for a SRT url is: > +@example > +srt://@var{hostname}:@var{port}[?@var{options}] > +@end example > + > +@var{options} contains a list of &-separated options of the form > +@var{key}=@var{val}. > + > +This protocol accepts the following options. > + > +@table @option > +@item conntimeo Please do not truncate the name. > +Connection timeout. SRT cannot connect for RTT > 1500 msec > +(2 handshake exchanges) with the default connect timeout of 3 seconds. This > option > +applies to the caller and rendezvous connection modes. The connect timeout > is 10 times > +the value set for the rendezvous mode (which can be used as a workaround for > this > +connection problem with earlier versions). Nit: maybe wrap the lines shorter, longer lines are more tiring to read. > + > +@item fc=@var{bytes} > +Flight Flag Size (Window Size), in bytes. FC is actually an internal > parameter and > +you should set it to not less than @option{recv_buffe
Re: [FFmpeg-devel] [PATCH]lavf/rtpdec: Constify several pointers
2018-02-11 0:32 GMT+01:00 Muhammad Faiz : > On Sat, Feb 10, 2018 at 8:57 AM, Carl Eugen Hoyos wrote: >> Hi! >> >> Attached patch fixes two warnings. >> libavformat/rtpdec.c: In function ‘ff_rtp_handler_find_by_name’: >> libavformat/rtpdec.c:155:20: warning: return discards ‘const’ >> qualifier from pointer target type [-Wdiscarded-qualifiers] >> return handler; >> ^~~ >> libavformat/rtpdec.c: In function ‘ff_rtp_handler_find_by_id’: >> libavformat/rtpdec.c:168:20: warning: return discards ‘const’ >> qualifier from pointer target type [-Wdiscarded-qualifiers] >> return handler; >> ^~~ >> >> Please comment, Carl Eugen >> >> From b0383afe16c62fcb0fbc7ea49168edd2f26ac0aa Mon Sep 17 00:00:00 2001 >> From: Carl Eugen Hoyos >> Date: Sat, 10 Feb 2018 02:54:42 +0100 >> Subject: [PATCH] lavf/rtpdec: Constify several pointers. >> >> Fixes two warnings: >> libavformat/rtpdec.c:155:20: warning: return discards 'const' qualifier from >> pointer target type [-Wdiscarded-qualifiers] >> libavformat/rtpdec.c:168:20: warning: return discards 'const' qualifier from >> pointer target type [-Wdiscarded-qualifiers] >> --- >> libavformat/rdt.c|2 +- >> libavformat/rdt.h|2 +- >> libavformat/rtpdec.c |6 +++--- >> libavformat/rtpdec.h |6 +++--- >> libavformat/rtsp.c |8 >> libavformat/rtsp.h |2 +- >> 6 files changed, 13 insertions(+), 13 deletions(-) > > LGTM. Patch applied. > Probably, the variables should also be constified. Not sure which variables you mean. Thank you, Carl Eugen ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH]lavf/matroskaenc: Do not allow -reserve_index_space 1
Hi! Attached patch fixes an assertion failure with the following command line: $ ffmpeg -f lavfi -i testsrc -reserve_index_space 1 out.mkv Please comment, Carl Eugen From 4566d5f90f24bf2373175a8aad84c82be6b1a9eb Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Sun, 11 Feb 2018 20:16:02 +0100 Subject: [PATCH] lavf/matroskaenc: Do not allow -reserve_index_space 1. Fixes an assertion failure: Assertion size >= 2 failed at libavformat/matroskaenc.c:298 --- libavformat/matroskaenc.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index f22c2ab..b0dc4dd 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -2726,7 +2726,7 @@ static const AVCodecTag additional_subtitle_tags[] = { #define OFFSET(x) offsetof(MatroskaMuxContext, x) #define FLAGS AV_OPT_FLAG_ENCODING_PARAM static const AVOption options[] = { -{ "reserve_index_space", "Reserve a given amount of space (in bytes) at the beginning of the file for the index (cues).", OFFSET(reserve_cues_space), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, FLAGS }, +{ "reserve_index_space", "Reserve a given amount of space (in bytes) at the beginning of the file for the index (cues).", OFFSET(reserve_cues_space), AV_OPT_TYPE_INT, { .i64 = 0 }, 2, INT_MAX, FLAGS }, { "cluster_size_limit", "Store at most the provided amount of bytes in a cluster. ", OFFSET(cluster_size_limit), AV_OPT_TYPE_INT , { .i64 = -1 }, -1, INT_MAX, FLAGS }, { "cluster_time_limit", "Store at most the provided number of milliseconds in a cluster.", OFFSET(cluster_time_limit), AV_OPT_TYPE_INT64, { .i64 = -1 }, -1, INT64_MAX, FLAGS }, { "dash", "Create a WebM file conforming to WebM DASH specification", OFFSET(is_dash), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, FLAGS }, -- 1.7.10.4 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH]lavf/matroskaenc: Do not allow -reserve_index_space 1
Carl Eugen Hoyos (2018-02-11): > Attached patch fixes an assertion failure with the following command line: > $ ffmpeg -f lavfi -i testsrc -reserve_index_space 1 out.mkv > > Please comment, Carl Eugen Reading the code, it is pretty obvious that 0 is a valid value and forbidding it would be bad. By the way, you can write "-lavfi" instead of "-f lavfi -i", unless you want to test the lavfi device specifically. Regards, -- Nicolas George signature.asc Description: Digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH]lavf/matroskaenc: Do not allow -reserve_index_space 1
2018-02-11 20:23 GMT+01:00 Nicolas George : > Carl Eugen Hoyos (2018-02-11): >> Attached patch fixes an assertion failure with the following command line: >> $ ffmpeg -f lavfi -i testsrc -reserve_index_space 1 out.mkv > Reading the code, it is pretty obvious that 0 is a valid value and > forbidding it would be bad. It is still the used default value... Uglier alternative attached. Carl Eugen From 6a08d7cb89294b81e87dac93bbf58627e5d37cec Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Sun, 11 Feb 2018 20:41:32 +0100 Subject: [PATCH] lavf/matroskaenc: Force the minimum value for -reserve_index_space to 2. Fixes an assertion failure: Assertion size >= 2 failed at libavformat/matroskaenc.c:298 --- libavformat/matroskaenc.c |2 ++ 1 file changed, 2 insertions(+) diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index f22c2ab..5950b4d 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -2001,6 +2001,8 @@ static int mkv_write_header(AVFormatContext *s) } if ((pb->seekable & AVIO_SEEKABLE_NORMAL) && mkv->reserve_cues_space) { mkv->cues_pos = avio_tell(pb); +if (mkv->reserve_cues_space == 1) +mkv->reserve_cues_space++; put_ebml_void(pb, mkv->reserve_cues_space); } -- 1.7.10.4 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH]lavf/matroskaenc: Do not allow -reserve_index_space 1
Carl Eugen Hoyos (2018-02-11): > 2018-02-11 20:23 GMT+01:00 Nicolas George : > > Carl Eugen Hoyos (2018-02-11): > >> Attached patch fixes an assertion failure with the following command line: > >> $ ffmpeg -f lavfi -i testsrc -reserve_index_space 1 out.mkv > > > Reading the code, it is pretty obvious that 0 is a valid value and > > forbidding it would be bad. > > It is still the used default value... > > Uglier alternative attached. > > Carl Eugen > From 6a08d7cb89294b81e87dac93bbf58627e5d37cec Mon Sep 17 00:00:00 2001 > From: Carl Eugen Hoyos > Date: Sun, 11 Feb 2018 20:41:32 +0100 > Subject: [PATCH] lavf/matroskaenc: Force the minimum value for > -reserve_index_space to 2. > > Fixes an assertion failure: > Assertion size >= 2 failed at libavformat/matroskaenc.c:298 > --- > libavformat/matroskaenc.c |2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c > index f22c2ab..5950b4d 100644 > --- a/libavformat/matroskaenc.c > +++ b/libavformat/matroskaenc.c > @@ -2001,6 +2001,8 @@ static int mkv_write_header(AVFormatContext *s) > } > if ((pb->seekable & AVIO_SEEKABLE_NORMAL) && mkv->reserve_cues_space) { > mkv->cues_pos = avio_tell(pb); > +if (mkv->reserve_cues_space == 1) > +mkv->reserve_cues_space++; > put_ebml_void(pb, mkv->reserve_cues_space); I would have written it: put_ebml_void(pb, FFMAX(2, mkv->reserve_cues_space)); That is more or less equivalent to this patch. But I do not maintain that file, and I do not know the actual meaning of these fields any more than you. > } > Regards, -- Nicolas George signature.asc Description: Digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 1/3] mpegvideo_parser: implement parsing of the picture structure field
2018-02-11 23:37 GMT+09:00 Jan Ekström : > From: Masaki Tanaka > > Lets one receive the proper field order from pictures coded in > field picture mode, until now forcibly set to BFF. > --- > libavcodec/mpegvideo_parser.c | 16 +++- > 1 file changed, 15 insertions(+), 1 deletion(-) > > diff --git a/libavcodec/mpegvideo_parser.c b/libavcodec/mpegvideo_parser.c > index be240b6890..3406346a8b 100644 > --- a/libavcodec/mpegvideo_parser.c > +++ b/libavcodec/mpegvideo_parser.c > @@ -41,7 +41,7 @@ static void mpegvideo_extract_headers(AVCodecParserContext > *s, > uint32_t start_code; > int frame_rate_index, ext_type, bytes_left; > int frame_rate_ext_n, frame_rate_ext_d; > -int top_field_first, repeat_first_field, progressive_frame; > +int picture_structure, top_field_first, repeat_first_field, > progressive_frame; > int horiz_size_ext, vert_size_ext, bit_rate_ext; > int did_set_size=0; > int set_dim_ret = 0; > @@ -51,6 +51,7 @@ static void mpegvideo_extract_headers(AVCodecParserContext > *s, > enum AVPixelFormat pix_fmt = AV_PIX_FMT_NONE; > //FIXME replace the crap with get_bits() > s->repeat_pict = 0; > +s->picture_structure = AV_PICTURE_STRUCTURE_UNKNOWN; > > while (buf < buf_end) { > start_code= -1; > @@ -114,6 +115,7 @@ static void mpegvideo_extract_headers(AVCodecParserContext > *s, > break; > case 0x8: /* picture coding extension */ > if (bytes_left >= 5) { > +picture_structure = buf[2] & 0x03; > top_field_first = buf[3] & (1 << 7); > repeat_first_field = buf[3] & (1 << 1); > progressive_frame = buf[4] & (1 << 7); > @@ -138,6 +140,18 @@ static void > mpegvideo_extract_headers(AVCodecParserContext > *s, > s->field_order = AV_FIELD_BB; > } else > s->field_order = AV_FIELD_PROGRESSIVE; > + > +switch (picture_structure) { > +case PICT_TOP_FIELD: > +s->picture_structure = > AV_PICTURE_STRUCTURE_TOP_FIELD; > +break; > +case PICT_BOTTOM_FIELD: > +s->picture_structure = > AV_PICTURE_STRUCTURE_BOTTOM_FIELD; > +break; > +case PICT_FRAME: > +s->picture_structure = > AV_PICTURE_STRUCTURE_FRAME; > +break; > +} > Libavcodec handles MPEG-2 Video packet per frame but not picture, and the parser stops immediately after parsing the first slice of the picture. So, the parser returns per full frame but picture_structure says it's a field picture. This is evil and this is the reason why I hesitate to post this patch. I'm interested in how other devs consider this evil solution. I think the parser should parse the second field too if encountering a field coded picture, and treat the packet as frame coded and set field_order appropriate. > } > break; > } > -- > 2.14.3 > > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel > ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avdevice/decklink_dec: Extract NTSC VANC
On Mon, 5 Feb 2018, Ray Tiley wrote: This changes how NTSC VANC is extracted from the buffer. In NTSC the vanc data interleved between the uyvy and not just the luma as in high definition resolutions. In my testing this allows a decklink card encoding valid NTSC closed captions to pass the caption data to the x264 encoder. Updated with rewviews from Devon Heitmueller and Marton Balint. Signed-off-by: Ray Tiley --- libavdevice/decklink_dec.cpp | 37 ++--- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/libavdevice/decklink_dec.cpp b/libavdevice/decklink_dec.cpp index 94dae26..c3683bb 100644 --- a/libavdevice/decklink_dec.cpp +++ b/libavdevice/decklink_dec.cpp @@ -149,6 +149,30 @@ static void extract_luma_from_v210(uint16_t *dst, const uint8_t *src, int width) } } +static void unpack_v210(uint16_t *dst, const uint8_t *src, int width) +{ +int i; +for (i = 0; i < width / 6; i++) { +*dst++ = src[0] + ((src[1] & 3) << 8); +*dst++ = (src[1] >> 2) + ((src[2] & 15) << 6); +*dst++ = (src[2] >> 4) + ((src[3] & 63) << 4); + +*dst++ = src[4] + ((src[5] & 3) << 8); +*dst++ = (src[5] >> 2) + ((src[6] & 15) << 6); +*dst++ = (src[6] >> 4) + ((src[7] & 63) << 4); + +*dst++ = src[8] + ((src[9] & 3) << 8); +*dst++ = (src[9] >> 2) + ((src[10] & 15) << 6); +*dst++ = (src[10] >> 4) + ((src[11] & 63) << 4); + +*dst++ = src[12] + ((src[13] & 3) << 8); +*dst++ = (src[13] >> 2) + ((src[14] & 15) << 6); +*dst++ = (src[14] >> 4) + ((src[15] & 63) << 4); + +src += 16; +} +} Sorry for the delay, and for not spotting this earlier, but I think you can simply write this: int i; for (i = 0; i < width * 2 / 3; i++) { *dst++ = src[0] + ((src[1] & 3) << 8); *dst++ = (src[1] >> 2) + ((src[2] & 15) << 6); *dst++ = (src[2] >> 4) + ((src[3] & 63) << 4); src += 4; } + static uint8_t calc_parity_and_line_offset(int line) { uint8_t ret = (line < 313) << 5; @@ -740,9 +764,16 @@ HRESULT decklink_input_callback::VideoInputFrameArrived( for (i = vanc_line_numbers[idx].vanc_start; i <= vanc_line_numbers[idx].vanc_end; i++) { uint8_t *buf; if (vanc->GetBufferForVerticalBlankingLine(i, (void**)&buf) == S_OK) { -uint16_t luma_vanc[MAX_WIDTH_VANC]; -extract_luma_from_v210(luma_vanc, buf, videoFrame->GetWidth()); -txt_buf = get_metadata(avctx, luma_vanc, videoFrame->GetWidth(), +uint16_t vanc[MAX_WIDTH_VANC]; +size_t vanc_size = videoFrame->GetWidth(); +if (ctx->bmd_mode == bmdModeNTSC && +videoFrame->GetWidth() * 2 <= MAX_WIDTH_VANC) { + vanc_size = vanc_size * 2; + unpack_v210(vanc, buf, videoFrame->GetWidth()); Please use 4 space indent. +} else { + extract_luma_from_v210(vanc, buf, videoFrame->GetWidth()); +} +txt_buf = get_metadata(avctx, vanc, vanc_size, txt_buf, sizeof(txt_buf0) - (txt_buf - txt_buf0), &pkt); } if (i == vanc_line_numbers[idx].field0_vanc_end) Thanks, Marton ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 1/2] avformat/aviobuf: add ff_read_line_to_bprint and ff_read_line_to_bprint_overwrite functions
On Sun, 11 Feb 2018, Nicolas George wrote: Marton Balint (2018-02-10): To be able to read lines longer than a static buffer size. Signed-off-by: Marton Balint --- libavformat/aviobuf.c | 46 ++ libavformat/internal.h | 26 ++ 2 files changed, 72 insertions(+) diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c index 86eb6579f4..12cd73745d 100644 --- a/libavformat/aviobuf.c +++ b/libavformat/aviobuf.c @@ -821,6 +821,52 @@ int ff_get_line(AVIOContext *s, char *buf, int maxlen) return i; } +int64_t ff_read_line_to_bprint(AVIOContext *s, AVBPrint *bp) +{ +int len, end; +int64_t read = 0; +char tmp[1024]; +char c; + +do { +len = 0; +do { +c = avio_r8(s); +end = (c == '\r' || c == '\n' || c == '\0'); +if (!end) +tmp[len++] = c; +} while (!end && len < sizeof(tmp)); +av_bprint_append_data(bp, tmp, len); +read += len; +} while (!end); I think the code would be much simpler if you just call av_bprint_chars() for each read character. The loop-within-loop makes the logic a little hard to understand. If speed is critic, then you could read directly into the bprint buffer, but I do not think this is necessary. It is a 500% speed improvement on a 260 MB line compared to using av_bprint_chars, so I'd rather leave it as is. I can add a comment saying "for performance reasons we fill a temporary buffer, and use av_bprint functions on chunks of data". Regards, Marton ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 1/3] mpegvideo_parser: implement parsing of the picture structure field
On Mon, Feb 12, 2018 at 05:37:32AM +0900, Yusuke Nakamura wrote: > 2018-02-11 23:37 GMT+09:00 Jan Ekström : > > > From: Masaki Tanaka > > > > Lets one receive the proper field order from pictures coded in > > field picture mode, until now forcibly set to BFF. > > --- > > libavcodec/mpegvideo_parser.c | 16 +++- > > 1 file changed, 15 insertions(+), 1 deletion(-) > > > > diff --git a/libavcodec/mpegvideo_parser.c b/libavcodec/mpegvideo_parser.c > > index be240b6890..3406346a8b 100644 > > --- a/libavcodec/mpegvideo_parser.c > > +++ b/libavcodec/mpegvideo_parser.c > > @@ -41,7 +41,7 @@ static void mpegvideo_extract_headers(AVCodecParserContext > > *s, > > uint32_t start_code; > > int frame_rate_index, ext_type, bytes_left; > > int frame_rate_ext_n, frame_rate_ext_d; > > -int top_field_first, repeat_first_field, progressive_frame; > > +int picture_structure, top_field_first, repeat_first_field, > > progressive_frame; > > int horiz_size_ext, vert_size_ext, bit_rate_ext; > > int did_set_size=0; > > int set_dim_ret = 0; > > @@ -51,6 +51,7 @@ static void mpegvideo_extract_headers(AVCodecParserContext > > *s, > > enum AVPixelFormat pix_fmt = AV_PIX_FMT_NONE; > > //FIXME replace the crap with get_bits() > > s->repeat_pict = 0; > > +s->picture_structure = AV_PICTURE_STRUCTURE_UNKNOWN; > > > > while (buf < buf_end) { > > start_code= -1; > > @@ -114,6 +115,7 @@ static void > > mpegvideo_extract_headers(AVCodecParserContext > > *s, > > break; > > case 0x8: /* picture coding extension */ > > if (bytes_left >= 5) { > > +picture_structure = buf[2] & 0x03; > > top_field_first = buf[3] & (1 << 7); > > repeat_first_field = buf[3] & (1 << 1); > > progressive_frame = buf[4] & (1 << 7); > > @@ -138,6 +140,18 @@ static void > > mpegvideo_extract_headers(AVCodecParserContext > > *s, > > s->field_order = AV_FIELD_BB; > > } else > > s->field_order = AV_FIELD_PROGRESSIVE; > > + > > +switch (picture_structure) { > > +case PICT_TOP_FIELD: > > +s->picture_structure = > > AV_PICTURE_STRUCTURE_TOP_FIELD; > > +break; > > +case PICT_BOTTOM_FIELD: > > +s->picture_structure = > > AV_PICTURE_STRUCTURE_BOTTOM_FIELD; > > +break; > > +case PICT_FRAME: > > +s->picture_structure = > > AV_PICTURE_STRUCTURE_FRAME; > > +break; > > +} > > > > Libavcodec handles MPEG-2 Video packet per frame but not picture, and the > parser stops immediately after parsing the first slice of the picture. So, > the parser returns per full frame but picture_structure says it's a field > picture. This is evil and this is the reason why I hesitate to post this > patch. I'm interested in how other devs consider this evil solution. I > think the parser should parse the second field too if encountering a field > coded picture, and treat the packet as frame coded and set field_order > appropriate. I think a better API is needed to export the picture_structure correctly. With the API here, i think unspecified is better than delcaring field pictures to be frames. The field value is also what decoders would use, they have to 2 field pics arent the same as a frame picture [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB In a rich man's house there is no place to spit but his face. -- Diogenes of Sinope signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] Purely synthetic PTS and DTS...
I have video frames in a buffer in memory... and I know their frame rate (and other information like resolution, etc)... I am attempting to mux this video into an mp4... But I don't know how to set PTS/DTS appropriately. I have two questions: 1) What should I set AVStream->time_base to? 2) How do I compute PTS/DTS per frame (given only a framerate)? Thanks in advance! ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 1/2] avcodec/mpeg4videodec: Ignore multiple VOL headers
On Sun, Feb 11, 2018 at 08:01:36PM +0100, Carl Eugen Hoyos wrote: > 2018-02-09 22:24 GMT+01:00 Michael Niedermayer : > > Fixes: Ticket7005 > > > > Signed-off-by: Michael Niedermayer > > --- > > libavcodec/mpeg4videodec.c | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c > > index 756753e2fc..19210d97fe 100644 > > --- a/libavcodec/mpeg4videodec.c > > +++ b/libavcodec/mpeg4videodec.c > > @@ -2707,8 +2707,8 @@ int ff_mpeg4_decode_picture_header(Mpeg4DecContext > > *ctx, GetBitContext *gb) > > > > if (startcode >= 0x120 && startcode <= 0x12F) { > > if (vol) { > > -av_log(s->avctx, AV_LOG_ERROR, "Multiple VOL headers"); > > -return AVERROR_INVALIDDATA; > > +av_log(s->avctx, AV_LOG_WARNING, "Ignoring multiple VOL > > headers\n"); > > +continue; > > } > > Is it expected that the warning is printed as following on decoding > now (context switches between NULL and mpeg4)? It doesnt really switch, i guess the NULL is from the AVParser which does not have a codec setup and the context_to_name() uses the codec. That is this looks like a unrelated issue of the Parser in general not printing a proper name [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB The worst form of inequality is to try to make unequal things equal. -- Aristotle signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH]lavf/rtpdec: Constify several pointers
On Mon, Feb 12, 2018 at 2:05 AM, Carl Eugen Hoyos wrote: > 2018-02-11 0:32 GMT+01:00 Muhammad Faiz : >> On Sat, Feb 10, 2018 at 8:57 AM, Carl Eugen Hoyos wrote: >>> Hi! >>> >>> Attached patch fixes two warnings. >>> libavformat/rtpdec.c: In function ‘ff_rtp_handler_find_by_name’: >>> libavformat/rtpdec.c:155:20: warning: return discards ‘const’ >>> qualifier from pointer target type [-Wdiscarded-qualifiers] >>> return handler; >>> ^~~ >>> libavformat/rtpdec.c: In function ‘ff_rtp_handler_find_by_id’: >>> libavformat/rtpdec.c:168:20: warning: return discards ‘const’ >>> qualifier from pointer target type [-Wdiscarded-qualifiers] >>> return handler; >>> ^~~ >>> >>> Please comment, Carl Eugen >>> >>> From b0383afe16c62fcb0fbc7ea49168edd2f26ac0aa Mon Sep 17 00:00:00 2001 >>> From: Carl Eugen Hoyos >>> Date: Sat, 10 Feb 2018 02:54:42 +0100 >>> Subject: [PATCH] lavf/rtpdec: Constify several pointers. >>> >>> Fixes two warnings: >>> libavformat/rtpdec.c:155:20: warning: return discards 'const' qualifier >>> from pointer target type [-Wdiscarded-qualifiers] >>> libavformat/rtpdec.c:168:20: warning: return discards 'const' qualifier >>> from pointer target type [-Wdiscarded-qualifiers] >>> --- >>> libavformat/rdt.c|2 +- >>> libavformat/rdt.h|2 +- >>> libavformat/rtpdec.c |6 +++--- >>> libavformat/rtpdec.h |6 +++--- >>> libavformat/rtsp.c |8 >>> libavformat/rtsp.h |2 +- >>> 6 files changed, 13 insertions(+), 13 deletions(-) >> >> LGTM. > > Patch applied. > >> Probably, the variables should also be constified. > > Not sure which variables you mean. ff_*_dynamic_handler. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] fate/libavcodec: add codec_desc test
On Sun, Feb 11, 2018 at 6:43 AM, Michael Niedermayer wrote: > On Sat, Feb 10, 2018 at 04:37:00PM +0700, Muhammad Faiz wrote: >> Remove runtime check at codec_desc.c >> >> Signed-off-by: Muhammad Faiz >> --- >> libavcodec/Makefile | 1 + >> libavcodec/codec_desc.c | 24 --- >> libavcodec/tests/codec_desc.c | 45 >> +++ >> tests/fate/libavcodec.mak | 5 + >> 4 files changed, 51 insertions(+), 24 deletions(-) >> create mode 100644 libavcodec/tests/codec_desc.c > > LGTM Applied. Thank's. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH] avdevice/decklink_dec: Extract NTSC VANC
This changes how NTSC VANC is extracted from the buffer. In NTSC the vanc data interleved between the uyvy and not just the luma as in high definition resolutions. In my testing this allows a decklink card encoding valid NTSC closed captions to pass the caption data to the x264 encoder. Updated with rewviews from Devon Heitmueller and Marton Balint. Signed-off-by: Ray Tiley --- libavdevice/decklink_dec.cpp | 23 --- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/libavdevice/decklink_dec.cpp b/libavdevice/decklink_dec.cpp index 5c116f2..c3bb46e 100644 --- a/libavdevice/decklink_dec.cpp +++ b/libavdevice/decklink_dec.cpp @@ -149,6 +149,17 @@ static void extract_luma_from_v210(uint16_t *dst, const uint8_t *src, int width) } } +static void unpack_v210(uint16_t *dst, const uint8_t *src, int width) +{ +int i; +for (i = 0; i < width * 2 / 3; i++) { +*dst++ = src[0] + ((src[1] & 3) << 8); +*dst++ = (src[1] >> 2) + ((src[2] & 15) << 6); +*dst++ = (src[2] >> 4) + ((src[3] & 63) << 4); +src += 4; +} +} + static uint8_t calc_parity_and_line_offset(int line) { uint8_t ret = (line < 313) << 5; @@ -752,9 +763,15 @@ HRESULT decklink_input_callback::VideoInputFrameArrived( for (i = vanc_line_numbers[idx].vanc_start; i <= vanc_line_numbers[idx].vanc_end; i++) { uint8_t *buf; if (vanc->GetBufferForVerticalBlankingLine(i, (void**)&buf) == S_OK) { -uint16_t luma_vanc[MAX_WIDTH_VANC]; -extract_luma_from_v210(luma_vanc, buf, videoFrame->GetWidth()); -txt_buf = get_metadata(avctx, luma_vanc, videoFrame->GetWidth(), +uint16_t vanc[MAX_WIDTH_VANC]; +size_t vanc_size = videoFrame->GetWidth(); +if (ctx->bmd_mode == bmdModeNTSC && videoFrame->GetWidth() * 2 <= MAX_WIDTH_VANC) { +vanc_size = vanc_size * 2; +unpack_v210(vanc, buf, videoFrame->GetWidth()); +} else { +extract_luma_from_v210(vanc, buf, videoFrame->GetWidth()); +} +txt_buf = get_metadata(avctx, vanc, vanc_size, txt_buf, sizeof(txt_buf0) - (txt_buf - txt_buf0), &pkt); } if (i == vanc_line_numbers[idx].field0_vanc_end) -- 2.7.4 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 1/3] mpegvideo_parser: implement parsing of the picture structure field
On Mon, Feb 12, 2018 at 12:23 AM, Michael Niedermayer wrote: > > I think a better API is needed to export the picture_structure correctly. > I might be misunderstanding the problem at hand, but I'm not sure if a better API is required right now in the sense that if we define that: * the demuxer and/or parser should return a decode'able coding unit (whether or not it can actually be decoded depends on the state of things). In case of field coded pictures this would be one coded field, if I understand correctly. * and, if the decoder then needs two coded field pictures to generate a combed together "frame" - so be it. The new decoding/encoding APIs let you have a non-synchronized amount of input VS output. The primary part of course being that we shouldn't be ignoring the other field picture in the parser if they are in the same PES packet, for example. > With the API here, i think unspecified is better than delcaring field pictures > to be frames. The field value is also what decoders would use, they have to > 2 field pics arent the same as a frame picture > Yes, if we are not going to be separating them in the parser as two decode'able units, then we at the very least would have to parse both and set the field order flags for that packet of two field pictures correctly. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH] avcodec: remove av_codec_init_static()
Modify the behavior of init_static_data(). Signed-off-by: Muhammad Faiz --- libavcodec/allcodecs.c | 16 libavcodec/avcodec.h | 4 +++- libavcodec/libvpxdec.c | 15 ++- libavcodec/libvpxenc.c | 15 ++- libavcodec/libx264.c | 11 ++- libavcodec/libx265.c | 11 ++- 6 files changed, 55 insertions(+), 17 deletions(-) diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index 774b78ef09..02910b5594 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -757,24 +757,16 @@ extern AVCodec ff_vp9_vaapi_encoder; #include "libavcodec/codec_list.c" -static AVOnce av_codec_static_init = AV_ONCE_INIT; -static void av_codec_init_static(void) -{ -for (int i = 0; codec_list[i]; i++) { -if (codec_list[i]->init_static_data) -codec_list[i]->init_static_data((AVCodec*)codec_list[i]); -} -} - const AVCodec *av_codec_iterate(void **opaque) { uintptr_t i = (uintptr_t)*opaque; const AVCodec *c = codec_list[i]; -ff_thread_once(&av_codec_static_init, av_codec_init_static); - -if (c) +if (c) { +if (c->init_static_data) +c->init_static_data(); *opaque = (void*)(i + 1); +} return c; } diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index ad0b48a839..d89bf300fc 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -3443,8 +3443,10 @@ typedef struct AVCodec { * * This is not intended for time consuming operations as it is * run for every codec regardless of that codec being used. + * This may be called multiple times from different threads, the callee + * has responsibility for thread synchronization. */ -void (*init_static_data)(struct AVCodec *codec); +void (*init_static_data)(void); int (*init)(AVCodecContext *); int (*encode_sub)(AVCodecContext *, uint8_t *buf, int buf_size, diff --git a/libavcodec/libvpxdec.c b/libavcodec/libvpxdec.c index 04f27d3396..f2003b836b 100644 --- a/libavcodec/libvpxdec.c +++ b/libavcodec/libvpxdec.c @@ -30,6 +30,7 @@ #include "libavutil/common.h" #include "libavutil/imgutils.h" #include "libavutil/intreadwrite.h" +#include "libavutil/thread.h" #include "avcodec.h" #include "internal.h" #include "libvpx.h" @@ -299,6 +300,18 @@ static av_cold int vp9_init(AVCodecContext *avctx) return vpx_init(avctx, &vpx_codec_vp9_dx_algo, 0); } +static av_cold void vp9_init_static_once(void) +{ +extern AVCodec ff_libvpx_vp9_decoder; +ff_vp9_init_static(&ff_libvpx_vp9_decoder); +} + +static av_cold void vp9_init_static(void) +{ +static AVOnce once = AV_ONCE_INIT; +ff_thread_once(&once, vp9_init_static_once); +} + AVCodec ff_libvpx_vp9_decoder = { .name = "libvpx-vp9", .long_name = NULL_IF_CONFIG_SMALL("libvpx VP9"), @@ -309,7 +322,7 @@ AVCodec ff_libvpx_vp9_decoder = { .close = vpx_free, .decode = vpx_decode, .capabilities = AV_CODEC_CAP_AUTO_THREADS | AV_CODEC_CAP_DR1, -.init_static_data = ff_vp9_init_static, +.init_static_data = vp9_init_static, .profiles = NULL_IF_CONFIG_SMALL(ff_vp9_profiles), .wrapper_name = "libvpx", }; diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c index d0bd1e997a..086dd5defa 100644 --- a/libavcodec/libvpxenc.c +++ b/libavcodec/libvpxenc.c @@ -39,6 +39,7 @@ #include "libavutil/intreadwrite.h" #include "libavutil/mathematics.h" #include "libavutil/opt.h" +#include "libavutil/thread.h" /** * Portion of struct vpx_codec_cx_pkt from vpx_encoder.h. @@ -1209,6 +1210,18 @@ static av_cold int vp9_init(AVCodecContext *avctx) return vpx_init(avctx, vpx_codec_vp9_cx()); } +static av_cold void vp9_init_static_once(void) +{ +extern AVCodec ff_libvpx_vp9_encoder; +ff_vp9_init_static(&ff_libvpx_vp9_encoder); +} + +static av_cold void vp9_init_static(void) +{ +static AVOnce once = AV_ONCE_INIT; +ff_thread_once(&once, vp9_init_static_once); +} + static const AVClass class_vp9 = { .class_name = "libvpx-vp9 encoder", .item_name = av_default_item_name, @@ -1229,7 +1242,7 @@ AVCodec ff_libvpx_vp9_encoder = { .profiles = NULL_IF_CONFIG_SMALL(ff_vp9_profiles), .priv_class = &class_vp9, .defaults = defaults, -.init_static_data = ff_vp9_init_static, +.init_static_data = vp9_init_static, .wrapper_name = "libvpx", }; #endif /* CONFIG_LIBVPX_VP9_ENCODER */ diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c index 12379ff763..0da61a0fcd 100644 --- a/libavcodec/libx264.c +++ b/libavcodec/libx264.c @@ -26,6 +26,7 @@ #include "libavutil/pixdesc.h" #include "libavutil/stereo3d.h" #include "libavutil/intreadwrite.h" +#include "libavutil/thread.h" #include "avcodec.h" #include "internal.h" @@ -896,8 +897,10 @@ static const enum AVPixelFormat pix_fmts_8bit_rgb[] = { }; #endif -static av_cold void X264_init_static(AVCodec *codec) +static av_cold