Re: [FFmpeg-devel] [PATCH 2/2] avformat/mxfenc: support XAVC long gop

2019-04-24 Thread Baptiste Coudurier
Hi Michael, I hope you are doing well,

> On Apr 16, 2019, at 4:03 PM, Michael Niedermayer  
> wrote:
> 
> Signed PGP part
> On Wed, Apr 10, 2019 at 06:54:53PM -0300, James Almer wrote:
>> On 4/10/2019 6:26 PM, Baptiste Coudurier wrote:
 On Apr 9, 2019, at 6:27 PM, James Almer  wrote:
 
 On 4/9/2019 9:40 PM, Baptiste Coudurier wrote:
> 
>> On Apr 9, 2019, at 5:24 PM, James Almer  wrote:
>> 
>> On 4/9/2019 8:59 PM, Baptiste Coudurier wrote:
>>> 
 On Apr 9, 2019, at 4:51 PM, James Almer  wrote:
 
 On 4/9/2019 8:22 PM, Baptiste Coudurier wrote:
> Hi James,
> 
>> On Apr 9, 2019, at 4:09 PM, James Almer  wrote:
>> 
>>> […]
>> 
>> Ok so, the only fields you need from the sps are 
>> constraint_set_flags,
>> frame_mbs_only_flag, bit_depth_luma, profile_idc, level_idc and sar,
>> meaning you don't even need to parse the sps until the very end (sar 
>> is
>> the furthest value, and right at the beginning of vui_parameters).
>> I'd very much prefer if we can avoid making
>> ff_h264_decode_seq_parameter_set() avpriv and with it H264ParamSets 
>> part
>> of the ABI, so i think it's worth copying the required bitstream 
>> parsing
>> code at least until the beginning of vui_parameters. It was done for
>> hevc and av1, so it can be done for h264 as well.
> 
> Since vui parsing is needed, that would be the entire 
> "ff_h264_decode_seq_parameter_set()” function.
 
 If you only need up to sar, then yo don't need to parse the entire VUI.
>>> 
>>> It still requires copying the entire 
>>> ff_h264_decode_seq_parameter_set(), even though the sub functions are 
>>> not needed.
>>> 
> 
> I disagree with the copying. I also disagree with the copying for 
> AVC1 and HEVC btw.
 
 Using avpriv opens a whole can of worms that will be unpredictable in
 the future. Just look at recent commits like
 f4ea930a119298c6110ee4e3d24219a66e27e230 that started storing 
 previously
 skipped values. If hevc_pc was made avpriv for isombff/matroska muxing
 purposes and its structs part of the ABI, this wouldn't have been
 possible until a major bump.
>>> 
>>> When did the sharing policy between avformat and avcodec (in the sense 
>>> avformat using avcodec) change ?
>>> It seems perfectly natural to me to have libavformat require the 
>>> libavcodec version that it was compiled with,
>>> and check it at runtime.
>> 
>> More than one ffmpeg release will ship with libavcodec/libavformat
>> sharing the same soname. Backwards compatibility is expected, hence the
>> split between major, minor and micro, as you're meant to be able to drop
>> a newer libavcodec library, say for example ffmpeg 4.1's
>> libavcodec.58.so, and it should work with an existing libavformat.so.58
>> that was linked against ffmpeg 4.0's libavcodec.58.so.
> 
> Sorry to repeat the question but when did that change ?
 
 I don't know if it ever changed to being with. It's been like this for
 as long as i remember, and i don't recall inter-library version checks
 that would take minor and micro into consideration (which would be
 needed to truly tie a given libavformat library with the exact
 libavcodec it was linked to) whereas ABI backwards compatibility
 considerations for inter-library stuff can be seen all across the
 codebase and git history.
>>> 
>>> It definitely changed, probably around the introduction of “avpriv” prefix.
>> 
>> I think that predates my arrival to the project. Someone else will have
>> to chime in...
> 
> it possibly changed from "we dont care / we didnt think about it" in the
> distant past, iam not sure its very long ago.
> But strange interdependancies on minor/micro versions that are outside
> the established rules (https://semver.org/ )
> can cause surprises and problems to for example packagers for distros.
> So i suggest to stay close to what most users of the libs / packagers do
> expect and whould causes the least problems and surprise …

Actually I just saw this:
WARNING: library configuration mismatch
From fftools/cmdutils.c line 1117 from 2010 it seems

So we did care about warning about it since we added this code.

I still believe we should enforce libavcodec version inside libavformat,
but that will be another topic.

—
Baptiste






signature.asc
Description: Message signed with OpenPGP
___
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 2/2] avformat/mxfenc: support XAVC long gop

2019-04-16 Thread Michael Niedermayer
On Wed, Apr 10, 2019 at 06:54:53PM -0300, James Almer wrote:
> On 4/10/2019 6:26 PM, Baptiste Coudurier wrote:
> >> On Apr 9, 2019, at 6:27 PM, James Almer  wrote:
> >>
> >> On 4/9/2019 9:40 PM, Baptiste Coudurier wrote:
> >>>
>  On Apr 9, 2019, at 5:24 PM, James Almer  wrote:
> 
>  On 4/9/2019 8:59 PM, Baptiste Coudurier wrote:
> >
> >> On Apr 9, 2019, at 4:51 PM, James Almer  wrote:
> >>
> >> On 4/9/2019 8:22 PM, Baptiste Coudurier wrote:
> >>> Hi James,
> >>>
>  On Apr 9, 2019, at 4:09 PM, James Almer  wrote:
> 
> > […]
> 
>  Ok so, the only fields you need from the sps are 
>  constraint_set_flags,
>  frame_mbs_only_flag, bit_depth_luma, profile_idc, level_idc and sar,
>  meaning you don't even need to parse the sps until the very end (sar 
>  is
>  the furthest value, and right at the beginning of vui_parameters).
>  I'd very much prefer if we can avoid making
>  ff_h264_decode_seq_parameter_set() avpriv and with it H264ParamSets 
>  part
>  of the ABI, so i think it's worth copying the required bitstream 
>  parsing
>  code at least until the beginning of vui_parameters. It was done for
>  hevc and av1, so it can be done for h264 as well.
> >>>
> >>> Since vui parsing is needed, that would be the entire 
> >>> "ff_h264_decode_seq_parameter_set()” function.
> >>
> >> If you only need up to sar, then yo don't need to parse the entire VUI.
> >
> > It still requires copying the entire 
> > ff_h264_decode_seq_parameter_set(), even though the sub functions are 
> > not needed. 
> >
> >>>
> >>> I disagree with the copying. I also disagree with the copying for 
> >>> AVC1 and HEVC btw.
> >>
> >> Using avpriv opens a whole can of worms that will be unpredictable in
> >> the future. Just look at recent commits like
> >> f4ea930a119298c6110ee4e3d24219a66e27e230 that started storing 
> >> previously
> >> skipped values. If hevc_pc was made avpriv for isombff/matroska muxing
> >> purposes and its structs part of the ABI, this wouldn't have been
> >> possible until a major bump.
> >
> > When did the sharing policy between avformat and avcodec (in the sense 
> > avformat using avcodec) change ?
> > It seems perfectly natural to me to have libavformat require the 
> > libavcodec version that it was compiled with,
> > and check it at runtime.
> 
>  More than one ffmpeg release will ship with libavcodec/libavformat
>  sharing the same soname. Backwards compatibility is expected, hence the
>  split between major, minor and micro, as you're meant to be able to drop
>  a newer libavcodec library, say for example ffmpeg 4.1's
>  libavcodec.58.so, and it should work with an existing libavformat.so.58
>  that was linked against ffmpeg 4.0's libavcodec.58.so.
> >>>
> >>> Sorry to repeat the question but when did that change ?
> >>
> >> I don't know if it ever changed to being with. It's been like this for
> >> as long as i remember, and i don't recall inter-library version checks
> >> that would take minor and micro into consideration (which would be
> >> needed to truly tie a given libavformat library with the exact
> >> libavcodec it was linked to) whereas ABI backwards compatibility
> >> considerations for inter-library stuff can be seen all across the
> >> codebase and git history.
> > 
> > It definitely changed, probably around the introduction of “avpriv” prefix.
> 
> I think that predates my arrival to the project. Someone else will have
> to chime in...

