Re: [FFmpeg-devel] [PATCH 1/2] avfilter/af_astats: Only print header lines when values are to be printed

2021-04-06 Thread Tobias Rapp

On 26.03.2021 13:58, Tobias Rapp wrote:

Avoids empty "Channel" or "Overall" header lines added to log output
when measurement is restricted to one scope using
"measure_perchannel=none" or "measure_overall=none".

Signed-off-by: Tobias Rapp 
---
  libavfilter/af_astats.c | 6 --
  1 file changed, 4 insertions(+), 2 deletions(-)

[...]


A gentle ping for both patches. I'm putting Paul on CC as he seems to be 
the author of the most recent changes.


Regards,
Tobias

___
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] libavcodec/qsvdec: use the param from decodeHeader to configure surface

2021-04-06 Thread Chen, Wenbin


> -Original Message-
> From: Xiang, Haihao 
> Sent: Tuesday, April 6, 2021 2:24 PM
> To: Chen, Wenbin ; ffmpeg-devel@ffmpeg.org
> Subject: Re: [FFmpeg-devel] [PATCH] libavcodec/qsvdec: use the param from
> decodeHeader to configure surface
> 
> On Tue, 2021-03-23 at 06:45 +, Chen, Wenbin wrote:
> > > -Original Message-
> > > From: Xiang, Haihao 
> > > Sent: Tuesday, March 23, 2021 12:10 PM
> > > To: ffmpeg-devel@ffmpeg.org
> > > Cc: Chen, Wenbin 
> > > Subject: Re: [FFmpeg-devel] [PATCH] libavcodec/qsvdec: use the param
> from
> > > decodeHeader to configure surface
> > >
> > > On Mon, 2021-03-22 at 14:31 +0800, wenbin.c...@intel.com wrote:
> > > > From: "Chen,Wenbin" 
> > > >
> > > > MSDK recognizes both yuv420p10 and yuv420p9 as MFX_FOURCC_P010,
> > >
> > > but param
> > > > are different. When decode yuv420p9 video, ffmpeg-qsv will use
> > > > yuv420p10le to configure surface which is different with param from
> > > > DecoderHeader and this will lead to error. Now change it use
> > > > param from decoderHeader to configure surface.
> > >
> > >
> > > Both yuv420p10 and yuv420p9 have 3 planes (
> > >
> https://github.com/FFmpeg/FFmpeg/blob/master/libavutil/pixdesc.c#L1359-
> > > L1406) ,
> > > but MFX_FOURCC_P010 has 2 planes only. MSDK doesn't recognizes
> > > yuv420p10 and
> > > yuv420p9 as MFX_FOURCC_P010. FFmpeg-qsv uses p010le instead of
> > > yuv420p10le to
> > > configure surface for 10bit video.
> > >
> >
> > Sorry, I didn't describe the problem well. I mean when MSDK
> decodeHeader a
> > 9bit video
> > It will return MFX_FOURCC_P010, but its frameInfo is 9bit. However
> FFmpeg-qsv
> > will use P010's parameter
> > to configure surface which will be 10bit, and if ffmpeg-qsv send 10bit
> surface
> > to decode 9bit video MSDK will report an error.
> >
> 
> So it will use yuv420p10le for a 9bit video, right? A potential issue here is
> the depth info will be lost in the pipeline, a filter after qsv decoder will
> take it as 10bit frame instead of 9bit frame.
> 
> Thanks
> Haihao
> 
> 

Yes, there is a risk of losing depth information. Function ff_qsv_map_fourcc() 
should also takes 
"FrameInfo.BitDepth" into consideration. This issue is not brought by this 
patch, we may fix it in a new patch.

Thanks
wenbin

> > >
> > > >
> > > > Signed-off-by Wenbin Chen 
> > > > ---
> > > >  libavcodec/qsvdec.c | 4 ++--
> > > >  1 file changed, 2 insertions(+), 2 deletions(-)
> > > >
> > > > diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
> > > > index 569ccd4fba..3ab48ea7a2 100644
> > > > --- a/libavcodec/qsvdec.c
> > > > +++ b/libavcodec/qsvdec.c
> > > > @@ -309,13 +309,13 @@ static int alloc_frame(AVCodecContext *avctx,
> > >
> > > QSVContext
> > > > *q, QSVFrame *frame)
> > > >  if (frame->frame->format == AV_PIX_FMT_QSV) {
> > > >  frame->surface = *(mfxFrameSurface1*)frame->frame->data[3];
> > > >  } else {
> > > > -frame->surface.Info = q->frame_info;
> > > > -
> > > >  frame->surface.Data.PitchLow = frame->frame->linesize[0];
> > > >  frame->surface.Data.Y= frame->frame->data[0];
> > > >  frame->surface.Data.UV   = frame->frame->data[1];
> > > >  }
> > > >
> > > > +frame->surface.Info = q->frame_info;
> > > > +
> > > >  if (q->frames_ctx.mids) {
> > > >  ret = ff_qsv_find_surface_idx(&q->frames_ctx, frame);
> > > >  if (ret < 0)
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH V6 4/6] lavu: add side data AV_FRAME_DATA_BOUNDING_BOXES

2021-04-06 Thread Guo, Yejun


> -Original Message-
> From: Guo, Yejun
> Sent: 2021年4月5日 17:56
> To: FFmpeg development discussions and patches 
> Subject: RE: [FFmpeg-devel] [PATCH V6 4/6] lavu: add side data
> AV_FRAME_DATA_BOUNDING_BOXES
> 
> 
> 
> > -Original Message-
> > From: ffmpeg-devel  On Behalf Of
> Nicolas
> > George
> > Sent: 2021年4月4日 18:02
> > To: FFmpeg development discussions and patches
> 
> > Subject: Re: [FFmpeg-devel] [PATCH V6 4/6] lavu: add side data
> > AV_FRAME_DATA_BOUNDING_BOXES
> >
> > Guo, Yejun (12021-04-01):
> > > > Is this allowed to be negative? Can/should this be size_t?
> > > There was a long discussion about size_t/int/uint32_t when I added
> > > struct AVRegionOfInterest in frame.h, and finally size_t is not chosen.
> >
> > Then at least unsigned.
> 
> yes, 'unsigned int' is another option. but imho, it might be better to use
> the same data type of AVFrame.width/height, they are 'int'.
> 
> >
> > > yes, we can add a version number (enum AVBBoxHeaderVersion, see below)
> > at the
> > > beginning of the struct, and the user needs to set it with
> > AV_BBOX_HEADER_CURRENT.
> > > It is not elegant, is this what we really want?
> >
> > A version number does not make the structure compatible. At best,
> > applications check the version and detect they do not support this one
> > and report an error. At worse, they do not bother to check and it causes
> > strange bugs. The version number does not help with compatibility, it
> > just makes it detectable.
> 
> My idea was to use separate code path for AVBoundingBoxHeaderV1,
> AVBoundingBoxHeaderV2, ... (not union in my previous email) according to
> the version number. And yes, it doesn't work if the user does not set or
> check the version number correctly.
> 
> >
> > To make the structure compatible, we have to ask ourselves: What happens
> > if we update it? What breaks compatibility? Once we have an answer, we
> > find a workaround.
> >
> > In this case, what happens is that the variable array must be at the
> > end, and therefore its offset changes. And we cannot have a second
> > variable array (like the name! you had to set a constant size), and we
> > cannot update the type of the array elements.
> >
> > And the solution becomes obvious: let us store the offsets in the
> > structure.
> 
> Thanks a lot for your nice explanation! thank you.
> 
> >
> > So, that would be:
> >
> > typedef struct AVBoundingBoxHeader {
> > ...
> > /**
> >  * Offset of the array of bounding boxes.
> >  */
> > size_t bboxes_offset;
> >
> > /**
> >  * Offset increment in the array of bounding boxes.
> >  */
> > size_t bboxes_step;
> > };
> >
> > Note that with that solution, we do not need the empty array, we can do
> > this:
> >
> > AVBoundingBoxHeader *ff_bounding_box_alloc(size_t nb_bbox)
> > {
> > struct {
> > AVBoundingBoxHeader header;
> > AVBoundingBox boxes[nb_bbox];
> > } *ret;
> > ret = av_mallocz(sizeof(*ret));
> > /* add error checks */
> > ret->header->bboxes_offset = (char *)&ret->boxes - (char *)ret->header;
> > ret->header->bboxes_step = sizeof(*ret->boxes);
> > }
> >
> > #define AV_BOUNDING_BOX_GET(header, idx) \
> > ((AVBoundingBox *)((char *)(header) + (header)->bboxes_offset + (idx) *
> > (header)->bboxes_step))
> 
> thanks, and I'll update the naming as what James mentioned.
> 
> >
> > You can do the same to lift the 128 limit on the name.
> 
> yes, we can now handle more variable arrays with this method.

Looks that we could not support more variable arrays without requiring special
compiler feature. See the sample code below, and I got compile error on my
ubuntu 18.04 with default compiler and default configure option.

sample code:
AVBoundingBoxHeader *
av_bbox_alloc(uint32_t nb_bboxes, size_t name_size, size_t *out_size)
{
struct {
AVBoundingBoxHeader header;
AVBoundingBox boxes[nb_bboxes];
char name[name_size];
} *ret;
...
}

compile error on ubuntu 18.04 with default setting:
error: ISO C90 forbids variable length array ‘boxes’ [-Werror=vla]
  AVBoundingBox boxes[nb_bboxes];
...

So, I might still use 'char source[128]' in AVBoundingBoxHeader, and use the
following code to meet the alignment requirement.

struct {
AVBoundingBoxHeader header;
AVBoundingBox boxes[];
} *ret;
ret = av_mallocz(sizeof(*ret) + sizeof(AVBoundingBox) * nb_bboxes);
___
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 v1 1/2] libavformat/mpegts: Extract arib_caption descriptor data into codecpar->extradata

2021-04-06 Thread zheng qian
The recognization of ARIB STD-B24 caption has been introduced in commit a03885b,
which is used as closed caption in Japanese / Brazilian Digital Television.

But whenever copying arib_caption into mpegts output, arib_caption inside the
outputted stream cannot be recgonized as a arib_caption subtitle track once 
again,
which is caused by the missing of descriptors in the PMT table.

These patches are intended to fix broken stream copying of arib_caption 
subtitle.

This patch extracts necessary fields into codecpar->extradata for future 
remuxing,
which describe the stream_identifier, the profile and other additional 
information.

Signed-off-by: zheng qian 
---
 libavformat/mpegts.c | 25 +
 1 file changed, 25 insertions(+)

diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index 6e0d9d7496..a6a534a277 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -2107,6 +2107,9 @@ int ff_parse_mpeg2_descriptor(AVFormatContext *fc, 
AVStream *st, int stream_type
 // STD-B24, fascicle 3, chapter 4 defines private_stream_1
 // for captions
 if (stream_type == STREAM_TYPE_PRIVATE_DATA) {
+if (desc_len < 3)
+return AVERROR_INVALIDDATA;
+
 // This structure is defined in STD-B10, part 1, listing 5.4 and
 // part 2, 6.2.20).
 // Listing of data_component_ids is in STD-B10, part 2, Annex J.
@@ -2145,6 +2148,28 @@ int ff_parse_mpeg2_descriptor(AVFormatContext *fc, 
AVStream *st, int stream_type
 st->codecpar->codec_id   = AV_CODEC_ID_ARIB_CAPTION;
 st->codecpar->profile= picked_profile;
 st->internal->request_probe= 0;
+
+// Store stream_identifier and payload of data_component_descriptor
+// (data_component_id & additional_arib_caption_info) as extradata.
+// data_component_descriptor is defined in ARIB STD-B10, part 2, 
6.2.20
+// These will be useful for remuxing arib_caption into mpegts 
output.
+if (!st->codecpar->extradata) {
+st->codecpar->extradata = av_mallocz(4 + 
AV_INPUT_BUFFER_PADDING_SIZE);
+if (!st->codecpar->extradata)
+return AVERROR(ENOMEM);
+
+st->codecpar->extradata_size = 4;
+
+// stream_identifier (component_tag of 
stream_identifier_descriptor)
+st->codecpar->extradata[0] = (uint8_t)(st->stream_identifier - 
1);
+
+// payload of data_component_descriptor structure
+// data_component_id
+st->codecpar->extradata[1] = (uint8_t)((data_component_id & 
0xF0) >> 8);
+st->codecpar->extradata[2] = (uint8_t)(data_component_id & 
0x0F);
+// additional_arib_caption_info, defined in ARIB STD-B24, 
fascicle 1, Part 3, 9.6.1
+st->codecpar->extradata[3] = get8(pp, desc_end);
+}
 }
 break;
 case 0xb0: /* DOVI video stream descriptor */
-- 
2.29.2

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH v1 2/2] libavformat/mpegtsenc: Write necessary descriptors into PMT for arib_caption