it possibly changed from "we dont care / we didnt think about it" in the 
distant past, iam not sure its very long ago.
But strange interdependancies on minor/micro versions that are outside
the established rules (https://semver.org/)
can cause surprises and problems to for example packagers for distros.
So i suggest to stay close to what most users of the libs / packagers do
expect and whould causes the least problems and surprise ...

Thanks

[...]
-- 
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
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 2/2] avformat/mxfenc: support XAVC long gop

2019-04-10 Thread James Almer
On 4/10/2019 6:26 PM, Baptiste Coudurier wrote:
>> On Apr 9, 2019, at 6:27 PM, James Almer  wrote:
>>
>> On 4/9/2019 9:40 PM, Baptiste Coudurier wrote:
>>>
 On Apr 9, 2019, at 5:24 PM, James Almer  wrote:

 On 4/9/2019 8:59 PM, Baptiste Coudurier wrote:
>
>> On Apr 9, 2019, at 4:51 PM, James Almer  wrote:
>>
>> On 4/9/2019 8:22 PM, Baptiste Coudurier wrote:
>>> Hi James,
>>>
 On Apr 9, 2019, at 4:09 PM, James Almer  wrote:

> […]

 Ok so, the only fields you need from the sps are constraint_set_flags,
 frame_mbs_only_flag, bit_depth_luma, profile_idc, level_idc and sar,
 meaning you don't even need to parse the sps until the very end (sar is
 the furthest value, and right at the beginning of vui_parameters).
 I'd very much prefer if we can avoid making
 ff_h264_decode_seq_parameter_set() avpriv and with it H264ParamSets 
 part
 of the ABI, so i think it's worth copying the required bitstream 
 parsing
 code at least until the beginning of vui_parameters. It was done for
 hevc and av1, so it can be done for h264 as well.
>>>
>>> Since vui parsing is needed, that would be the entire 
>>> "ff_h264_decode_seq_parameter_set()” function.
>>
>> If you only need up to sar, then yo don't need to parse the entire VUI.
>
> It still requires copying the entire ff_h264_decode_seq_parameter_set(), 
> even though the sub functions are not needed. 
>
>>>
>>> I disagree with the copying. I also disagree with the copying for AVC1 
>>> and HEVC btw.
>>
>> Using avpriv opens a whole can of worms that will be unpredictable in
>> the future. Just look at recent commits like
>> f4ea930a119298c6110ee4e3d24219a66e27e230 that started storing previously
>> skipped values. If hevc_pc was made avpriv for isombff/matroska muxing
>> purposes and its structs part of the ABI, this wouldn't have been
>> possible until a major bump.
>
> When did the sharing policy between avformat and avcodec (in the sense 
> avformat using avcodec) change ?
> It seems perfectly natural to me to have libavformat require the 
> libavcodec version that it was compiled with,
> and check it at runtime.

 More than one ffmpeg release will ship with libavcodec/libavformat
 sharing the same soname. Backwards compatibility is expected, hence the
 split between major, minor and micro, as you're meant to be able to drop
 a newer libavcodec library, say for example ffmpeg 4.1's
 libavcodec.58.so, and it should work with an existing libavformat.so.58
 that was linked against ffmpeg 4.0's libavcodec.58.so.
>>>
>>> Sorry to repeat the question but when did that change ?
>>
>> I don't know if it ever changed to being with. It's been like this for
>> as long as i remember, and i don't recall inter-library version checks
>> that would take minor and micro into consideration (which would be
>> needed to truly tie a given libavformat library with the exact
>> libavcodec it was linked to) whereas ABI backwards compatibility
>> considerations for inter-library stuff can be seen all across the
>> codebase and git history.
> 
> It definitely changed, probably around the introduction of “avpriv” prefix.

I think that predates my arrival to the project. Someone else will have
to chime in...

> 
>>> Which practical use case are we covering here ?
>>
>> I don't know, i'm not a library user. But i know the main use case for
>> the longest time was having ffmpeg work as a drop in replacement for
>> libav back when the latter was shipped in debian and other ditros.
>>
>>> You were never supposed to update libavcodec without updating libavformat
>>> If you use libavformat in the first place.
>>> Your problems are completely gone.
>>
>> As i said, as far as i remember, you've been meant to do that just fine.
>> Hence so much work about reducing the amount of exposed internal API,
>> and plenty of preprocessor checks meant to remove unneeded avpriv
>> symbols only after a major bump.
> 
> Well, AFAIR it was not the case, and IMHO it does not really make sense to
> update libavcodec without libavformat.
> I think all that work could have been avoided by introducing an explicit check
> inside libavformat.
> It would also improve code-reuse and peace of mind, not worrying about 
> the ABI within the project.
> 
> I think a distinction should be made between breaking the ABI for the user
> and the ABI used within the project.  

I wouldn't be against it if it can be done right. But then there's also
libavdevice which is tied to libavformat, so ultimately you'd be locking
every single library to specific versions, and at that point, you'd be
better just merging everything into a single monolithic library called
libffmpeg.so, libav.so or whatever.

> 
>>>

>
>>
>> sps parsing can and should be done 

Re: [FFmpeg-devel] [PATCH 2/2] avformat/mxfenc: support XAVC long gop

2019-04-10 Thread Baptiste Coudurier
> On Apr 9, 2019, at 6:27 PM, James Almer  wrote:
> 
> On 4/9/2019 9:40 PM, Baptiste Coudurier wrote:
>> 
>>> On Apr 9, 2019, at 5:24 PM, James Almer  wrote:
>>> 
>>> On 4/9/2019 8:59 PM, Baptiste Coudurier wrote:
 
> On Apr 9, 2019, at 4:51 PM, James Almer  wrote:
> 
> On 4/9/2019 8:22 PM, Baptiste Coudurier wrote:
>> Hi James,
>> 
>>> On Apr 9, 2019, at 4:09 PM, James Almer  wrote:
>>> 
 […]
>>> 
>>> Ok so, the only fields you need from the sps are constraint_set_flags,
>>> frame_mbs_only_flag, bit_depth_luma, profile_idc, level_idc and sar,
>>> meaning you don't even need to parse the sps until the very end (sar is
>>> the furthest value, and right at the beginning of vui_parameters).
>>> I'd very much prefer if we can avoid making
>>> ff_h264_decode_seq_parameter_set() avpriv and with it H264ParamSets part
>>> of the ABI, so i think it's worth copying the required bitstream parsing
>>> code at least until the beginning of vui_parameters. It was done for
>>> hevc and av1, so it can be done for h264 as well.
>> 
>> Since vui parsing is needed, that would be the entire 
>> "ff_h264_decode_seq_parameter_set()” function.
> 
> If you only need up to sar, then yo don't need to parse the entire VUI.
 
 It still requires copying the entire ff_h264_decode_seq_parameter_set(), 
 even though the sub functions are not needed. 
 