2021-04-06 Thread zheng qian
Stream copy for arib_caption into mpegts is not working correctly for now.

This patch utilizes the data stored in codecpar->extradata to write necessary
stream_identifier_descriptor and data_component_descriptor into PMT table
for arib_caption remuxing.

This patch fixes the copying of arib_caption. After this patch, arib_caption
inside the outputted (remuxed) mpegts stream can be recognized correctly
as an arib_caption subtitle stream.

Signed-off-by: zheng qian 
---
 libavformat/mpegtsenc.c | 16 +++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index a357f3a6aa..e26a5d3b51 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -357,6 +357,7 @@ static int get_dvb_stream_type(AVFormatContext *s, AVStream 
*st)
 break;
 case AV_CODEC_ID_DVB_SUBTITLE:
 case AV_CODEC_ID_DVB_TELETEXT:
+case AV_CODEC_ID_ARIB_CAPTION:
 stream_type = STREAM_TYPE_PRIVATE_DATA;
 break;
 case AV_CODEC_ID_SMPTE_KLV:
@@ -714,8 +715,21 @@ static int mpegts_write_pmt(AVFormatContext *s, 
MpegTSService *service)
}
 
*len_ptr = q - len_ptr - 1;
+} else if (codec_id == AV_CODEC_ID_ARIB_CAPTION) {
+if (st->codecpar->extradata && st->codecpar->extradata_size >= 
4) {
+// stream_identifier_descriptor
+*q++ = 0x52;  // descriptor_tag
+*q++ = 1; // descriptor_length
+*q++ = st->codecpar->extradata[0];  // component_tag: 
stream_identifier
+
+// data_component_descriptor
+*q++ = 0xFD;  // descriptor_tag: ARIB data coding type 
descriptor
+*q++ = 3; // descriptor_length
+memcpy(q, &st->codecpar->extradata[1], 3);  // 
data_component_id & additional_arib_caption_info
+q += 3;
+}
 }
-break;
+break;
 case AVMEDIA_TYPE_VIDEO:
 if (stream_type == STREAM_TYPE_VIDEO_DIRAC) {
 put_registration_descriptor(&q, MKTAG('d', 'r', 'a', 'c'));
-- 
2.29.2

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] web/documentation: Added my book (FFMPEG Quick Hacks) to list of FFmpeg books

2021-04-06 Thread V Subhash [FFMPEG Quick Hacks]
 > I'm talking about starting a page on the wiki and listing all books
> *there*. No patch required.

I will add the books to wiki but while the two old books are there at 
https://ffmpeg.org/documentation.html, I would like you to add the books I had 
submitted.  
___
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/utils: add helper functions to retrieve index entries from an AVStream

2021-04-06 Thread Nicolas George
James Almer (12021-04-01):
> Yet the line has to be drawn somewhere. Otherwise public headers would be
> chock full of structs and/or fields normally kept in internal headers
> because "Someone may find them useful".

You are right, the line has to be drawn somewhere. I posit that the best
place to draw the line is defined by laziness: let us make things
private by default; but if something needs to be public, then let us
make it public in the simplest possible way. We need to think ahead
about what would be a maintenance or compatibility hassle, but apart
from that, we should not spend time deciding which bit needs to be
public and which bit needs to be private. We just chose the simplest
solution.

> Please refrain from making such accusations.

I insist: the direct consequence of what you want is to complicate
things, therefore I consider it is fair to write that in this particular
instance "you want to complicate things".

But more importantly, it is not an accusation: I state it only in the
hope that it will be useful, to you and to the project.

Still in the hope to be useful, I will elaborate. I believe I have
observed a bias in your policy towards the project. Knowing that it
might just be imagination plus confirmation bias from me, I still
believe it is useful to let you know about it. It is easier to spot
biases in others than in oneself.

The bias I believe you have is to underestimate mundane complexity: the
cost of typing a few more keys (or to have to rely on advanced features
of an editor); the cost of reading longer lines of code; the cost of
remembering the order of the arguments of a function; the cost of
remembering in which half of a structure that has been split a
particular field has arrived, etc.

All this is tiny, but it is everywhere, and tiny times many, it starts
to accumulate, and it makes working on the project that less fun.

This is not an accusation, I just suggest that you think about it.

> I want to not return a volatile pointer if i can avoid it, because no
> matter how many warnings you add or how much you trust the user, it's
> an unsafe practice. But if both you and Anton consider it the less
> problematic solution, then fine, lets go with it.

I will pile up on this:

In C every function that accepts a pointer as argument or that returns a
pointer comes with caveats about the validity of the pointer.

Just a few common cases: some functions will free their arguments with
generic free(); some functions will free them with a specific handler;
some functions will keep the pointer and expect it to stay valid; some
functions will demand that you free what they return, again, with
generic or specific handlers. The list goes on and on and on.

There are no exception: when you meet a new function with pointers, you
cannot guess the hypotheses it makes about the pointers (unless it is
very similar to a function you already know, and even then you can have
bad surprises), you have to look at the doc. And if you do not, you will
get segfaults or memory leaks or memory corruption.

And every C programmer knows it. Possibly not in as many words, but what
I wrote just now will be no surprise for any C programmer skilled enough
to use the FFmpeg libraries.

The constraint "only valid until the next function call on the same
structure" is not the most common, nor the least dangerous, but it is
not exceptional at all. And in this case, it is by far both the most
simple and the most efficient solution.

Regards,

-- 
  Nicolas George


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] libavcodec/qsvdec: use the param from decodeHeader to configure surface

2021-04-06 Thread Xiang, Haihao
On Tue, 2021-04-06 at 07:54 +, Chen, Wenbin wrote:
> > -Original Message-
> > From: Xiang, Haihao 
> > Sent: Tuesday, April 6, 2021 2:24 PM
> > To: Chen, Wenbin ; ffmpeg-devel@ffmpeg.org
> > Subject: Re: [FFmpeg-devel] [PATCH] libavcodec/qsvdec: use the param from
> > decodeHeader to configure surface
> > 
> > On Tue, 2021-03-23 at 06:45 +, Chen, Wenbin wrote:
> > > > -Original Message-
> > > > From: Xiang, Haihao 
> > > > Sent: Tuesday, March 23, 2021 12:10 PM
> > > > To: ffmpeg-devel@ffmpeg.org
> > > > Cc: Chen, Wenbin 
> > > > Subject: Re: [FFmpeg-devel] [PATCH] libavcodec/qsvdec: use the param
> > 
> > from
> > > > decodeHeader to configure surface
> > > > 
> > > > On Mon, 2021-03-22 at 14:31 +0800, wenbin.c...@intel.com wrote:
> > > > > From: "Chen,Wenbin" 
> > > > > 
> > > > > MSDK recognizes both yuv420p10 and yuv420p9 as MFX_FOURCC_P010,
> > > > 
> > > > but param
> > > > > are different. When decode yuv420p9 video, ffmpeg-qsv will use
> > > > > yuv420p10le to configure surface which is different with param from
> > > > > DecoderHeader and this will lead to error. Now change it use
> > > > > param from decoderHeader to configure surface.
> > > > 
> > > > 
> > > > Both yuv420p10 and yuv420p9 have 3 planes (
> > > > 
> > 
> > https://github.com/FFmpeg/FFmpeg/blob/master/libavutil/pixdesc.c#L1359-
> > > > L1406) ,
> > > > but MFX_FOURCC_P010 has 2 planes only. MSDK doesn't recognizes
> > > > yuv420p10 and
> > > > yuv420p9 as MFX_FOURCC_P010. FFmpeg-qsv uses p010le instead of
> > > > yuv420p10le to
> > > > configure surface for 10bit video.
> > > > 
> > > 
> > > Sorry, I didn't describe the problem well. I mean when MSDK
> > 
> > decodeHeader a
> > > 9bit video
> > > It will return MFX_FOURCC_P010, but its frameInfo is 9bit. However
> > 
> > FFmpeg-qsv
> > > will use P010's parameter
> > > to configure surface which will be 10bit, and if ffmpeg-qsv send 10bit
> > 
> > surface
> > > to decode 9bit video MSDK will report an error.
> > > 
> > 
> > So it will use yuv420p10le for a 9bit video, right? A potential issue here
> > is
> > the depth info will be lost in the pipeline, a filter after qsv decoder will
> > take it as 10bit frame instead of 9bit frame.
> > 
> > Thanks
> > Haihao
> > 
> > 
> 
> Yes, there is a risk of losing depth information. Function ff_qsv_map_fourcc()
> should also takes 
> "FrameInfo.BitDepth" into consideration. This issue is not brought by this
> patch, we may fix it in a new patch.


FFmpeg has already used pixfmt for both memory layout and the used bits in a
frame. I think you should add a new pixfmt for your case, otherwise we won't
know the bit depth when handling a yuv420p10le frame in a filter if using
yuv420p10le for a 9bit video.


> 
> Thanks
> wenbin
> 
> > > > 
> > > > > 
> > > > > Signed-off-by Wenbin Chen 
> > > > > ---
> > > > >  libavcodec/qsvdec.c | 4 ++--
> > > > >  1 file changed, 2 insertions(+), 2 deletions(-)
> > > > > 
> > > > > diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
> > > > > index 569ccd4fba..3ab48ea7a2 100644
> > > > > --- a/libavcodec/qsvdec.c
> > > > > +++ b/libavcodec/qsvdec.c
> > > > > @@ -309,13 +309,13 @@ static int alloc_frame(AVCodecContext *avctx,
> > > > 
> > > > QSVContext
> > > > > *q, QSVFrame *frame)
> > > > >  if (frame->frame->format == AV_PIX_FMT_QSV) {
> > > > >  frame->surface = *(mfxFrameSurface1*)frame->frame->data[3];
> > > > >  } else {
> > > > > -frame->surface.Info = q->frame_info;
> > > > > -
> > > > >  frame->surface.Data.PitchLow = frame->frame->linesize[0];
> > > > >  frame->surface.Data.Y= frame->frame->data[0];
> > > > >  frame->surface.Data.UV   = frame->frame->data[1];
> > > > >  }
> > > > > 
> > > > > +frame->surface.Info = q->frame_info;
> > > > > +
> > > > >  if (q->frames_ctx.mids) {
> > > > >  ret = ff_qsv_find_surface_idx(&q->frames_ctx, frame);
> > > > >  if (ret < 0)
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH V6 4/6] lavu: add side data AV_FRAME_DATA_BOUNDING_BOXES

2021-04-06 Thread Nicolas George
Guo, Yejun (12021-04-06):
> compile error on ubuntu 18.04 with default setting:
> error: ISO C90 forbids variable length array ‘boxes’ [-Werror=vla]
>   AVBoundingBox boxes[nb_bboxes];

This warning is explicitly added by configure it, we do not have to keep
it if it hiders us.

If people agree with my analysis that pointers to VLA used to compute
sizes and offsets in an isolated function are not a problem, unlike
actual VLAs on the stack, then we can just remove it. I do not think we
are at risk of adding VLAs by mistake.

Regards,