>> 
>> I disagree with the copying. I also disagree with the copying for AVC1 
>> and HEVC btw.
> 
> Using avpriv opens a whole can of worms that will be unpredictable in
> the future. Just look at recent commits like
> f4ea930a119298c6110ee4e3d24219a66e27e230 that started storing previously
> skipped values. If hevc_pc was made avpriv for isombff/matroska muxing
> purposes and its structs part of the ABI, this wouldn't have been
> possible until a major bump.
 
 When did the sharing policy between avformat and avcodec (in the sense 
 avformat using avcodec) change ?
 It seems perfectly natural to me to have libavformat require the 
 libavcodec version that it was compiled with,
 and check it at runtime.
>>> 
>>> More than one ffmpeg release will ship with libavcodec/libavformat
>>> sharing the same soname. Backwards compatibility is expected, hence the
>>> split between major, minor and micro, as you're meant to be able to drop
>>> a newer libavcodec library, say for example ffmpeg 4.1's
>>> libavcodec.58.so, and it should work with an existing libavformat.so.58
>>> that was linked against ffmpeg 4.0's libavcodec.58.so.
>> 
>> Sorry to repeat the question but when did that change ?
> 
> I don't know if it ever changed to being with. It's been like this for
> as long as i remember, and i don't recall inter-library version checks
> that would take minor and micro into consideration (which would be
> needed to truly tie a given libavformat library with the exact
> libavcodec it was linked to) whereas ABI backwards compatibility
> considerations for inter-library stuff can be seen all across the
> codebase and git history.

It definitely changed, probably around the introduction of “avpriv” prefix.

>> Which practical use case are we covering here ?
> 
> I don't know, i'm not a library user. But i know the main use case for
> the longest time was having ffmpeg work as a drop in replacement for
> libav back when the latter was shipped in debian and other ditros.
> 
>> You were never supposed to update libavcodec without updating libavformat
>> If you use libavformat in the first place.
>> Your problems are completely gone.
> 
> As i said, as far as i remember, you've been meant to do that just fine.
> Hence so much work about reducing the amount of exposed internal API,
> and plenty of preprocessor checks meant to remove unneeded avpriv
> symbols only after a major bump.

Well, AFAIR it was not the case, and IMHO it does not really make sense to
update libavcodec without libavformat.
I think all that work could have been avoided by introducing an explicit check
inside libavformat.
It would also improve code-reuse and peace of mind, not worrying about 
the ABI within the project.

I think a distinction should be made between breaking the ABI for the user
and the ABI used within the project.  

>> 
>>> 
 
> 
> sps parsing can and should be done in libavformat for this. Otherwise
> you'll be constraining future development in other areas. So please,
> take libavcodec/cbs_h264* and libavformat/av1.c as basis and write a
> simple sps parser that takes the raw bitstream values and does nothing
> else. You only need six values.
 
 I disagree with the copying and we will need more opinions on this to 
 settle
 the argument, maybe a vote.
>>> 
>>> It's the cleanest way and the one used in all cases previous to this
>>> one.
>> 
>> We disagree here, there are at least 2 cleaner ways: 

Re: [FFmpeg-devel] [PATCH 2/2] avformat/mxfenc: support XAVC long gop

2019-04-10 Thread James Almer
On 4/10/2019 2:22 AM, Hendrik Leppkes wrote:
> On Wed, Apr 10, 2019 at 3:28 AM James Almer  wrote:
>>>
 Two thirds of SPS is not hard to implement, so i really don't understand
 why you're so adamantly against it.
>>>
>>> I’m adamant about re-using code between libavcodec and libavformat.
>>> Re-using code is _good_
>>
>> So lets do what i suggested in a previous email if re-implementing sps
>> in libavformat is not ok in your opinion: Add an
>> avpriv_h264_decode_seq_parameter_set() function that internally calls
>> ff_h264_decode_seq_parameter_set(), including proper AVBufferRef
>> cleaning at the end with a call to ff_h264_ps_uninit(), and that either
>> returns the six values using pointers parameters, or takes a pointer to
>> a new, small struct as parameter which will be allocated at runtime
>> (thus avoiding storing it on stack within libavformat, and tying to the
>> ABI) which contains at least those six values in question.
>> The reason i suggest a new small struct is to avoid using H264ParamSets
>> for this, which would imply direct access to ps->sps fields within
>> libavformat, and thus locking everything in its current offset.
>>
>> See how avpriv_ac3_parse_header() and av_ac3_parse_header() wrap
>> ff_ac3_parse_header() and each do either of the two options above.
> 
> As mentioned in another thread on this topic already, I agree with
> this. If you insist on re-use so strongly, then lets not cement more
> internal structs into the ABI, especially some that we worked on to
> get out of the ABI recently in the first place, and define a clean
> wrapper API that takes simple byte pointers as input and gives you a
> simplified public struct back.

I could agree to use H264ParamSets if as part of this set every single
SPS value defined in the latest version of the spec is added to "struct
SPS" and parsed by ff_h264_decode_seq_parameter_set() instead of being
discarded or stored exclusively in the AVCodecContext as it's the case
right now. The existing ones should also be double checked, seeing how i
just now found one with the wrong size (and sent a patch to fix it).
That way there will be nothing to expand in the future, and locking
fields to their current offset will not be an issue.
Ideally, the same would be done to "struct PPS", but as long as ps->pps
is not accessed from libavformat, it should be ok.

This of course will still need H264ParamSets to be allocated by the new
function to not let libavformat store it in stack, as its size must not
be part of the ABI, only the field's offsets. It would also require
ff_h264_ps_uninit to be made avpriv as it will need to be called from
outside the sps wrapper. So it's considerably a lot more work than just
using a new simple struct.

In all cases, be it a new simple struct or H264ParamSets, what must
absolutely not be used as a parameter is GetBitContext. Use instead a
data and size parameters, and allocate a GetBitContext context within
the wrapper.

> 
> - Hendrik
___
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 2/2] avformat/mxfenc: support XAVC long gop

2019-04-10 Thread Carl Eugen Hoyos
2019-04-10 2:40 GMT+02:00, Baptiste Coudurier :
>
>> On Apr 9, 2019, at 5:24 PM, James Almer  wrote:

>> More than one ffmpeg release will ship with libavcodec/libavformat
>> sharing the same soname. Backwards compatibility is expected, hence the
>> split between major, minor and micro, as you're meant to be able to drop
>> a newer libavcodec library, say for example ffmpeg 4.1's
>> libavcodec.58.so, and it should work with an existing libavformat.so.58
>> that was linked against ffmpeg 4.0's libavcodec.58.so.
>
> Sorry to repeat the question but when did that change ?
> Which practical use case are we covering here ?
> You were never supposed to update libavcodec without
> updating libavformat If you use libavformat in the first place.

While we have violated this before, we of course claim
compatibility, so this argument is not helpful, sorry.

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 2/2] avformat/mxfenc: support XAVC long gop

2019-04-10 Thread Thomas Mundt
Hi Baptiste,

Am Mi., 10. Apr. 2019 um 00:29 Uhr schrieb Baptiste Coudurier <
baptiste.coudur...@gmail.com>:

> Hi Thomas, I hope you are doing well
>
> > On Apr 4, 2019, at 7:27 AM, Thomas Mundt  wrote:
> >
> > Hi Baptiste,
> >
> > […]
> > For RP2027 Class 100 1080/50i I still get the error: frame size does not
> > match index unit size, 568832 != 0
> > I used the following command:
> > ffmpeg -f lavfi -i testsrc=size=1920x1080:rate=50 -vf interlace -c:v
> > libx264 -pix_fmt yuv422p10 -flags +ildct+ilme -avcintra-class 100
> > -color_primaries bt709 -color_trc bt709 -colorspace bt709 -x264-params
> >
> overscan="crop":videoformat="component":fps=25/1:interlaced=1:tff=1:force-cfr=1
> > -t 1 avci.mxf
>
> I see, that’s the switch to CBR index.
>

Works with you latest patch.


> > Also I encoded AVC High 422 Intra with the following command:
> > ffmpeg lavfi -i testsrc=size=1920x1080:rate=50 -c:v libx264 -pix_fmt
> > yuv422p -x264-params keyint=1 -t 1 avc.mxf
> > Without your patch MediaInfo shows Format profile: High 4:2:2 Intra@L4.2.
> > With your patch MediaInfo shows Format profile: High 4:2:2@L4.2 and
> > Format_Profile_Original: High 4:2:2 Intra@L4.2.
> > According to the MediaInfo documentation, the additional
> > "Format_Profile_Original" is shown when two format profile infomations
> are
> > found that do not match.
> >
>
> Muxer uses ….32.30.01 UID which is High 422 Intra according to specs:
>
> urn:smpte:ul:060e2b34.0401010a.04010202.01323001LEAF
> H.264/MPEG-4 AVC High 422 Intra Profile Unconstrained CodingIdentifies
> H.264/MPEG-4 AVC High 422 Intra Profile Unconstrained Coding
>
> So I’m not sure what media info is doing here.
>

I looked a little deeper into MediaInfo code. If the avc subdescriptor is
used, MediaInfo expects that in addition to profile and level, the profile
constraint is also set for intra coding.
Other MXF muxer, e.g. bmxlib, also set the profile constraint in the avc
subdescriptor.

Regards,
Thomas
___
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 2/2] avformat/mxfenc: support XAVC long gop

2019-04-09 Thread Hendrik Leppkes
On Wed, Apr 10, 2019 at 3:28 AM James Almer  wrote:
> >
> >> Two thirds of SPS is not hard to implement, so i really don't understand
> >> why you're so adamantly against it.
> >
> > I’m adamant about re-using code between libavcodec and libavformat.
> > Re-using code is _good_
>
> So lets do what i suggested in a previous email if re-implementing sps
> in libavformat is not ok in your opinion: Add an
> avpriv_h264_decode_seq_parameter_set() function that internally calls
> ff_h264_decode_seq_parameter_set(), including proper AVBufferRef
> cleaning at the end with a call to ff_h264_ps_uninit(), and that either
> returns the six values using pointers parameters, or takes a pointer to
> a new, small struct as parameter which will be allocated at runtime
> (thus avoiding storing it on stack within libavformat, and tying to the
> ABI) which contains at least those six values in question.
> The reason i suggest a new small struct is to avoid using H264ParamSets
> for this, which would imply direct access to ps->sps fields within
> libavformat, and thus locking everything in its current offset.
>
> See how avpriv_ac3_parse_header() and av_ac3_parse_header() wrap
> ff_ac3_parse_header() and each do either of the two options above.

As mentioned in another thread on this topic already, I agree with
this. If you insist on re-use so strongly, then lets not cement more
internal structs into the ABI, especially some that we worked on to
get out of the ABI recently in the first place, and define a clean
wrapper API that takes simple byte pointers as input and gives you a
simplified public struct back.

- Hendrik
___
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 2/2] avformat/mxfenc: support XAVC long gop

2019-04-09 Thread James Almer
On 4/9/2019 9:40 PM, Baptiste Coudurier wrote:
> 
>> On Apr 9, 2019, at 5:24 PM, James Almer  wrote:
>>
>> On 4/9/2019 8:59 PM, Baptiste Coudurier wrote:
>>>
 On Apr 9, 2019, at 4:51 PM, James Almer  wrote:

 On 4/9/2019 8:22 PM, Baptiste Coudurier wrote:
> Hi James,
>
>> On Apr 9, 2019, at 4:09 PM, James Almer  wrote:
>>
>>> […]
>>
>> Ok so, the only fields you need from the sps are constraint_set_flags,
>> frame_mbs_only_flag, bit_depth_luma, profile_idc, level_idc and sar,
>> meaning you don't even need to parse the sps until the very end (sar is
>> the furthest value, and right at the beginning of vui_parameters).
>> I'd very much prefer if we can avoid making
>> ff_h264_decode_seq_parameter_set() avpriv and with it H264ParamSets part
>> of the ABI, so i think it's worth copying the required bitstream parsing
>> code at least until the beginning of vui_parameters. It was done for
>> hevc and av1, so it can be done for h264 as well.
>
> Since vui parsing is needed, that would be the entire 
> "ff_h264_decode_seq_parameter_set()” function.

 If you only need up to sar, then yo don't need to parse the entire VUI.
>>>
>>> It still requires copying the entire ff_h264_decode_seq_parameter_set(), 
>>> even though the sub functions are not needed. 
>>>
>
> I disagree with the copying. I also disagree with the copying for AVC1 
> and HEVC btw.

 Using avpriv opens a whole can of worms that will be unpredictable in
 the future. Just look at recent commits like
 f4ea930a119298c6110ee4e3d24219a66e27e230 that started storing previously
 skipped values. If hevc_pc was made avpriv for isombff/matroska muxing
 purposes and its structs part of the ABI, this wouldn't have been
 possible until a major bump.
>>>
>>> When did the sharing policy between avformat and avcodec (in the sense 
>>> avformat using avcodec) change ?
>>> It seems perfectly natural to me to have libavformat require the libavcodec 
>>> version that it was compiled with,
>>> and check it at runtime.
>>
>> More than one ffmpeg release will ship with libavcodec/libavformat
>> sharing the same soname. Backwards compatibility is expected, hence the
>> split between major, minor and micro, as you're meant to be able to drop
>> a newer libavcodec library, say for example ffmpeg 4.1's
>> libavcodec.58.so, and it should work with an existing libavformat.so.58
>> that was linked against ffmpeg 4.0's libavcodec.58.so.
> 
> Sorry to repeat the question but when did that change ?

I don't know if it ever changed to being with. It's been like this for
as long as i remember, and i don't recall inter-library version checks
that would take minor and micro into consideration (which would be
needed to truly tie a given libavformat library with the exact
libavcodec it was linked to) whereas ABI backwards compatibility
considerations for inter-library stuff can be seen all across the
codebase and git history.

> Which practical use case are we covering here ?

I don't know, i'm not a library user. But i know the main use case for
the longest time was having ffmpeg work as a drop in replacement for
libav back when the latter was shipped in debian and other ditros.

> You were never supposed to update libavcodec without updating libavformat
> If you use libavformat in the first place.
> Your problems are completely gone.

As i said, as far as i remember, you've been meant to do that just fine.
Hence so much work about reducing the amount of exposed internal API,
and plenty of preprocessor checks meant to remove unneeded avpriv
symbols only after a major bump.

> 
>>
>>>

 sps parsing can and should be done in libavformat for this. Otherwise
 you'll be constraining future development in other areas. So please,
 take libavcodec/cbs_h264* and libavformat/av1.c as basis and write a
 simple sps parser that takes the raw bitstream values and does nothing
 else. You only need six values.