-- 
  Nicolas George


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".

[FFmpeg-devel] [PATCH] mov: Prioritize aspect ratio values found in pasp atom

2021-04-06 Thread Vittorio Giovara
Here is the proposed patch to address samples like trac/7277.

This effectively reverts an 11 year old patch
(9044dd83991491309ecb76c389502e410897d7d2) but I wasn't able to identify
the file mentioned in the log.

If anyone knows where to look up the sample in issue 1539 that is not on
trac I can see if this patch affects it in one way or another, however a
lot has changed in the mov demuxer so maybe it's not strictly necessary.

I'm still unsure where to add the extra documentation; lavu/display.h seems
too generic for a mov-specific behavior.
-- 
Vittorio


0001-mov-Prioritize-aspect-ratio-values-found-in-pasp-ato.patch
Description: Binary data
___
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] avformat/utils: add helper functions to retrieve index entries from an AVStream

2021-04-06 Thread James Almer

On 4/3/2021 8:12 PM, James Almer wrote:

Signed-off-by: James Almer 
---
Now using the avformat_ prefix as Anton requested. I forgot about it when i
made v3.


Will apply soon if there are no objections.



  libavformat/avformat.h | 39 +++
  libavformat/utils.c| 27 +++
  2 files changed, 66 insertions(+)

diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 6a9b09160c..a1e87ef891 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -2767,6 +2767,45 @@ int av_find_default_stream_index(AVFormatContext *s);
   */
  int av_index_search_timestamp(AVStream *st, int64_t timestamp, int flags);
  
+/**

+ * Get the index entry count for the given AVStream.
+ *
+ * @param st stream
+ * @return the number of index entries in the stream
+ */
+int avformat_index_get_entries_count(AVStream *st);
+
+/**
+ * Get the AVIndexEntry corresponding to the given index.
+ *
+ * @param st  Stream containing the requested AVIndexEntry.
+ * @param idx The desired index.
+ * @return A pointer to the requested AVIndexEntry if it exists, NULL 
otherwise.
+ *
+ * @note The pointer returned by this function is only guaranteed to be valid
+ *   until any function that could alter the stream or the AVFormatContext
+ *   that cointains it is called.
+ */
+const AVIndexEntry *avformat_index_get_entry(AVStream *st, int idx);
+
+/**
+ * Get the AVIndexEntry corresponding to the given timestamp.
+ *
+ * @param st  Stream containing the requested AVIndexEntry.
+ * @param timestamp   Timestamp to retrieve the index entry for.
+ * @param flags   If AVSEEK_FLAG_BACKWARD then the returned entry will 
correspond
+ *to the timestamp which is <= the requested one, if 
backward
+ *is 0, then it will be >=
+ *if AVSEEK_FLAG_ANY seek to any frame, only keyframes 
otherwise.
+ * @return A pointer to the requested AVIndexEntry if it exists, NULL 
otherwise.
+ *
+ * @note The pointer returned by this function is only guaranteed to be valid
+ *   until any function that could alter the stream or the AVFormatContext
+ *   that cointains it is called.
+ */
+const AVIndexEntry *avformat_index_get_entry_from_timestamp(AVStream *st,
+int64_t 
wanted_timestamp,
+int flags);
  /**
   * Add an index entry into a sorted list. Update the entry if the list
   * already contains it.
diff --git a/libavformat/utils.c b/libavformat/utils.c
index e9bf31e38b..942d7c8390 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -2176,6 +2176,33 @@ int av_index_search_timestamp(AVStream *st, int64_t 
wanted_timestamp, int flags)
   wanted_timestamp, flags);
  }
  
+int avformat_index_get_entries_count(AVStream *st)

+{
+return st->internal->nb_index_entries;
+}
+
+const AVIndexEntry *avformat_index_get_entry(AVStream *st, int idx)
+{
+if (idx < 0 || idx >= st->internal->nb_index_entries)
+return NULL;
+
+return &st->internal->index_entries[idx];
+}
+
+const AVIndexEntry *avformat_index_get_entry_from_timestamp(AVStream *st,
+int64_t 
wanted_timestamp,
+int flags)
+{
+int idx = ff_index_search_timestamp(st->internal->index_entries,
+st->internal->nb_index_entries,
+wanted_timestamp, flags);
+
+if (idx < 0)
+return NULL;
+
+return &st->internal->index_entries[idx];
+}
+
  static int64_t ff_read_timestamp(AVFormatContext *s, int stream_index, 
int64_t *ppos, int64_t pos_limit,
   int64_t (*read_timestamp)(struct 
AVFormatContext *, int , int64_t *, int64_t ))
  {



___
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] avformat/utils: add helper functions to retrieve index entries from an AVStream

2021-04-06 Thread Andreas Rheinhardt
James Almer:
> On 4/3/2021 8:12 PM, James Almer wrote:
>> Signed-off-by: James Almer 
>> ---
>> Now using the avformat_ prefix as Anton requested. I forgot about it
>> when i
>> made v3.
> 
> Will apply soon if there are no objections.
> 

I wonder whether the AVStream *st should be const; together with a
guarantee that calling these functions does not invalidate entries that
have been returned earlier.

>>
>>   libavformat/avformat.h | 39 +++
>>   libavformat/utils.c    | 27 +++
>>   2 files changed, 66 insertions(+)
>>
>> diff --git a/libavformat/avformat.h b/libavformat/avformat.h
>> index 6a9b09160c..a1e87ef891 100644
>> --- a/libavformat/avformat.h
>> +++ b/libavformat/avformat.h
>> @@ -2767,6 +2767,45 @@ int
>> av_find_default_stream_index(AVFormatContext *s);
>>    */
>>   int av_index_search_timestamp(AVStream *st, int64_t timestamp, int
>> flags);
>>   +/**
>> + * Get the index entry count for the given AVStream.
>> + *
>> + * @param st stream
>> + * @return the number of index entries in the stream
>> + */
>> +int avformat_index_get_entries_count(AVStream *st);

An int? Not something unsigned?

>> +
>> +/**
>> + * Get the AVIndexEntry corresponding to the given index.
>> + *
>> + * @param st  Stream containing the requested AVIndexEntry.
>> + * @param idx The desired index.
>> + * @return A pointer to the requested AVIndexEntry if it exists, NULL
>> otherwise.
>> + *
>> + * @note The pointer returned by this function is only guaranteed to
>> be valid
>> + *   until any function that could alter the stream or the
>> AVFormatContext
>> + *   that cointains it is called.
^
typo
>> + */
>> +const AVIndexEntry *avformat_index_get_entry(AVStream *st, int idx);
>> +
>> +/**
>> + * Get the AVIndexEntry corresponding to the given timestamp.
>> + *
>> + * @param st  Stream containing the requested AVIndexEntry.
>> + * @param timestamp   Timestamp to retrieve the index entry for.
>> + * @param flags   If AVSEEK_FLAG_BACKWARD then the returned entry
>> will correspond
>> + *    to the timestamp which is <= the requested one,
>> if backward
>> + *    is 0, then it will be >=
>> + *    if AVSEEK_FLAG_ANY seek to any frame, only
>> keyframes otherwise.
>> + * @return A pointer to the requested AVIndexEntry if it exists, NULL
>> otherwise.
>> + *
>> + * @note The pointer returned by this function is only guaranteed to
>> be valid
>> + *   until any function that could alter the stream or the
>> AVFormatContext
>> + *   that cointains it is called.
^
same typo
>> + */
>> +const AVIndexEntry *avformat_index_get_entry_from_timestamp(AVStream
>> *st,
>> +    int64_t
>> wanted_timestamp,
>> +    int flags);
>>   /**
>>    * Add an index entry into a sorted list. Update the entry if the list
>>    * already contains it.
>> diff --git a/libavformat/utils.c b/libavformat/utils.c
>> index e9bf31e38b..942d7c8390 100644
>> --- a/libavformat/utils.c
>> +++ b/libavformat/utils.c
>> @@ -2176,6 +2176,33 @@ int av_index_search_timestamp(AVStream *st,
>> int64_t wanted_timestamp, int flags)
>>    wanted_timestamp, flags);
>>   }
>>   +int avformat_index_get_entries_count(AVStream *st)
>> +{
>> +    return st->internal->nb_index_entries;
>> +}
>> +
>> +const AVIndexEntry *avformat_index_get_entry(AVStream *st, int idx)
>> +{
>> +    if (idx < 0 || idx >= st->internal->nb_index_entries)
>> +    return NULL;
>> +
>> +    return &st->internal->index_entries[idx];
>> +}
>> +
>> +const AVIndexEntry *avformat_index_get_entry_from_timestamp(AVStream
>> *st,
>> +    int64_t
>> wanted_timestamp,
>> +    int flags)
>> +{
>> +    int idx = ff_index_search_timestamp(st->internal->index_entries,
>> +    st->internal->nb_index_entries,
>> +    wanted_timestamp, flags);
>> +
>> +    if (idx < 0)
>> +    return NULL;
>> +
>> +    return &st->internal->index_entries[idx];
>> +}
>> +
>>   static int64_t ff_read_timestamp(AVFormatContext *s, int
>> stream_index, int64_t *ppos, int64_t pos_limit,
>>    int64_t (*read_timestamp)(struct
>> AVFormatContext *, int , int64_t *, int64_t ))
>>   {
>>
> 
> ___
> 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
htt

Re: [FFmpeg-devel] [PATCH v4] avformat/utils: add helper functions to retrieve index entries from an AVStream

2021-04-06 Thread James Almer

On 4/6/2021 3:46 PM, Andreas Rheinhardt wrote:

James Almer:

On 4/3/2021 8:12 PM, James Almer wrote:

Signed-off-by: James Almer 
---
Now using the avformat_ prefix as Anton requested. I forgot about it
when i
made v3.


Will apply soon if there are no objections.



I wonder whether the AVStream *st should be const; together with a
guarantee that calling these functions does not invalidate entries that
have been returned earlier.


Sure, will make it const.





   libavformat/avformat.h | 39 +++
   libavformat/utils.c    | 27 +++
   2 files changed, 66 insertions(+)

diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 6a9b09160c..a1e87ef891 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -2767,6 +2767,45 @@ int
av_find_default_stream_index(AVFormatContext *s);
    */
   int av_index_search_timestamp(AVStream *st, int64_t timestamp, int
flags);
   +/**
+ * Get the index entry count for the given AVStream.
+ *
+ * @param st stream
+ * @return the number of index entries in the stream
+ */
+int avformat_index_get_entries_count(AVStream *st);


An int? Not something unsigned?


st->internal->nb_index_entries is an int, and 
av_index_search_timestamp() returns an int, too, so I'm inclined to 
leave it as is.