>>>
>>> I disagree with the copying and we will need more opinions on this to settle
>>> the argument, maybe a vote.
>>
>> It's the cleanest way and the one used in all cases previous to this
>> one.
> 
> We disagree here, there are at least 2 cleaner ways: not using AVCodecContext 
> at all
> in sps parsing or forcing libavcodec version.

You'd still be making GetBitContext part of the ABI with the former option.

> 
>> There has been work during the last bump to remove internal structs
>> from the ABI precisely because they constrained development. Among them
>> was GetBitsContext, which you're now trying to reintroduce and thus
>> invalidate all that previous cleaning work, and only to get six values
>> for a single muxer.
> 
> Adding fields are the end of structs does not break ABI, it’s been done for 
> decades in FFmpeg.

Only for structs which size is not part of the ABI, and thus can't be
stored on stack. That means those allocated 

Re: [FFmpeg-devel] [PATCH 2/2] avformat/mxfenc: support XAVC long gop

2019-04-09 Thread Baptiste Coudurier

> On Apr 9, 2019, at 5:24 PM, James Almer  wrote:
> 
> On 4/9/2019 8:59 PM, Baptiste Coudurier wrote:
>> 
>>> On Apr 9, 2019, at 4:51 PM, James Almer  wrote:
>>> 
>>> On 4/9/2019 8:22 PM, Baptiste Coudurier wrote:
 Hi James,
 
> On Apr 9, 2019, at 4:09 PM, James Almer  wrote:
> 
>> […]
> 
> Ok so, the only fields you need from the sps are constraint_set_flags,
> frame_mbs_only_flag, bit_depth_luma, profile_idc, level_idc and sar,
> meaning you don't even need to parse the sps until the very end (sar is
> the furthest value, and right at the beginning of vui_parameters).
> I'd very much prefer if we can avoid making
> ff_h264_decode_seq_parameter_set() avpriv and with it H264ParamSets part
> of the ABI, so i think it's worth copying the required bitstream parsing
> code at least until the beginning of vui_parameters. It was done for
> hevc and av1, so it can be done for h264 as well.
 
 Since vui parsing is needed, that would be the entire 
 "ff_h264_decode_seq_parameter_set()” function.
>>> 
>>> If you only need up to sar, then yo don't need to parse the entire VUI.
>> 
>> It still requires copying the entire ff_h264_decode_seq_parameter_set(), 
>> even though the sub functions are not needed. 
>> 
 
 I disagree with the copying. I also disagree with the copying for AVC1 and 
 HEVC btw.
>>> 
>>> Using avpriv opens a whole can of worms that will be unpredictable in
>>> the future. Just look at recent commits like
>>> f4ea930a119298c6110ee4e3d24219a66e27e230 that started storing previously
>>> skipped values. If hevc_pc was made avpriv for isombff/matroska muxing
>>> purposes and its structs part of the ABI, this wouldn't have been
>>> possible until a major bump.
>> 
>> When did the sharing policy between avformat and avcodec (in the sense 
>> avformat using avcodec) change ?
>> It seems perfectly natural to me to have libavformat require the libavcodec 
>> version that it was compiled with,
>> and check it at runtime.
> 
> More than one ffmpeg release will ship with libavcodec/libavformat
> sharing the same soname. Backwards compatibility is expected, hence the
> split between major, minor and micro, as you're meant to be able to drop
> a newer libavcodec library, say for example ffmpeg 4.1's
> libavcodec.58.so, and it should work with an existing libavformat.so.58
> that was linked against ffmpeg 4.0's libavcodec.58.so.

Sorry to repeat the question but when did that change ?
Which practical use case are we covering here ?
You were never supposed to update libavcodec without updating libavformat
If you use libavformat in the first place.
Your problems are completely gone.

> 
>> 
>>> 
>>> sps parsing can and should be done in libavformat for this. Otherwise
>>> you'll be constraining future development in other areas. So please,
>>> take libavcodec/cbs_h264* and libavformat/av1.c as basis and write a
>>> simple sps parser that takes the raw bitstream values and does nothing
>>> else. You only need six values.
>> 
>> I disagree with the copying and we will need more opinions on this to settle
>> the argument, maybe a vote.
> 
> It's the cleanest way and the one used in all cases previous to this
> one.

We disagree here, there are at least 2 cleaner ways: not using AVCodecContext 
at all
in sps parsing or forcing libavcodec version.

> There has been work during the last bump to remove internal structs
> from the ABI precisely because they constrained development. Among them
> was GetBitsContext, which you're now trying to reintroduce and thus
> invalidate all that previous cleaning work, and only to get six values
> for a single muxer.

Adding fields are the end of structs does not break ABI, it’s been done for 
decades in FFmpeg.
Also looking at h264_ps.h:

[…]
int residual_color_transform_flag;///< residual_colour_transform_flag
int constraint_set_flags; ///< constraint_set[0-3]_flag
uint8_t data[4096];
size_t data_size;

Why are we wasting 4k here ? I’m trying to trace git logs but it seems to be 
originating
from a merge commit.

> Two thirds of SPS is not hard to implement, so i really don't understand
> why you're so adamantly against it.

I’m adamant about re-using code between libavcodec and libavformat.
Re-using code is _good_

— 
Baptiste

___
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 2/2] avformat/mxfenc: support XAVC long gop

2019-04-09 Thread James Almer
On 4/9/2019 8:59 PM, Baptiste Coudurier wrote:
> 
>> On Apr 9, 2019, at 4:51 PM, James Almer  wrote:
>>
>> On 4/9/2019 8:22 PM, Baptiste Coudurier wrote:
>>> Hi James,
>>>
 On Apr 9, 2019, at 4:09 PM, James Almer  wrote:

> […]

 Ok so, the only fields you need from the sps are constraint_set_flags,
 frame_mbs_only_flag, bit_depth_luma, profile_idc, level_idc and sar,
 meaning you don't even need to parse the sps until the very end (sar is
 the furthest value, and right at the beginning of vui_parameters).
 I'd very much prefer if we can avoid making
 ff_h264_decode_seq_parameter_set() avpriv and with it H264ParamSets part
 of the ABI, so i think it's worth copying the required bitstream parsing
 code at least until the beginning of vui_parameters. It was done for
 hevc and av1, so it can be done for h264 as well.
>>>
>>> Since vui parsing is needed, that would be the entire 
>>> "ff_h264_decode_seq_parameter_set()” function.
>>
>> If you only need up to sar, then yo don't need to parse the entire VUI.
> 
> It still requires copying the entire ff_h264_decode_seq_parameter_set(), even 
> though the sub functions are not needed. 
> 
>>>
>>> I disagree with the copying. I also disagree with the copying for AVC1 and 
>>> HEVC btw.
>>
>> Using avpriv opens a whole can of worms that will be unpredictable in
>> the future. Just look at recent commits like
>> f4ea930a119298c6110ee4e3d24219a66e27e230 that started storing previously
>> skipped values. If hevc_pc was made avpriv for isombff/matroska muxing
>> purposes and its structs part of the ABI, this wouldn't have been
>> possible until a major bump.
> 
> When did the sharing policy between avformat and avcodec (in the sense 
> avformat using avcodec) change ?
> It seems perfectly natural to me to have libavformat require the libavcodec 
> version that it was compiled with,
> and check it at runtime.

More than one ffmpeg release will ship with libavcodec/libavformat
sharing the same soname. Backwards compatibility is expected, hence the
split between major, minor and micro, as you're meant to be able to drop
a newer libavcodec library, say for example ffmpeg 4.1's
libavcodec.58.so, and it should work with an existing libavformat.so.58
that was linked against ffmpeg 4.0's libavcodec.58.so.

> 
>>
>> sps parsing can and should be done in libavformat for this. Otherwise
>> you'll be constraining future development in other areas. So please,
>> take libavcodec/cbs_h264* and libavformat/av1.c as basis and write a
>> simple sps parser that takes the raw bitstream values and does nothing
>> else. You only need six values.
> 
> I disagree with the copying and we will need more opinions on this to settle
> the argument, maybe a vote.

It's the cleanest way and the one used in all cases previous to this
one. There has been work during the last bump to remove internal structs
from the ABI precisely because they constrained development. Among them
was GetBitsContext, which you're now trying to reintroduce and thus
invalidate all that previous cleaning work, and only to get six values
for a single muxer.

Two thirds of SPS is not hard to implement, so i really don't understand
why you're so adamantly against it.

> 
> — 
> Baptiste
> 
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
> 

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

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

Re: [FFmpeg-devel] [PATCH 2/2] avformat/mxfenc: support XAVC long gop

2019-04-09 Thread Baptiste Coudurier

> On Apr 9, 2019, at 4:51 PM, James Almer  wrote:
> 
> On 4/9/2019 8:22 PM, Baptiste Coudurier wrote:
>> Hi James,
>> 
>>> On Apr 9, 2019, at 4:09 PM, James Almer  wrote:
>>> 
 […]
>>> 
>>> Ok so, the only fields you need from the sps are constraint_set_flags,
>>> frame_mbs_only_flag, bit_depth_luma, profile_idc, level_idc and sar,
>>> meaning you don't even need to parse the sps until the very end (sar is
>>> the furthest value, and right at the beginning of vui_parameters).
>>> I'd very much prefer if we can avoid making
>>> ff_h264_decode_seq_parameter_set() avpriv and with it H264ParamSets part
>>> of the ABI, so i think it's worth copying the required bitstream parsing
>>> code at least until the beginning of vui_parameters. It was done for
>>> hevc and av1, so it can be done for h264 as well.
>> 
>> Since vui parsing is needed, that would be the entire 
>> "ff_h264_decode_seq_parameter_set()” function.
> 
> If you only need up to sar, then yo don't need to parse the entire VUI.

It still requires copying the entire ff_h264_decode_seq_parameter_set(), even 
though the sub functions are not needed. 

>> 
>> I disagree with the copying. I also disagree with the copying for AVC1 and 
>> HEVC btw.
> 
> Using avpriv opens a whole can of worms that will be unpredictable in
> the future. Just look at recent commits like
> f4ea930a119298c6110ee4e3d24219a66e27e230 that started storing previously
> skipped values. If hevc_pc was made avpriv for isombff/matroska muxing
> purposes and its structs part of the ABI, this wouldn't have been
> possible until a major bump.

When did the sharing policy between avformat and avcodec (in the sense avformat 
using avcodec) change ?
It seems perfectly natural to me to have libavformat require the libavcodec 
version that it was compiled with,
and check it at runtime.

> 
> sps parsing can and should be done in libavformat for this. Otherwise
> you'll be constraining future development in other areas. So please,
> take libavcodec/cbs_h264* and libavformat/av1.c as basis and write a
> simple sps parser that takes the raw bitstream values and does nothing
> else. You only need six values.

I disagree with the copying and we will need more opinions on this to settle
the argument, maybe a vote.

— 
Baptiste

___
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 2/2] avformat/mxfenc: support XAVC long gop

2019-04-09 Thread James Almer
On 4/9/2019 8:22 PM, Baptiste Coudurier wrote:
> Hi James,
> 
>> On Apr 9, 2019, at 4:09 PM, James Almer  wrote:
>>
>>> […]
>>
>> Ok so, the only fields you need from the sps are constraint_set_flags,
>> frame_mbs_only_flag, bit_depth_luma, profile_idc, level_idc and sar,
>> meaning you don't even need to parse the sps until the very end (sar is
>> the furthest value, and right at the beginning of vui_parameters).
>> I'd very much prefer if we can avoid making
>> ff_h264_decode_seq_parameter_set() avpriv and with it H264ParamSets part
>> of the ABI, so i think it's worth copying the required bitstream parsing
>> code at least until the beginning of vui_parameters. It was done for
>> hevc and av1, so it can be done for h264 as well.
> 
> Since vui parsing is needed, that would be the entire 
> "ff_h264_decode_seq_parameter_set()” function.

If you only need up to sar, then yo don't need to parse the entire VUI.

> 
> I disagree with the copying. I also disagree with the copying for AVC1 and 
> HEVC btw.

Using avpriv opens a whole can of worms that will be unpredictable in
the future. Just look at recent commits like
f4ea930a119298c6110ee4e3d24219a66e27e230 that started storing previously
skipped values. If hevc_pc was made avpriv for isombff/matroska muxing
purposes and its structs part of the ABI, this wouldn't have been
possible until a major bump.

sps parsing can and should be done in libavformat for this. Otherwise
you'll be constraining future development in other areas. So please,
take libavcodec/cbs_h264* and libavformat/av1.c as basis and write a
simple sps parser that takes the raw bitstream values and does nothing
else. You only need six values.

> 
> — 
> Baptiste
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
> 

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

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

Re: [FFmpeg-devel] [PATCH 2/2] avformat/mxfenc: support XAVC long gop

2019-04-09 Thread Baptiste Coudurier
> On Apr 9, 2019, at 4:05 PM, Hendrik Leppkes  wrote:
> 
> On Wed, Apr 10, 2019 at 12:21 AM Baptiste Coudurier
>  wrote:
>> +return 0;
>> +}
>> +init_get_bits(, tmp, tmp_size*8);
>> +ret = avpriv_h264_decode_seq_parameter_set(, 
>> (AVCodecContext*)s, , 0);
> 
> The AVCodecContext cast looks like a recipe for disaster. The function
> is internal to the H264 decoder, so if it at some point decides to
> actually access the AVCodecContext it receives, or even worse, the
> priv_data element in it, expecting a H264Context, then everything goes
> to hell.
> Just another sign why exporting functions internal from a decoder is
> just an overall bad idea…

Calm down. AVCodecContext can be allocated in any case, for AV_CODEC_ID_H264.
The reason that function needs it in the first place is small.

Re-using code is _good_

— 
Baptiste

___
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 2/2] avformat/mxfenc: support XAVC long gop

2019-04-09 Thread Baptiste Coudurier
Hi James,

> On Apr 9, 2019, at 4:09 PM, James Almer  wrote:
> 
>> […]
> 
> Ok so, the only fields you need from the sps are constraint_set_flags,
> frame_mbs_only_flag, bit_depth_luma, profile_idc, level_idc and sar,
> meaning you don't even need to parse the sps until the very end (sar is
> the furthest value, and right at the beginning of vui_parameters).
> I'd very much prefer if we can avoid making
> ff_h264_decode_seq_parameter_set() avpriv and with it H264ParamSets part
> of the ABI, so i think it's worth copying the required bitstream parsing
> code at least until the beginning of vui_parameters. It was done for
> hevc and av1, so it can be done for h264 as well.

Since vui parsing is needed, that would be the entire 
"ff_h264_decode_seq_parameter_set()” function.

I disagree with the copying. I also disagree with the copying for AVC1 and HEVC 
btw.

— 
Baptiste
___
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 2/2] avformat/mxfenc: support XAVC long gop