+
+/**
+ * Get the AVIndexEntry corresponding to the given index.
+ *
+ * @param st  Stream containing the requested AVIndexEntry.
+ * @param idx The desired index.
+ * @return A pointer to the requested AVIndexEntry if it exists, NULL
otherwise.
+ *
+ * @note The pointer returned by this function is only guaranteed to
be valid
+ *   until any function that could alter the stream or the
AVFormatContext
+ *   that cointains it is called.

 ^
 typo

+ */
+const AVIndexEntry *avformat_index_get_entry(AVStream *st, int idx);
+
+/**
+ * Get the AVIndexEntry corresponding to the given timestamp.
+ *
+ * @param st  Stream containing the requested AVIndexEntry.
+ * @param timestamp   Timestamp to retrieve the index entry for.
+ * @param flags   If AVSEEK_FLAG_BACKWARD then the returned entry
will correspond
+ *    to the timestamp which is <= the requested one,
if backward
+ *    is 0, then it will be >=
+ *    if AVSEEK_FLAG_ANY seek to any frame, only
keyframes otherwise.
+ * @return A pointer to the requested AVIndexEntry if it exists, NULL
otherwise.
+ *
+ * @note The pointer returned by this function is only guaranteed to
be valid
+ *   until any function that could alter the stream or the
AVFormatContext
+ *   that cointains it is called.

 ^
 same typo


Both fixed locally.


+ */
+const AVIndexEntry *avformat_index_get_entry_from_timestamp(AVStream
*st,
+    int64_t
wanted_timestamp,
+    int flags);
   /**
    * Add an index entry into a sorted list. Update the entry if the list
    * already contains it.
diff --git a/libavformat/utils.c b/libavformat/utils.c
index e9bf31e38b..942d7c8390 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -2176,6 +2176,33 @@ int av_index_search_timestamp(AVStream *st,
int64_t wanted_timestamp, int flags)
    wanted_timestamp, flags);
   }
   +int avformat_index_get_entries_count(AVStream *st)
+{
+    return st->internal->nb_index_entries;
+}
+
+const AVIndexEntry *avformat_index_get_entry(AVStream *st, int idx)
+{
+    if (idx < 0 || idx >= st->internal->nb_index_entries)
+    return NULL;
+
+    return &st->internal->index_entries[idx];
+}
+
+const AVIndexEntry *avformat_index_get_entry_from_timestamp(AVStream
*st,
+    int64_t
wanted_timestamp,
+    int flags)
+{
+    int idx = ff_index_search_timestamp(st->internal->index_entries,
+    st->internal->nb_index_entries,
+    wanted_timestamp, flags);
+
+    if (idx < 0)
+    return NULL;
+
+    return &st->internal->index_entries[idx];
+}
+
   static int64_t ff_read_timestamp(AVFormatContext *s, int
stream_index, int64_t *ppos, int64_t pos_limit,
    int64_t (*read_timestamp)(struct
AVFormatContext *, int , int64_t *, int64_t ))
   {



___
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
ffmpe

Re: [FFmpeg-devel] [PATCH] mov: Prioritize aspect ratio values found in pasp atom

2021-04-06 Thread Vittorio Giovara
On Tue, Apr 6, 2021 at 6:51 PM Vittorio Giovara 
wrote:

> Here is the proposed patch to address samples like trac/7277.
>
> This effectively reverts an 11 year old patch
> (9044dd83991491309ecb76c389502e410897d7d2) but I wasn't able to identify
> the file mentioned in the log.
>
> If anyone knows where to look up the sample in issue 1539 that is not on
> trac I can see if this patch affects it in one way or another, however a
> lot has changed in the mov demuxer so maybe it's not strictly necessary.
>

Carl kindly pointed me to the sample, and I can confirm my patch does
affect how the video looks: without my patch the sample is shown at a 16:9
AR (which I assume was the original fix), with my patch the sample uses an
AR of 1:1 and it is therefore square. However I tried with a recent
Quicktime, and it displays the sample using the square aspect ratio.

What is the preferred course of action? I see three options
 - leave the code as is, no action
 - apply my patch, fixing 7277, but breaking 1539, assuming QT is doing the
right thing
 - add a demuxer option that optionally disables pasp parsing (is it even
worth it?)

Let me know your thoughts
-- 
Vittorio
___
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 10/19] avcodec/mpegvideo_enc: Remove redundant time_base check

2021-04-06 Thread Andreas Rheinhardt
This check is dead as ff_encode_preinit() has an even stricter check.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/mpegvideo_enc.c | 5 -
 1 file changed, 5 deletions(-)

diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index d5dd69b88f..2a0fd60cbc 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -672,11 +672,6 @@ FF_ENABLE_DEPRECATION_WARNINGS
 return AVERROR_PATCHWELCOME;
 }
 
-if (!avctx->time_base.den || !avctx->time_base.num) {
-av_log(avctx, AV_LOG_ERROR, "framerate not set\n");
-return AVERROR(EINVAL);
-}
-
 #if FF_API_PRIVATE_OPT
 FF_DISABLE_DEPRECATION_WARNINGS
 if (avctx->b_frame_strategy)
-- 
2.27.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 12/19] avcodec/mpegvideo_enc: Don't segfault on unorthodox mpeg_quant

2021-04-06 Thread Andreas Rheinhardt
The (deprecated) field AVCodecContext.mpeg_quant has no range
restriction; MpegEncContext.mpeg_quant is restricted to 0..1.
If the former is set, the latter is overwritten with it without
checking the range. This can trigger an av_assert2() with the MPEG-4
encoder when writing said field.

Fix this by just setting MpegEncContext.mpeg_quant to 1 if
AVCodecContext.mpeg_quant is set.

Signed-off-by: Andreas Rheinhardt 
---
This can not be triggered if one only sets options via the dictionary in
avcodec_open2(); one needs to set it directly in the AVCodecContext or
use the private class of AVCodecContext.

 libavcodec/mpegvideo_enc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index d1f2460409..0a1d0db86d 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -564,7 +564,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
 #if FF_API_PRIVATE_OPT
 FF_DISABLE_DEPRECATION_WARNINGS
 if (avctx->mpeg_quant)
-s->mpeg_quant = avctx->mpeg_quant;
+s->mpeg_quant = 1;
 FF_ENABLE_DEPRECATION_WARNINGS
 #endif
 
-- 
2.27.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 13/19] avcodec/mpeg12enc: Perform size/level/profile checks earlier

2021-04-06 Thread Andreas Rheinhardt
This has the advantage that one does not waste some allocations
if one errors out because of these checks.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/mpeg12enc.c | 44 +-
 1 file changed, 22 insertions(+), 22 deletions(-)

diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c
index b7d3d1c6b0..8dcc04d341 100644
--- a/libavcodec/mpeg12enc.c
+++ b/libavcodec/mpeg12enc.c
@@ -152,19 +152,16 @@ static av_cold int encode_init(AVCodecContext *avctx)
max_size, max_size);
 return AVERROR(EINVAL);
 }
+if ((avctx->width & 0xFFF) == 0 && (avctx->height & 0xFFF) == 1) {
+av_log(avctx, AV_LOG_ERROR, "Width / Height is invalid for MPEG2\n");
+return AVERROR(EINVAL);
+}
 
-if ((ret = ff_mpv_encode_init(avctx)) < 0)
-return ret;
-
-if (find_frame_rate_index(s) < 0) {
-if (s->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL) {
-av_log(avctx, AV_LOG_ERROR, "MPEG-1/2 does not support %d/%d 
fps\n",
-   avctx->time_base.den, avctx->time_base.num);
+if (avctx->strict_std_compliance > FF_COMPLIANCE_UNOFFICIAL) {
+if ((avctx->width & 0xFFF) == 0 || (avctx->height & 0xFFF) == 0) {
+av_log(avctx, AV_LOG_ERROR, "Width or Height are not allowed to be 
multiples of 4096\n"
+"add '-strict %d' if you want to use 
them anyway.\n", FF_COMPLIANCE_UNOFFICIAL);
 return AVERROR(EINVAL);
-} else {
-av_log(avctx, AV_LOG_INFO,
-   "MPEG-1/2 does not support %d/%d fps, there may be AV sync 
issues\n",
-   avctx->time_base.den, avctx->time_base.num);
 }
 }
 
@@ -174,9 +171,9 @@ static av_cold int encode_init(AVCodecContext *avctx)
 return AVERROR(EINVAL);
 }
 /* Main or 4:2:2 */
-avctx->profile = s->chroma_format == CHROMA_420 ? 
FF_PROFILE_MPEG2_MAIN : FF_PROFILE_MPEG2_422;
+avctx->profile = avctx->pix_fmt == AV_PIX_FMT_YUV420P ? 
FF_PROFILE_MPEG2_MAIN
+  : 
FF_PROFILE_MPEG2_422;
 }