2019-04-09 Thread James Almer
On 4/9/2019 7:14 PM, Baptiste Coudurier wrote:
> ---
>  libavformat/Makefile |   2 +-
>  libavformat/avc.c|  32 +++
>  libavformat/avc.h|   2 +
>  libavformat/hevc.c   |  36 +---
>  libavformat/mxf.h|   1 +
>  libavformat/mxfenc.c | 201 +--
>  6 files changed, 193 insertions(+), 81 deletions(-)
> 
> diff --git a/libavformat/Makefile b/libavformat/Makefile
> index c010fc83f9..f8539527bc 100644
> --- a/libavformat/Makefile
> +++ b/libavformat/Makefile
> @@ -338,7 +338,7 @@ OBJS-$(CONFIG_MUSX_DEMUXER)  += musx.o
>  OBJS-$(CONFIG_MV_DEMUXER)+= mvdec.o
>  OBJS-$(CONFIG_MVI_DEMUXER)   += mvi.o
>  OBJS-$(CONFIG_MXF_DEMUXER)   += mxfdec.o mxf.o
> -OBJS-$(CONFIG_MXF_MUXER) += mxfenc.o mxf.o audiointerleave.o
> +OBJS-$(CONFIG_MXF_MUXER) += mxfenc.o mxf.o audiointerleave.o 
> avc.o
>  OBJS-$(CONFIG_MXG_DEMUXER)   += mxg.o
>  OBJS-$(CONFIG_NC_DEMUXER)+= ncdec.o
>  OBJS-$(CONFIG_NISTSPHERE_DEMUXER)+= nistspheredec.o pcm.o
> diff --git a/libavformat/avc.c b/libavformat/avc.c
> index ec50033a04..6c97ae04ab 100644
> --- a/libavformat/avc.c
> +++ b/libavformat/avc.c
> @@ -241,3 +241,35 @@ const uint8_t *ff_avc_mp4_find_startcode(const uint8_t 
> *start,
>  
>  return start + res;
>  }
> +
> +uint8_t *ff_nal_unit_extract_rbsp(const uint8_t *src, uint32_t src_len,
> +  uint32_t *dst_len, int header_len)

Nit: Might be a good chance to make src_len and dst_len size_t.

> +{
> +uint8_t *dst;
> +uint32_t i, len;
> +
> +dst = av_malloc(src_len + AV_INPUT_BUFFER_PADDING_SIZE);
> +if (!dst)
> +return NULL;
> +
> +/* NAL unit header */
> +i = len = 0;
> +while (i < header_len && i < src_len)
> +dst[len++] = src[i++];
> +
> +while (i + 2 < src_len)
> +if (!src[i] && !src[i + 1] && src[i + 2] == 3) {
> +dst[len++] = src[i++];
> +dst[len++] = src[i++];
> +i++; // remove emulation_prevention_three_byte
> +} else
> +dst[len++] = src[i++];
> +
> +while (i < src_len)
> +dst[len++] = src[i++];
> +
> +memset(dst + len, 0, AV_INPUT_BUFFER_PADDING_SIZE);
> +
> +*dst_len = len;
> +return dst;
> +}

[...]

> @@ -2168,37 +2227,81 @@ static int mxf_parse_h264_frame(AVFormatContext *s, 
> AVStream *st,
>  {
>  MXFContext *mxf = s->priv_data;
>  MXFStreamContext *sc = st->priv_data;
> -AVCodecParameters *par = st->codecpar;
> -static const int mxf_h264_num_codec_uls = sizeof(mxf_h264_codec_uls) / 
> sizeof(mxf_h264_codec_uls[0]);
> +H264ParamSets ps = { { 0 } };
> +GetBitContext gb;
>  const uint8_t *buf = pkt->data;
>  const uint8_t *buf_end = pkt->data + pkt->size;
> +const uint8_t *tmp, *nal_end;
>  uint32_t state = -1;
> -int long_gop = 0; // assume intra when there is no SPS header
>  int extra_size = 512; // support AVC Intra files without SPS/PPS header
> -int i, frame_size;
> -uint8_t uid_found;
> -
> -if (pkt->size > extra_size)
> -buf_end -= pkt->size - extra_size; // no need to parse beyond 
> SPS/PPS header
> +int i, j, tmp_size, frame_size, ret, slice_type, intra_only = 0;
>  
>  for (;;) {
>  buf = avpriv_find_start_code(buf, buf_end, );
>  if (buf >= buf_end)
>  break;
> ---buf;
> +
>  switch (state & 0x1f) {
>  case H264_NAL_SPS:
> -par->profile = buf[1];
> -long_gop = buf[2] & 0x10 ? 0 : 1; // constraint_set3_flag 
> signals intra
>  e->flags |= 0x40;
> -break;
> +
> +if (ps.sps != NULL)
> +break;
> +
> +nal_end = ff_avc_find_startcode(buf, buf_end);
> +tmp = ff_nal_unit_extract_rbsp(buf, nal_end - buf, _size, 0);
> +if (!buf) {
> +av_log(s, AV_LOG_ERROR, "error extracting rbsp\n");
> +return 0;
> +}
> +init_get_bits(, tmp, tmp_size*8);
> +ret = avpriv_h264_decode_seq_parameter_set(, 
> (AVCodecContext*)s, , 0);
> +av_freep();
> +if (ret < 0)
> +return 0;
> +for (j = 0; j < MAX_SPS_COUNT; j++) {
> +if (ps.sps_list[j] != NULL) {
> +ps.sps = (SPS*)ps.sps_list[j]->data;
> +break;
> +}
> +}
> +
> +sc->aspect_ratio.num = st->codecpar->width * ps.sps->sar.num;
> +sc->aspect_ratio.den = st->codecpar->height * ps.sps->sar.den;
> +av_reduce(>aspect_ratio.num, >aspect_ratio.den,
> +  sc->aspect_ratio.num, sc->aspect_ratio.den, 1024*1024);
> +intra_only = (ps.sps->constraint_set_flags >> 3) & 1;
> +sc->interlaced = !ps.sps->frame_mbs_only_flag;
> +sc->component_depth = 

Re: [FFmpeg-devel] [PATCH 2/2] avformat/mxfenc: support XAVC long gop

2019-04-09 Thread Hendrik Leppkes
On Wed, Apr 10, 2019 at 12:21 AM Baptiste Coudurier
 wrote:
> +return 0;
> +}
> +init_get_bits(, tmp, tmp_size*8);
> +ret = avpriv_h264_decode_seq_parameter_set(, 
> (AVCodecContext*)s, , 0);

The AVCodecContext cast looks like a recipe for disaster. The function
is internal to the H264 decoder, so if it at some point decides to
actually access the AVCodecContext it receives, or even worse, the
priv_data element in it, expecting a H264Context, then everything goes
to hell.
Just another sign why exporting functions internal from a decoder is
just an overall bad idea...

- Hendrik
___
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 2/2] avformat/mxfenc: support XAVC long gop

2019-04-09 Thread Baptiste Coudurier
Hi Thomas, I hope you are doing well

> On Apr 4, 2019, at 7:27 AM, Thomas Mundt  wrote:
> 
> Hi Baptiste,
> 
> […]
> For RP2027 Class 100 1080/50i I still get the error: frame size does not
> match index unit size, 568832 != 0
> I used the following command:
> ffmpeg -f lavfi -i testsrc=size=1920x1080:rate=50 -vf interlace -c:v
> libx264 -pix_fmt yuv422p10 -flags +ildct+ilme -avcintra-class 100
> -color_primaries bt709 -color_trc bt709 -colorspace bt709 -x264-params
> overscan="crop":videoformat="component":fps=25/1:interlaced=1:tff=1:force-cfr=1
> -t 1 avci.mxf

I see, that’s the switch to CBR index.

> Also I encoded AVC High 422 Intra with the following command:
> ffmpeg lavfi -i testsrc=size=1920x1080:rate=50 -c:v libx264 -pix_fmt
> yuv422p -x264-params keyint=1 -t 1 avc.mxf
> Without your patch MediaInfo shows Format profile: High 4:2:2 Intra@L4.2.
> With your patch MediaInfo shows Format profile: High 4:2:2@L4.2 and
> Format_Profile_Original: High 4:2:2 Intra@L4.2.
> According to the MediaInfo documentation, the additional
> "Format_Profile_Original" is shown when two format profile infomations are
> found that do not match.
> 

Muxer uses ….32.30.01 UID which is High 422 Intra according to specs:

urn:smpte:ul:060e2b34.0401010a.04010202.01323001LEAFH.264/MPEG-4 
AVC High 422 Intra Profile Unconstrained CodingIdentifies H.264/MPEG-4 AVC 
High 422 Intra Profile Unconstrained Coding

So I’m not sure what media info is doing here.

— 
Baptiste

___
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 2/2] avformat/mxfenc: support XAVC long gop

2019-04-04 Thread Thomas Mundt
Hi Baptiste,

Am Mi., 3. Apr. 2019 um 11:23 Uhr schrieb Baptiste Coudurier <
baptiste.coudur...@gmail.com>:

> ---
>  libavformat/mxf.h|   1 +
>  libavformat/mxfenc.c | 197 ---
>  2 files changed, 147 insertions(+), 51 deletions(-)
>
> diff --git a/libavformat/mxf.h b/libavformat/mxf.h
> index 4394450dea..f32124f772 100644
> --- a/libavformat/mxf.h
> +++ b/libavformat/mxf.h
> @@ -48,6 +48,7 @@ enum MXFMetadataSetType {
>  EssenceGroup,
>  TaggedValue,
>  TapeDescriptor,
> +AVCSubDescriptor,
>  };
>
>  enum MXFFrameLayout {
> diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c
> index 8c6db94865..1f865a0ad1 100644
> --- a/libavformat/mxfenc.c
> +++ b/libavformat/mxfenc.c
> @@ -49,7 +49,10 @@
>  #include "libavcodec/bytestream.h"
>  #include "libavcodec/dnxhddata.h"
>  #include "libavcodec/dv_profile.h"
> -#include "libavcodec/h264.h"
> +#include "libavcodec/golomb.h"
> +#include "libavcodec/h264data.h"
> +#include "libavcodec/h264_ps.h"
> +#include "libavcodec/h2645_parse.h"
>  #include "libavcodec/internal.h"
>  #include "audiointerleave.h"
>  #include "avformat.h"
> @@ -99,6 +102,7 @@ typedef struct MXFStreamContext {
>  int max_gop; ///< maximum gop size, used by mpeg-2
> descriptor
>  int b_picture_count; ///< maximum number of consecutive b
> pictures, used in mpeg-2 descriptor
>  int low_delay;   ///< low delay, used in mpeg-2 descriptor
> +int avc_intra;
>  } MXFStreamContext;
>
>  typedef struct MXFContainerEssenceEntry {
> @@ -167,6 +171,7 @@ static const struct {
>  static void mxf_write_wav_desc(AVFormatContext *s, AVStream *st);
>  static void mxf_write_aes3_desc(AVFormatContext *s, AVStream *st);
>  static void mxf_write_mpegvideo_desc(AVFormatContext *s, AVStream *st);
> +static void mxf_write_h264_desc(AVFormatContext *s, AVStream *st);
>  static void mxf_write_cdci_desc(AVFormatContext *s, AVStream *st);
>  static void mxf_write_generic_sound_desc(AVFormatContext *s, AVStream
> *st);
>  static void mxf_write_s436m_anc_desc(AVFormatContext *s, AVStream *st);
> @@ -310,7 +315,7 @@ static const MXFContainerEssenceEntry
> mxf_essence_container_uls[] = {
>  { {
> 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x0a,0x0D,0x01,0x03,0x01,0x02,0x10,0x60,0x01
> },
>{
> 0x06,0x0E,0x2B,0x34,0x01,0x02,0x01,0x01,0x0D,0x01,0x03,0x01,0x15,0x01,0x05,0x00
> },
>{
> 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x0a,0x04,0x01,0x02,0x02,0x01,0x00,0x00,0x00
> },
> -  mxf_write_mpegvideo_desc },
> +  mxf_write_h264_desc },
>  // S436M ANC
>  { {
> 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x0a,0x0D,0x01,0x03,0x01,0x02,0x0e,0x00,0x00
> },
>{
> 0x06,0x0E,0x2B,0x34,0x01,0x02,0x01,0x01,0x0D,0x01,0x03,0x01,0x17,0x01,0x02,0x00
> },
> @@ -498,6 +503,12 @@ static const MXFLocalTagPair mxf_local_tag_batch[] = {
>  { 0x8006,
> {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x05,0x04,0x01,0x06,0x02,0x01,0x08,0x00,0x00}},
> /* MaxGOP */
>  { 0x8007,
> {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x05,0x04,0x01,0x06,0x02,0x01,0x0A,0x00,0x00}},
> /* ProfileAndLevel */
>  { 0x8008,
> {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x05,0x04,0x01,0x06,0x02,0x01,0x09,0x00,0x00}},
> /* BPictureCount */
> +// Generic Descriptor
> +{ 0x8100,
> {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x09,0x06,0x01,0x01,0x04,0x06,0x10,0x00,0x00}},
> /* SubDescriptors */
> +// AVC SubDescriptor
> +{ 0x8200,
> {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x0E,0x04,0x01,0x06,0x06,0x01,0x0E,0x00,0x00}},
> /* AVC Decoding Delay */
> +{ 0x8201,
> {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x0E,0x04,0x01,0x06,0x06,0x01,0x0A,0x00,0x00}},
> /* AVC Profile */
> +{ 0x8202,
> {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x0E,0x04,0x01,0x06,0x06,0x01,0x0D,0x00,0x00}},
> /* AVC Level */
>  // Wave Audio Essence Descriptor
>  { 0x3D09,
> {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x05,0x04,0x02,0x03,0x03,0x05,0x00,0x00,0x00}},
> /* Average Bytes Per Second */
>  { 0x3D0A,
> {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x05,0x04,0x02,0x03,0x02,0x01,0x00,0x00,0x00}},
> /* Block Align */
> @@ -1126,6 +1137,8 @@ static const UID mxf_aes3_descriptor_key  = {
> 0x06,0x0E,0x2B,0x34,0x02,0x53,
>  static const UID mxf_cdci_descriptor_key  = {
> 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0D,0x01,0x01,0x01,0x01,0x01,0x28,0x00
> };
>  static const UID mxf_generic_sound_descriptor_key = {
> 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0D,0x01,0x01,0x01,0x01,0x01,0x42,0x00
> };
>
> +static const UID mxf_avc_subdescriptor_key = {
> 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x6E,0x00
> };
> +
>  static int get_trc(UID ul, enum AVColorTransferCharacteristic trc)
>  {
>  switch (trc){
> @@ -1317,6 +1330,13 @@ static int64_t
> mxf_write_cdci_common(AVFormatContext *s, AVStream *st, const UID
>  avio_w8(pb, sc->field_dominance);
>  }
>
> +if (st->codecpar->codec_id == AV_CODEC_ID_H264 && !sc->avc_intra) {
> +// write avc sub descriptor