-
 if (avctx->level == FF_LEVEL_UNKNOWN) {
 if (avctx->profile == FF_PROFILE_MPEG2_422) {   /* 4:2:2 */
 if (avctx->width <= 720 && avctx->height <= 608)
@@ -184,7 +181,8 @@ static av_cold int encode_init(AVCodecContext *avctx)
 else
 avctx->level = 2;   /* High */
 } else {
-if (avctx->profile != FF_PROFILE_MPEG2_HIGH && s->chroma_format != 
CHROMA_420) {
+if (avctx->profile != FF_PROFILE_MPEG2_HIGH &&
+avctx->pix_fmt != AV_PIX_FMT_YUV420P) {
 av_log(avctx, AV_LOG_ERROR,
"Only High(1) and 4:2:2(0) profiles support 4:2:2 color 
sampling\n");
 return AVERROR(EINVAL);
@@ -198,16 +196,18 @@ static av_cold int encode_init(AVCodecContext *avctx)
 }
 }
 
-if ((avctx->width & 0xFFF) == 0 && (avctx->height & 0xFFF) == 1) {
-av_log(avctx, AV_LOG_ERROR, "Width / Height is invalid for MPEG2\n");
-return AVERROR(EINVAL);
-}
+if ((ret = ff_mpv_encode_init(avctx)) < 0)
+return ret;
 
-if (s->strict_std_compliance > FF_COMPLIANCE_UNOFFICIAL) {
-if ((avctx->width & 0xFFF) == 0 || (avctx->height & 0xFFF) == 0) {
-av_log(avctx, AV_LOG_ERROR, "Width or Height are not allowed to be 
multiples of 4096\n"
-"add '-strict %d' if you want to use 
them anyway.\n", FF_COMPLIANCE_UNOFFICIAL);
+if (find_frame_rate_index(s) < 0) {
+if (s->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL) {
+av_log(avctx, AV_LOG_ERROR, "MPEG-1/2 does not support %d/%d 
fps\n",
+   avctx->time_base.den, avctx->time_base.num);
 return AVERROR(EINVAL);
+} else {
+av_log(avctx, AV_LOG_INFO,
+   "MPEG-1/2 does not support %d/%d fps, there may be AV sync 
issues\n",
+   avctx->time_base.den, avctx->time_base.num);
 }
 }
 
-- 
2.27.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 14/19] avcodec/mpegvideo_enc: Combine identical checks

2021-04-06 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/mpegvideo_enc.c | 12 +++-
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 0a1d0db86d..e5411f0393 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -527,10 +527,11 @@ FF_ENABLE_DEPRECATION_WARNINGS
 return AVERROR(EINVAL);
 }
 if ((s->codec_id == AV_CODEC_ID_H263  ||
- s->codec_id == AV_CODEC_ID_H263P) &&
+ s->codec_id == AV_CODEC_ID_H263P ||
+ s->codec_id == AV_CODEC_ID_RV20) &&
 ((avctx->width &3) ||
  (avctx->height&3) )) {
-av_log(avctx, AV_LOG_ERROR, "w/h must be a multiple of 4\n");
+av_log(avctx, AV_LOG_ERROR, "width and height must be a multiple of 
4\n");
 return AVERROR(EINVAL);
 }
 
@@ -541,13 +542,6 @@ FF_ENABLE_DEPRECATION_WARNINGS
 return AVERROR(EINVAL);
 }
 
-if (s->codec_id == AV_CODEC_ID_RV20 &&
-(avctx->width &3 ||
- avctx->height&3 )) {
-av_log(avctx, AV_LOG_ERROR, "width and height must be a multiple of 
4\n");
-return AVERROR(EINVAL);
-}
-
 if ((s->codec_id == AV_CODEC_ID_WMV1 ||
  s->codec_id == AV_CODEC_ID_WMV2) &&
  avctx->width & 1) {
-- 
2.27.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 15/19] avcodec/mpegvideo: Deprecate mpeg_quant option for codecs != MPEG-4

2021-04-06 Thread Andreas Rheinhardt
mpeg_quant may only be set for MPEG-4 and MPEG-2, yet for the latter
it is no option as the code acts as if it were always set.
So deprecate the option for all codecs for which it makes no sense.

Furthermore, given that the code already errors out if the option is set
for a codec that doesn't support it we can restrict the range of
the option for all these codecs without breaking something. This means
that the checks for whether mpeg_quant is set for these codecs can be
removed as soon as AVCodecContext.mpeg_quant is removed.

Signed-off-by: Andreas Rheinhardt 
---
If one sets mpeg_quant to 1 for MPEG-2 and to -1 for MPEG-1 one can
simplify some checks in mpegvideo_enc. Will send a patch for this later.

 libavcodec/mjpegenc.c  |  3 +++
 libavcodec/mpeg12enc.c |  7 +++
 libavcodec/mpeg4videoenc.c |  2 ++
 libavcodec/mpegvideo.h |  6 +-
 libavcodec/mpegvideo_enc.c | 12 ++--
 libavcodec/version.h   |  5 -
 6 files changed, 31 insertions(+), 4 deletions(-)

diff --git a/libavcodec/mjpegenc.c b/libavcodec/mjpegenc.c
index 3cff50abdb..6c261a1397 100644
--- a/libavcodec/mjpegenc.c
+++ b/libavcodec/mjpegenc.c
@@ -593,6 +593,9 @@ FF_MPV_COMMON_OPTS
 { "huffman", "Huffman table strategy", OFFSET(huffman), AV_OPT_TYPE_INT, { 
.i64 = HUFFMAN_TABLE_OPTIMAL }, 0, NB_HUFFMAN_TABLE_OPTION - 1, VE, "huffman" },
 { "default", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = HUFFMAN_TABLE_DEFAULT }, 
INT_MIN, INT_MAX, VE, "huffman" },
 { "optimal", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = HUFFMAN_TABLE_OPTIMAL }, 
INT_MIN, INT_MAX, VE, "huffman" },
+#if FF_API_MPEGVIDEO_OPTS
+FF_MPV_DEPRECATED_MPEG_QUANT_OPT
+#endif
 { NULL},
 };
 
diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c
index 8dcc04d341..99c79a4232 100644
--- a/libavcodec/mpeg12enc.c
+++ b/libavcodec/mpeg12enc.c
@@ -1152,6 +1152,9 @@ av_cold void ff_mpeg1_encode_init(MpegEncContext *s)
 static const AVOption mpeg1_options[] = {
 COMMON_OPTS
 FF_MPV_COMMON_OPTS
+#if FF_API_MPEGVIDEO_OPTS
+FF_MPV_DEPRECATED_MPEG_QUANT_OPT
+#endif
 { NULL },
 };
 
@@ -1179,6 +1182,10 @@ static const AVOption mpeg2_options[] = {
 { LEVEL("low", 10) },
 #undef LEVEL
 FF_MPV_COMMON_OPTS
+#if FF_API_MPEGVIDEO_OPTS
+{ "mpeg_quant",   "Deprecated, does nothing", OFFSET(mpeg_quant),
+  AV_OPT_TYPE_INT, {.i64 = 1 }, 0, 1, VE | AV_OPT_FLAG_DEPRECATED },
+#endif
 FF_MPEG2_PROFILE_OPTS
 { NULL },
 };
diff --git a/libavcodec/mpeg4videoenc.c b/libavcodec/mpeg4videoenc.c
index 2bf65305ad..e2792e1161 100644
--- a/libavcodec/mpeg4videoenc.c
+++ b/libavcodec/mpeg4videoenc.c
@@ -1375,6 +1375,8 @@ void ff_mpeg4_encode_video_packet_header(MpegEncContext 
*s)
 static const AVOption options[] = {
 { "data_partitioning", "Use data partitioning.",  
OFFSET(data_partitioning), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },
 { "alternate_scan","Enable alternate scantable.", 
OFFSET(alternate_scan),AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },
+{ "mpeg_quant","Use MPEG quantizers instead of H.263",
+  OFFSET(mpeg_quant), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 1, VE },
 FF_MPV_COMMON_OPTS
 FF_MPEG4_PROFILE_OPTS
 { NULL },
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index 5a99c19656..e83b4ab211 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -672,7 +672,6 @@ FF_MPV_OPT_CMP_FUNC, \
 {"skip_cmp", "Frame skip compare function", 
FF_MPV_OFFSET(frame_skip_cmp), AV_OPT_TYPE_INT, {.i64 = FF_CMP_DCTMAX }, 
INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "cmp_func" }, \
 {"sc_threshold", "Scene change threshold",  
FF_MPV_OFFSET(scenechange_threshold), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, 
INT_MAX, FF_MPV_OPT_FLAGS }, \
 {"noise_reduction", "Noise reduction",  
FF_MPV_OFFSET(noise_reduction), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, 
FF_MPV_OPT_FLAGS }, \
-{"mpeg_quant", "Use MPEG quantizers instead of H.263",  
FF_MPV_OFFSET(mpeg_quant), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 1, FF_MPV_OPT_FLAGS 
}, \
 {"ps", "RTP payload size in bytes", 
FF_MPV_OFFSET(rtp_payload_size), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, 
INT_MAX, FF_MPV_OPT_FLAGS }, \
 {"mepc", "Motion estimation bitrate penalty compensation (1.0 = 256)", 
FF_MPV_OFFSET(me_penalty_compensation), AV_OPT_TYPE_INT, {.i64 = 256 }, 
INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \
 {"mepre", "pre motion estimation", FF_MPV_OFFSET(me_pre), AV_OPT_TYPE_INT, 
{.i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \
@@ -680,6 +679,11 @@ FF_MPV_OPT_CMP_FUNC, \
 {"a53cc", "Use A53 Closed Captions (if available)", FF_MPV_OFFSET(a53_cc), 
AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, 1, FF_MPV_OPT_FLAGS }, \
 FF_MPV_RC_STRATEGY_OPTS
 
+#if FF_API_MPEGVIDEO_OPTS
+#define FF_MPV_DEPRECATED_MPEG_QUANT_OPT \
+{ "mpeg_quant", "Deprecated, does nothing", FF_MPV_OFFSET(mpeg_quant), 
AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 0, FF_MPV_OPT_FLAGS | AV_

[FFmpeg-devel] [PATCH 18/19] avcodec/mpegvideo: Deprecate bframe opts for encoders not supporting them

2021-04-06 Thread Andreas Rheinhardt
MPEG-1/2/4 are the only mpegvideo based encoders that support bframes;
yet even the encoders not supporting bframes have options that only make
sense for an encoder that supports bframes; setting any of these options
for such an encoder has no impact on the encoded outcome (but setting
b_strategy to two slows down encoding considerably). So deprecate these
options.

Signed-off-by: Andreas Rheinhardt 
---
It seems to me that MJPEG/AMV does not use the motion estimation code at
all (or rather, the options don't affect the output). If so, these
options should be deprecated/removed as well. Will look into this.

 libavcodec/mjpegenc.c  |  1 +
 libavcodec/mpeg12enc.c |  1 +
 libavcodec/mpeg4videoenc.c |  1 +
 libavcodec/mpegvideo.h | 12 +---
 libavcodec/mpegvideo_enc.c |  3 +++
 5 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/libavcodec/mjpegenc.c b/libavcodec/mjpegenc.c
index 792169d6bb..b355f97f14 100644
--- a/libavcodec/mjpegenc.c
+++ b/libavcodec/mjpegenc.c
@@ -597,6 +597,7 @@ FF_MPV_COMMON_OPTS
 #if FF_API_MPEGVIDEO_OPTS
 FF_MPV_DEPRECATED_MPEG_QUANT_OPT
 FF_MPV_DEPRECATED_A53_CC_OPT
+FF_MPV_DEPRECATED_BFRAME_OPTS
 #endif
 { NULL},
 };
diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c
index 0b88408046..dccb11b222 100644
--- a/libavcodec/mpeg12enc.c
+++ b/libavcodec/mpeg12enc.c
@@ -1148,6 +1148,7 @@ av_cold void ff_mpeg1_encode_init(MpegEncContext *s)
   OFFSET(scan_offset), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE }, 
\
 { "timecode_frame_start", "GOP timecode frame start number, in 
non-drop-frame format", \
   OFFSET(timecode_frame_start), AV_OPT_TYPE_INT64, {.i64 = -1 }, -1, 
INT64_MAX, VE}, \
+FF_MPV_COMMON_BFRAME_OPTS
 
 static const AVOption mpeg1_options[] = {
 COMMON_OPTS
diff --git a/libavcodec/mpeg4videoenc.c b/libavcodec/mpeg4videoenc.c
index f97c506d13..7145bfe8ce 100644
--- a/libavcodec/mpeg4videoenc.c
+++ b/libavcodec/mpeg4videoenc.c
@@ -1377,6 +1377,7 @@ static const AVOption options[] = {
 { "alternate_scan","Enable alternate scantable.", 
OFFSET(alternate_scan),AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },
 { "mpeg_quant","Use MPEG quantizers instead of H.263",
   OFFSET(mpeg_quant), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 1, VE },
+FF_MPV_COMMON_BFRAME_OPTS
 FF_MPV_COMMON_OPTS
 #if FF_API_MPEGVIDEO_OPTS
 FF_MPV_DEPRECATED_A53_CC_OPT
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index 9a6ad75166..30dcf99188 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -662,9 +662,6 @@ FF_MPV_OPT_CMP_FUNC, \
 { "zero", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_ME_ZERO }, 0, 0, 
FF_MPV_OPT_FLAGS, "motion_est" }, \
 { "epzs", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_ME_EPZS }, 0, 0, 
FF_MPV_OPT_FLAGS, "motion_est" }, \
 { "xone", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_ME_XONE }, 0, 0, 
FF_MPV_OPT_FLAGS, "motion_est" }, \
-{"b_strategy", "Strategy to choose between I/P/B-frames",   
FF_MPV_OFFSET(b_frame_strategy), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 2, 
FF_MPV_OPT_FLAGS }, \
-{"b_sensitivity", "Adjust sensitivity of b_frame_strategy 1",   
FF_MPV_OFFSET(b_sensitivity), AV_OPT_TYPE_INT, {.i64 = 40 }, 1, INT_MAX, 
FF_MPV_OPT_FLAGS }, \
-{"brd_scale", "Downscale frames for dynamic B-frame decision",  
FF_MPV_OFFSET(brd_scale), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 3, FF_MPV_OPT_FLAGS 
}, \
 {"skip_threshold", "Frame skip threshold",  
FF_MPV_OFFSET(frame_skip_threshold), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, 
INT_MAX, FF_MPV_OPT_FLAGS }, \
 {"skip_factor", "Frame skip factor",
FF_MPV_OFFSET(frame_skip_factor), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, 
INT_MAX, FF_MPV_OPT_FLAGS }, \
 {"skip_exp", "Frame skip exponent", 
FF_MPV_OFFSET(frame_skip_exp), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, 
FF_MPV_OPT_FLAGS }, \
@@ -677,6 +674,11 @@ FF_MPV_OPT_CMP_FUNC, \
 {"intra_penalty", "Penalty for intra blocks in block decision", 
FF_MPV_OFFSET(intra_penalty), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, INT_MAX/2, 
FF_MPV_OPT_FLAGS }, \
 FF_MPV_RC_STRATEGY_OPTS
 
+#define FF_MPV_COMMON_BFRAME_OPTS \
+{"b_strategy", "Strategy to choose between I/P/B-frames",  
FF_MPV_OFFSET(b_frame_strategy), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 2, 
FF_MPV_OPT_FLAGS }, \
+{"b_sensitivity", "Adjust sensitivity of b_frame_strategy 1",  
FF_MPV_OFFSET(b_sensitivity), AV_OPT_TYPE_INT, {.i64 = 40 }, 1, INT_MAX, 
FF_MPV_OPT_FLAGS }, \
+{"brd_scale", "Downscale frames for dynamic B-frame decision", 
FF_MPV_OFFSET(brd_scale), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 3, FF_MPV_OPT_FLAGS 
},
+
 #if FF_API_MPEGVIDEO_OPTS
 #define FF_MPV_DEPRECATED_MPEG_QUANT_OPT \
 { "mpeg_quant", "Deprecated, does nothing", FF_MPV_OFFSET(mpeg_quant), 
AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 0, FF_MPV_OPT_FLAGS | AV_OPT_FLAG_DEPRECATED },
@@ -684,6 +686,10 @@ FF_MPV_RC_STRATEGY_OPTS
 { "a53cc",  "Deprecated, does nothing", FF_MPV_OFFSET(a53_c

[FFmpeg-devel] [PATCH 16/19] avcodec/mpegvideo: Deprecate a53cc option for encoders != MPEG-2

2021-04-06 Thread Andreas Rheinhardt
The MPEG-2 encoder is the only mpegvideo-based encoder that supports
embedding a53 side data.

Signed-off-by: Andreas Rheinhardt 
---
I am surprised that no one seems to have noticed this when this option
has been added.

 libavcodec/mjpegenc.c  | 1 +
 libavcodec/mpeg12enc.c | 2 ++
 libavcodec/mpeg4videoenc.c | 3 +++
 libavcodec/mpegvideo.h | 3 ++-
 libavcodec/mpegvideo_enc.c | 3 +++
 5 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/libavcodec/mjpegenc.c b/libavcodec/mjpegenc.c
index 6c261a1397..86a18ec6a9 100644
--- a/libavcodec/mjpegenc.c
+++ b/libavcodec/mjpegenc.c
@@ -595,6 +595,7 @@ FF_MPV_COMMON_OPTS
 { "optimal", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = HUFFMAN_TABLE_OPTIMAL }, 
INT_MIN, INT_MAX, VE, "huffman" },
 #if FF_API_MPEGVIDEO_OPTS
 FF_MPV_DEPRECATED_MPEG_QUANT_OPT
+FF_MPV_DEPRECATED_A53_CC_OPT
 #endif
 { NULL},
 };
diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c
index 99c79a4232..5b8ccf3ce1 100644
--- a/libavcodec/mpeg12enc.c
+++ b/libavcodec/mpeg12enc.c
@@ -1154,6 +1154,7 @@ static const AVOption mpeg1_options[] = {
 FF_MPV_COMMON_OPTS
 #if FF_API_MPEGVIDEO_OPTS
 FF_MPV_DEPRECATED_MPEG_QUANT_OPT
+FF_MPV_DEPRECATED_A53_CC_OPT
 #endif
 { NULL },
 };
@@ -1164,6 +1165,7 @@ static const AVOption mpeg2_options[] = {
   OFFSET(intra_vlc_format),AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },
 { "non_linear_quant", "Use nonlinear quantizer.",OFFSET(q_scale_type), 
  AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },
 { "alternate_scan",   "Enable alternate scantable.", 
OFFSET(alternate_scan), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },
+{ "a53cc", "Use A53 Closed Captions (if available)", OFFSET(a53_cc),   
  AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, VE },
 { "seq_disp_ext", "Write sequence_display_extension blocks.", 
OFFSET(seq_disp_ext), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1, VE, "seq_disp_ext" 
},
 { "auto",   NULL, 0, AV_OPT_TYPE_CONST,  {.i64 = -1},  0, 0, VE, 
"seq_disp_ext" },
 { "never",  NULL, 0, AV_OPT_TYPE_CONST,  {.i64 = 0 },  0, 0, VE, 
"seq_disp_ext" },
diff --git a/libavcodec/mpeg4videoenc.c b/libavcodec/mpeg4videoenc.c
index e2792e1161..384710cf60 100644
--- a/libavcodec/mpeg4videoenc.c
+++ b/libavcodec/mpeg4videoenc.c
@@ -1378,6 +1378,9 @@ static const AVOption options[] = {
 { "mpeg_quant","Use MPEG quantizers instead of H.263",
   OFFSET(mpeg_quant), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 1, VE },
 FF_MPV_COMMON_OPTS
+#if FF_API_MPEGVIDEO_OPTS
+FF_MPV_DEPRECATED_A53_CC_OPT
+#endif
 FF_MPEG4_PROFILE_OPTS
 { NULL },
 };
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index e83b4ab211..508ae0dfb9 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -676,12 +676,13 @@ FF_MPV_OPT_CMP_FUNC, \
 {"mepc", "Motion estimation bitrate penalty compensation (1.0 = 256)", 
FF_MPV_OFFSET(me_penalty_compensation), AV_OPT_TYPE_INT, {.i64 = 256 }, 
INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \
 {"mepre", "pre motion estimation", FF_MPV_OFFSET(me_pre), AV_OPT_TYPE_INT, 
{.i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \
 {"intra_penalty", "Penalty for intra blocks in block decision", 
FF_MPV_OFFSET(intra_penalty), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, INT_MAX/2, 
FF_MPV_OPT_FLAGS }, \
-{"a53cc", "Use A53 Closed Captions (if available)", FF_MPV_OFFSET(a53_cc), 
AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, 1, FF_MPV_OPT_FLAGS }, \
 FF_MPV_RC_STRATEGY_OPTS
 
 #if FF_API_MPEGVIDEO_OPTS
 #define FF_MPV_DEPRECATED_MPEG_QUANT_OPT \
 { "mpeg_quant", "Deprecated, does nothing", FF_MPV_OFFSET(mpeg_quant), 
AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 0, FF_MPV_OPT_FLAGS | AV_OPT_FLAG_DEPRECATED },
+#define FF_MPV_DEPRECATED_A53_CC_OPT \
+{ "a53cc",  "Deprecated, does nothing", FF_MPV_OFFSET(a53_cc), 
AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, FF_MPV_OPT_FLAGS | AV_OPT_FLAG_DEPRECATED 
},
 #endif
 
 extern const AVOption ff_mpv_generic_options[];
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 19a7e57a29..03fcfa83dd 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -88,6 +88,7 @@ const AVOption ff_mpv_generic_options[] = {
 FF_MPV_COMMON_OPTS
 #if FF_API_MPEGVIDEO_OPTS
 FF_MPV_DEPRECATED_MPEG_QUANT_OPT
+FF_MPV_DEPRECATED_A53_CC_OPT
 #endif
 { NULL },
 };
@@ -4712,6 +4713,7 @@ static const AVOption h263_options[] = {
 FF_MPV_COMMON_OPTS
 #if FF_API_MPEGVIDEO_OPTS
 FF_MPV_DEPRECATED_MPEG_QUANT_OPT
+FF_MPV_DEPRECATED_A53_CC_OPT
 #endif
 { NULL },
 };
@@ -4745,6 +4747,7 @@ static const AVOption h263p_options[] = {
 FF_MPV_COMMON_OPTS
 #if FF_API_MPEGVIDEO_OPTS
 FF_MPV_DEPRECATED_MPEG_QUANT_OPT
+FF_MPV_DEPRECATED_A53_CC_OPT
 #endif
 { NULL },
 };
-- 
2.27.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 "

[FFmpeg-devel] [PATCH 19/19] avcodec/mpeg12dec: Remove redundant writes

2021-04-06 Thread Andreas Rheinhardt
ff_mpv_decode_init() already sets MpegEncContext.codec_id.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/mpeg12dec.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
index 92dd6a0b24..db522963c4 100644
--- a/libavcodec/mpeg12dec.c
+++ b/libavcodec/mpeg12dec.c
@@ -1067,7 +1067,6 @@ static av_cold int mpeg_decode_init(AVCodecContext *avctx)
 s->mpeg_enc_ctx_allocated  = 0;
 s->mpeg_enc_ctx.picture_number = 0;
 s->repeat_field= 0;
-s->mpeg_enc_ctx.codec_id   = avctx->codec->id;
 avctx->color_range = AVCOL_RANGE_MPEG;
 return 0;
 }
-- 
2.27.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 17/19] avcodec/mpegvideo: Deprecate duplicate matrix opt for unsupported codecs

2021-04-06 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/mjpegenc.c  | 1 +
 libavcodec/mpeg12enc.c | 2 ++
 libavcodec/mpeg4videoenc.c | 1 +
 libavcodec/mpegvideo.h | 3 ++-
 libavcodec/mpegvideo_enc.c | 3 +++
 5 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/libavcodec/mjpegenc.c b/libavcodec/mjpegenc.c
index 86a18ec6a9..792169d6bb 100644
--- a/libavcodec/mjpegenc.c
+++ b/libavcodec/mjpegenc.c
@@ -593,6 +593,7 @@ FF_MPV_COMMON_OPTS
 { "huffman", "Huffman table strategy", OFFSET(huffman), AV_OPT_TYPE_INT, { 
.i64 = HUFFMAN_TABLE_OPTIMAL }, 0, NB_HUFFMAN_TABLE_OPTION - 1, VE, "huffman" },
 { "default", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = HUFFMAN_TABLE_DEFAULT }, 
INT_MIN, INT_MAX, VE, "huffman" },
 { "optimal", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = HUFFMAN_TABLE_OPTIMAL }, 
INT_MIN, INT_MAX, VE, "huffman" },
+{ "force_duplicated_matrix", "Always write luma and chroma matrix for mjpeg, 
useful for rtp streaming.", OFFSET(force_duplicated_matrix), AV_OPT_TYPE_BOOL, 
{.i64 = 0 }, 0, 1, VE },
 #if FF_API_MPEGVIDEO_OPTS
 FF_MPV_DEPRECATED_MPEG_QUANT_OPT
 FF_MPV_DEPRECATED_A53_CC_OPT
diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c
index 5b8ccf3ce1..0b88408046 100644
--- a/libavcodec/mpeg12enc.c
+++ b/libavcodec/mpeg12enc.c
@@ -1155,6 +1155,7 @@ static const AVOption mpeg1_options[] = {
 #if FF_API_MPEGVIDEO_OPTS
 FF_MPV_DEPRECATED_MPEG_QUANT_OPT
 FF_MPV_DEPRECATED_A53_CC_OPT
+FF_MPV_DEPRECATED_MATRIX_OPT
 #endif
 { NULL },
 };
@@ -1187,6 +1188,7 @@ static const AVOption mpeg2_options[] = {
 #if FF_API_MPEGVIDEO_OPTS
 { "mpeg_quant",   "Deprecated, does nothing", OFFSET(mpeg_quant),
   AV_OPT_TYPE_INT, {.i64 = 1 }, 0, 1, VE | AV_OPT_FLAG_DEPRECATED },
+FF_MPV_DEPRECATED_MATRIX_OPT
 #endif
 FF_MPEG2_PROFILE_OPTS
 { NULL },
diff --git a/libavcodec/mpeg4videoenc.c b/libavcodec/mpeg4videoenc.c
index 384710cf60..f97c506d13 100644
--- a/libavcodec/mpeg4videoenc.c
+++ b/libavcodec/mpeg4videoenc.c
@@ -1380,6 +1380,7 @@ static const AVOption options[] = {
 FF_MPV_COMMON_OPTS
 #if FF_API_MPEGVIDEO_OPTS
 FF_MPV_DEPRECATED_A53_CC_OPT
+FF_MPV_DEPRECATED_MATRIX_OPT
 #endif
 FF_MPEG4_PROFILE_OPTS
 { NULL },
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index 508ae0dfb9..9a6ad75166 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -662,7 +662,6 @@ FF_MPV_OPT_CMP_FUNC, \
 { "zero", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_ME_ZERO }, 0, 0, 
FF_MPV_OPT_FLAGS, "motion_est" }, \
 { "epzs", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_ME_EPZS }, 0, 0, 
FF_MPV_OPT_FLAGS, "motion_est" }, \
 { "xone", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_ME_XONE }, 0, 0, 
FF_MPV_OPT_FLAGS, "motion_est" }, \
-{ "force_duplicated_matrix", "Always write luma and chroma matrix for mjpeg, 
useful for rtp streaming.", FF_MPV_OFFSET(force_duplicated_matrix), 
AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, FF_MPV_OPT_FLAGS },   \
 {"b_strategy", "Strategy to choose between I/P/B-frames",   
FF_MPV_OFFSET(b_frame_strategy), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 2, 
FF_MPV_OPT_FLAGS }, \
 {"b_sensitivity", "Adjust sensitivity of b_frame_strategy 1",   
FF_MPV_OFFSET(b_sensitivity), AV_OPT_TYPE_INT, {.i64 = 40 }, 1, INT_MAX, 
FF_MPV_OPT_FLAGS }, \
 {"brd_scale", "Downscale frames for dynamic B-frame decision",  
FF_MPV_OFFSET(brd_scale), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 3, FF_MPV_OPT_FLAGS 
}, \
@@ -683,6 +682,8 @@ FF_MPV_RC_STRATEGY_OPTS
 { "mpeg_quant", "Deprecated, does nothing", FF_MPV_OFFSET(mpeg_quant), 
AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 0, FF_MPV_OPT_FLAGS | AV_OPT_FLAG_DEPRECATED },
 #define FF_MPV_DEPRECATED_A53_CC_OPT \
 { "a53cc",  "Deprecated, does nothing", FF_MPV_OFFSET(a53_cc), 
AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, FF_MPV_OPT_FLAGS | AV_OPT_FLAG_DEPRECATED 
},
+#define FF_MPV_DEPRECATED_MATRIX_OPT \
+   { "force_duplicated_matrix", "Deprecated, does nothing", 
FF_MPV_OFFSET(force_duplicated_matrix), AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, 
FF_MPV_OPT_FLAGS | AV_OPT_FLAG_DEPRECATED },
 #endif
 
 extern const AVOption ff_mpv_generic_options[];
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 03fcfa83dd..2330e4440e 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -89,6 +89,7 @@ const AVOption ff_mpv_generic_options[] = {
 #if FF_API_MPEGVIDEO_OPTS
 FF_MPV_DEPRECATED_MPEG_QUANT_OPT
 FF_MPV_DEPRECATED_A53_CC_OPT
+FF_MPV_DEPRECATED_MATRIX_OPT
 #endif
 { NULL },
 };
@@ -4714,6 +4715,7 @@ static const AVOption h263_options[] = {
 #if FF_API_MPEGVIDEO_OPTS
 FF_MPV_DEPRECATED_MPEG_QUANT_OPT
 FF_MPV_DEPRECATED_A53_CC_OPT
+FF_MPV_DEPRECATED_MATRIX_OPT
 #endif
 { NULL },
 };
@@ -4748,6 +4750,7 @@ static const AVOption h263p_options[] = {
 #if FF_API_MPEGVIDEO_OPTS
 FF_MPV_DEPRECATED_MPEG_QUANT_OPT
 FF_MPV_DEPRECATED_A53_CC_OPT
+FF_MPV_DEPRECATED_MATRIX_OPT
 #endif
 { NULL },
 };
-- 
2.27.0

___

[FFmpeg-devel] [PATCH] avcodec/msp2dec: Check available space in RLE decoder

2021-04-06 Thread Michael Niedermayer
Fixes: out of array read
Fixes: 
32968/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MSP2_fuzzer-5315296027082752

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
---
 libavcodec/msp2dec.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavcodec/msp2dec.c b/libavcodec/msp2dec.c
index cc548d218a..87057fb5e2 100644
--- a/libavcodec/msp2dec.c
+++ b/libavcodec/msp2dec.c
@@ -68,9 +68,10 @@ static int msp2_decode_frame(AVCodecContext *avctx,
 
 bytestream2_init(&gb, buf, pkt_size);
 x = 0;
-while (bytestream2_get_bytes_left(&gb) && x < width) {
+while (bytestream2_get_bytes_left(&gb) > 0 && x < width) {
 int size = bytestream2_get_byte(&gb);
 if (size) {
+size = FFMIN(size, bytestream2_get_bytes_left(&gb));
 memcpy(p->data[0] + y * p->linesize[0] + x, gb.buffer, 
FFMIN(size, width - x));
 bytestream2_skip(&gb, size);
 } else {
-- 
2.17.1

___
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 11/19] avcodec/mpeg12enc: Move MPEG-1/2 dimension checks to mpeg12enc

2021-04-06 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/mpeg12enc.c |  8 
 libavcodec/mpegvideo_enc.c | 14 --
 2 files changed, 8 insertions(+), 14 deletions(-)

diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c
index 5676caef87..b7d3d1c6b0 100644
--- a/libavcodec/mpeg12enc.c
+++ b/libavcodec/mpeg12enc.c
@@ -144,6 +144,14 @@ static av_cold int encode_init(AVCodecContext *avctx)
 {
 int ret;
 MpegEncContext *s = avctx->priv_data;
+int max_size = avctx->codec_id == AV_CODEC_ID_MPEG2VIDEO ? 16383 : 4095;
+
+if (avctx->width > max_size || avctx->height > max_size) {
+av_log(avctx, AV_LOG_ERROR, "%s does not support resolutions above 
%dx%d\n",
+   CONFIG_SMALL ? avctx->codec->name : avctx->codec->long_name,
+   max_size, max_size);
+return AVERROR(EINVAL);
+}
 
 if ((ret = ff_mpv_encode_init(avctx)) < 0)
 return ret;
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 2a0fd60cbc..d1f2460409 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -534,20 +534,6 @@ FF_ENABLE_DEPRECATION_WARNINGS
 return AVERROR(EINVAL);
 }
 
-if (s->codec_id == AV_CODEC_ID_MPEG1VIDEO &&
-(avctx->width  > 4095 ||
- avctx->height > 4095 )) {
-av_log(avctx, AV_LOG_ERROR, "MPEG-1 does not support resolutions above 
4095x4095\n");
-return AVERROR(EINVAL);
-}
-
-if (s->codec_id == AV_CODEC_ID_MPEG2VIDEO &&
-(avctx->width  > 16383 ||
- avctx->height > 16383 )) {
-av_log(avctx, AV_LOG_ERROR, "MPEG-2 does not support resolutions above 
16383x16383\n");
-return AVERROR(EINVAL);
-}
-
 if (s->codec_id == AV_CODEC_ID_RV10 &&
 (avctx->width &15 ||
  avctx->height&15 )) {
-- 
2.27.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avcodec/msp2dec: Check available space in RLE decoder

2021-04-06 Thread Peter Ross
On Tue, Apr 06, 2021 at 11:50:22PM +0200, Michael Niedermayer wrote:
> Fixes: out of array read
> Fixes: 
> 32968/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MSP2_fuzzer-5315296027082752
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/msp2dec.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/libavcodec/msp2dec.c b/libavcodec/msp2dec.c
> index cc548d218a..87057fb5e2 100644
> --- a/libavcodec/msp2dec.c
> +++ b/libavcodec/msp2dec.c
> @@ -68,9 +68,10 @@ static int msp2_decode_frame(AVCodecContext *avctx,
>  
>  bytestream2_init(&gb, buf, pkt_size);
>  x = 0;
> -while (bytestream2_get_bytes_left(&gb) && x < width) {
> +while (bytestream2_get_bytes_left(&gb) > 0 && x < width) {
>  int size = bytestream2_get_byte(&gb);
>  if (size) {
> +size = FFMIN(size, bytestream2_get_bytes_left(&gb));
>  memcpy(p->data[0] + y * p->linesize[0] + x, gb.buffer, 
> FFMIN(size, width - x));
>  bytestream2_skip(&gb, size);
>  } else {

please apply

-- Peter
(A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)


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] avcodec/msp2dec: Check available space in RLE decoder

2021-04-06 Thread Andreas Rheinhardt
Michael Niedermayer:
> Fixes: out of array read
> Fixes: 
> 32968/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MSP2_fuzzer-5315296027082752
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/msp2dec.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/libavcodec/msp2dec.c b/libavcodec/msp2dec.c
> index cc548d218a..87057fb5e2 100644
> --- a/libavcodec/msp2dec.c
> +++ b/libavcodec/msp2dec.c
> @@ -68,9 +68,10 @@ static int msp2_decode_frame(AVCodecContext *avctx,
>  
>  bytestream2_init(&gb, buf, pkt_size);
>  x = 0;
> -while (bytestream2_get_bytes_left(&gb) && x < width) {
> +while (bytestream2_get_bytes_left(&gb) > 0 && x < width) {

This decoder uses the checked bytestream2 API, so != 0 and > 0 should be
equivalent for bytestream2_get_bytes_left(&gb).

>  int size = bytestream2_get_byte(&gb);
>  if (size) {
> +size = FFMIN(size, bytestream2_get_bytes_left(&gb));
>  memcpy(p->data[0] + y * p->linesize[0] + x, gb.buffer, 
> FFMIN(size, width - x));

width can include seven bytes of the packet's padding, but it stays
within the padding, so I wonder where the out of array read comes from.
The only fishy thing in this decoder I see is that 2 * avctx->height
might overflow.

>  bytestream2_skip(&gb, size);
>  } else {
> 
___
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] mov: Prioritize aspect ratio values found in pasp atom

2021-04-06 Thread Carl Eugen Hoyos
Am Di., 6. Apr. 2021 um 21:51 Uhr schrieb Vittorio Giovara
:
>
> without my patch the sample is shown at a 16:9
> AR (which I assume was the original fix), with my patch the sample uses an
> AR of 1:1 and it is therefore square.

> However I tried with a recent
> Quicktime, and it displays the sample using the square aspect ratio.

I would expect that it looks different with older QuickTime versions.

Carl Eugen
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avcodec/msp2dec: Check available space in RLE decoder

2021-04-06 Thread Andreas Rheinhardt
Andreas Rheinhardt:
> Michael Niedermayer:
>> Fixes: out of array read
>> Fixes: 
>> 32968/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MSP2_fuzzer-5315296027082752
>>
>> Found-by: continuous fuzzing process 
>> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
>> Signed-off-by: Michael Niedermayer 
>> ---
>>  libavcodec/msp2dec.c | 3 ++-
>>  1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/libavcodec/msp2dec.c b/libavcodec/msp2dec.c
>> index cc548d218a..87057fb5e2 100644
>> --- a/libavcodec/msp2dec.c
>> +++ b/libavcodec/msp2dec.c
>> @@ -68,9 +68,10 @@ static int msp2_decode_frame(AVCodecContext *avctx,
>>  
>>  bytestream2_init(&gb, buf, pkt_size);
>>  x = 0;
>> -while (bytestream2_get_bytes_left(&gb) && x < width) {
>> +while (bytestream2_get_bytes_left(&gb) > 0 && x < width) {
> 
> This decoder uses the checked bytestream2 API, so != 0 and > 0 should be
> equivalent for bytestream2_get_bytes_left(&gb).
> 
>>  int size = bytestream2_get_byte(&gb);
>>  if (size) {
>> +size = FFMIN(size, bytestream2_get_bytes_left(&gb));
>>  memcpy(p->data[0] + y * p->linesize[0] + x, gb.buffer, 
>> FFMIN(size, width - x));
> 
> width can include seven bytes of the packet's padding, but it stays
> within the padding, so I wonder where the out of array read comes from.
> The only fishy thing in this decoder I see is that 2 * avctx->height
> might overflow.
> 

Correction: width has no relationship with the packet's size at all; the
width - x in the above FFMIN only ensures that it writes at most seven
bytes into the frame's padding (is the frame actually guaranteed to be
padded?).
Btw: I don't see any advantage of writing in the frame's padding.

- Andreas
___
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] libavformat/id3v2: Read full null seperated list for text info frames

2021-04-06 Thread Lode Willems
All id3v2.4 text information frames are null separated lists:
https://id3.org/id3v2.4.0-frames

This change reads all values into the metadata dictionary without changing the
outputs of ffmpeg or ffprobe

Relevant ticket: https://trac.ffmpeg.org/ticket/6949

Signed-off-by: Lode Willems 
---
 libavformat/id3v2.c| 5 -
 libavformat/metadata.c | 2 +-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/libavformat/id3v2.c b/libavformat/id3v2.c
index 863709abbf..9ef56a52c2 100644
--- a/libavformat/id3v2.c
+++ b/libavformat/id3v2.c
@@ -320,7 +320,7 @@ static void read_ttag(AVFormatContext *s, AVIOContext *pb, 
int taglen,
   AVDictionary **metadata, const char *key)
 {
 uint8_t *dst;
-int encoding, dict_flags = AV_DICT_DONT_OVERWRITE | 
AV_DICT_DONT_STRDUP_VAL;
+int encoding, dict_flags = AV_DICT_DONT_OVERWRITE | 
AV_DICT_DONT_STRDUP_VAL | AV_DICT_MULTIKEY;
 unsigned genre;
 
 if (taglen < 1)
@@ -329,6 +329,8 @@ static void read_ttag(AVFormatContext *s, AVIOContext *pb, 
int taglen,
 encoding = avio_r8(pb);
 taglen--; /* account for encoding type byte */
 
+/* Read all null-terminated values */
+while (taglen > 0) {
 if (decode_str(s, pb, encoding, &dst, &taglen) < 0) {
 av_log(s, AV_LOG_ERROR, "Error reading frame %s, skipped\n", key);
 return;
@@ -353,6 +355,7 @@ static void read_ttag(AVFormatContext *s, AVIOContext *pb, 
int taglen,
 
 if (dst)
 av_dict_set(metadata, key, dst, dict_flags);
+}
 }
 
 static void read_uslt(AVFormatContext *s, AVIOContext *pb, int taglen,
diff --git a/libavformat/metadata.c b/libavformat/metadata.c
index b9b6de7972..68382e7937 100644
--- a/libavformat/metadata.c
+++ b/libavformat/metadata.c
@@ -50,7 +50,7 @@ void ff_metadata_conv(AVDictionary **pm, const AVMetadataConv 
*d_conv,
 key = dc->native;
 break;
 }
-av_dict_set(&dst, key, mtag->value, 0);
+av_dict_set(&dst, key, mtag->value, AV_DICT_DONT_OVERWRITE);
 }
 av_dict_free(pm);
 *pm = dst;
-- 
2.31.0
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] libavcodec/qsvdec: use the param from decodeHeader to configure surface

2021-04-06 Thread Chen, Wenbin


> -Original Message-
> From: Xiang, Haihao 
> Sent: Tuesday, April 6, 2021 11:08 PM
> To: Chen, Wenbin ; ffmpeg-devel@ffmpeg.org
> Subject: Re: [FFmpeg-devel] [PATCH] libavcodec/qsvdec: use the param from
> decodeHeader to configure surface
> 
> On Tue, 2021-04-06 at 07:54 +, Chen, Wenbin wrote:
> > > -Original Message-
> > > From: Xiang, Haihao 
> > > Sent: Tuesday, April 6, 2021 2:24 PM
> > > To: Chen, Wenbin ; ffmpeg-devel@ffmpeg.org
> > > Subject: Re: [FFmpeg-devel] [PATCH] libavcodec/qsvdec: use the param
> from
> > > decodeHeader to configure surface
> > >
> > > On Tue, 2021-03-23 at 06:45 +, Chen, Wenbin wrote:
> > > > > -Original Message-
> > > > > From: Xiang, Haihao 
> > > > > Sent: Tuesday, March 23, 2021 12:10 PM
> > > > > To: ffmpeg-devel@ffmpeg.org
> > > > > Cc: Chen, Wenbin 
> > > > > Subject: Re: [FFmpeg-devel] [PATCH] libavcodec/qsvdec: use the
> param
> > >
> > > from
> > > > > decodeHeader to configure surface
> > > > >
> > > > > On Mon, 2021-03-22 at 14:31 +0800, wenbin.c...@intel.com wrote:
> > > > > > From: "Chen,Wenbin" 
> > > > > >
> > > > > > MSDK recognizes both yuv420p10 and yuv420p9 as
> MFX_FOURCC_P010,
> > > > >
> > > > > but param
> > > > > > are different. When decode yuv420p9 video, ffmpeg-qsv will use
> > > > > > yuv420p10le to configure surface which is different with param from
> > > > > > DecoderHeader and this will lead to error. Now change it use
> > > > > > param from decoderHeader to configure surface.
> > > > >
> > > > >
> > > > > Both yuv420p10 and yuv420p9 have 3 planes (
> > > > >
> > >
> > >
> https://github.com/FFmpeg/FFmpeg/blob/master/libavutil/pixdesc.c#L1359-
> > > > > L1406) ,
> > > > > but MFX_FOURCC_P010 has 2 planes only. MSDK doesn't recognizes
> > > > > yuv420p10 and
> > > > > yuv420p9 as MFX_FOURCC_P010. FFmpeg-qsv uses p010le instead of
> > > > > yuv420p10le to
> > > > > configure surface for 10bit video.
> > > > >
> > > >
> > > > Sorry, I didn't describe the problem well. I mean when MSDK
> > >
> > > decodeHeader a
> > > > 9bit video
> > > > It will return MFX_FOURCC_P010, but its frameInfo is 9bit. However
> > >
> > > FFmpeg-qsv
> > > > will use P010's parameter
> > > > to configure surface which will be 10bit, and if ffmpeg-qsv send 10bit
> > >
> > > surface
> > > > to decode 9bit video MSDK will report an error.
> > > >
> > >
> > > So it will use yuv420p10le for a 9bit video, right? A potential issue here
> > > is
> > > the depth info will be lost in the pipeline, a filter after qsv decoder 
> > > will
> > > take it as 10bit frame instead of 9bit frame.
> > >
> > > Thanks
> > > Haihao
> > >
> > >
> >
> > Yes, there is a risk of losing depth information. Function
> ff_qsv_map_fourcc()
> > should also takes
> > "FrameInfo.BitDepth" into consideration. This issue is not brought by this
> > patch, we may fix it in a new patch.
> 
> 
> FFmpeg has already used pixfmt for both memory layout and the used bits in
> a
> frame. I think you should add a new pixfmt for your case, otherwise we
> won't
> know the bit depth when handling a yuv420p10le frame in a filter if using
> yuv420p10le for a 9bit video.
> 

Ok, I will try to add a new pixel format.

> 
> >
> > Thanks
> > wenbin
> >
> > > > >
> > > > > >
> > > > > > Signed-off-by Wenbin Chen 
> > > > > > ---
> > > > > >  libavcodec/qsvdec.c | 4 ++--
> > > > > >  1 file changed, 2 insertions(+), 2 deletions(-)
> > > > > >
> > > > > > diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
> > > > > > index 569ccd4fba..3ab48ea7a2 100644
> > > > > > --- a/libavcodec/qsvdec.c
> > > > > > +++ b/libavcodec/qsvdec.c
> > > > > > @@ -309,13 +309,13 @@ static int alloc_frame(AVCodecContext
> *avctx,
> > > > >
> > > > > QSVContext
> > > > > > *q, QSVFrame *frame)
> > > > > >  if (frame->frame->format == AV_PIX_FMT_QSV) {
> > > > > >  frame->surface = *(mfxFrameSurface1*)frame->frame-
> >data[3];
> > > > > >  } else {
> > > > > > -frame->surface.Info = q->frame_info;
> > > > > > -
> > > > > >  frame->surface.Data.PitchLow = frame->frame->linesize[0];
> > > > > >  frame->surface.Data.Y= frame->frame->data[0];
> > > > > >  frame->surface.Data.UV   = frame->frame->data[1];
> > > > > >  }
> > > > > >
> > > > > > +frame->surface.Info = q->frame_info;
> > > > > > +
> > > > > >  if (q->frames_ctx.mids) {
> > > > > >  ret = ff_qsv_find_surface_idx(&q->frames_ctx, frame);
> > > > > >  if (ret < 0)
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH V6 4/6] lavu: add side data AV_FRAME_DATA_BOUNDING_BOXES

2021-04-06 Thread Guo, Yejun


> -Original Message-
> From: ffmpeg-devel  On Behalf Of Nicolas
> George
> Sent: 2021年4月7日 0:46
> To: FFmpeg development discussions and patches 
> Subject: Re: [FFmpeg-devel] [PATCH V6 4/6] lavu: add side data
> AV_FRAME_DATA_BOUNDING_BOXES
> 
> Guo, Yejun (12021-04-06):
> > compile error on ubuntu 18.04 with default setting:
> > error: ISO C90 forbids variable length array ‘boxes’ [-Werror=vla]
> >   AVBoundingBox boxes[nb_bboxes];
> 
> This warning is explicitly added by configure it, we do not have to keep
> it if it hiders us.
> 
> If people agree with my analysis that pointers to VLA used to compute
> sizes and offsets in an isolated function are not a problem, unlike
> actual VLAs on the stack, then we can just remove it. I do not think we
> are at risk of adding VLAs by mistake.

I see, thanks. 

@Michael, any comment on this, thanks, '-Werror=vla' is enabled by 293e5423
in 2012. I can send a patch to remove this in configure for more comments. 

Then, I can update my detection patch set according to the result.

___
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] web/index: add news entry for 4:3

2021-04-06 Thread Gyan Doshi
---
 src/index | 85 +++
 1 file changed, 85 insertions(+)

Better late than never!

diff --git a/src/index b/src/index
index fdde3d3..b0ca46c 100644
--- a/src/index
+++ b/src/index
@@ -35,6 +35,91 @@
 News
   
 
+  June 15th, 2020, FFmpeg 4.3 "4:3"
+  
+FFmpeg 4.3 "4:3", a new
+major release, is now available! Some of the highlights:
+  
+  
+v360 filter
+Intel QSV-accelerated MJPEG decoding
+Intel QSV-accelerated VP9 decoding
+Support for TrueHD in mp4
+Support AMD AMF encoder on Linux (via Vulkan)
+IMM5 video decoder
+ZeroMQ protocol
+support Sipro ACELP.KELVIN decoding
+streamhash muxer
+sierpinski video source
+scroll video filter
+photosensitivity filter
+anlms filter
+arnndn filter
+bilateral filter
+maskedmin and maskedmax filters
+VDPAU VP9 hwaccel
+median filter
+QSV-accelerated VP9 encoding
+AV1 encoding support via librav1e
+AV1 frame merge bitstream filter
+AV1 Annex B demuxer
+axcorrelate filter
+mvdv decoder
+mvha decoder
+MPEG-H 3D Audio support in mp4
+thistogram filter
+freezeframes filter
+Argonaut Games ADPCM decoder
+Argonaut Games ASF demuxer
+xfade video filter
+xfade_opencl filter
+afirsrc audio filter source
+pad_opencl filter
+Simon & Schuster Interactive ADPCM decoder
+Real War KVAG demuxer
+CDToons video decoder
+siren audio decoder
+Rayman 2 ADPCM decoder
+Rayman 2 APM demuxer
+cas video filter
+High Voltage Software ADPCM decoder
+LEGO Racers ALP (.tun & .pcm) demuxer
+AMQP 0-9-1 protocol (RabbitMQ)
+Vulkan support
+avgblur_vulkan, overlay_vulkan, scale_vulkan and chromaber_vulkan 
filters
+ADPCM IMA MTF decoder
+FWSE demuxer
+DERF DPCM decoder
+DERF demuxer
+CRI HCA decoder
+CRI HCA demuxer
+overlay_cuda filter
+switch from AvxSynth to AviSynth+ on Linux
+mv30 decoder
+Expanded styling support for 3GPP Timed Text Subtitles (movtext)
+WebP parser
+tmedian filter
+maskedthreshold filter
+Support for muxing pcm and pgs in m2ts
+Cunning Developments ADPCM decoder
+asubboost filter
+Pro Pinball Series Soundbank demuxer
+pcm_rechunk bitstream filter
+scdet filter
+NotchLC decoder
+gradients source video filter
+MediaFoundation encoder wrapper
+untile filter
+Simon & Schuster Interactive ADPCM encoder
+PFM decoder
+dblur video filter
+Real War KVAG muxer
+  
+  
+We strongly recommend users, distributors, and system integrators to
+upgrade unless they use current git master.
+  
+
   October 5th, 2019, Bright Lights
   
   FFmpeg has added a realtime bright flash removal filter to libavfilter.
-- 
2.30.1

___
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".