Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Jerome Martinez <jerome@mediaarea.net>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Subject: Re: [FFmpeg-devel] [PATCH v2] avcodec/jpeg2000dec: support of 2 fields in 1 AVPacket
Date: Wed, 21 Feb 2024 15:27:30 +0100
Message-ID: <f25f1e3a-5646-4e42-89af-94b01fb54b5e@mediaarea.net> (raw)
In-Reply-To: <ee2afdf9ac3d013a236ce2e281379478c7cc38e9.camel@haerdin.se>

On 21/02/2024 14:11, Tomas Härdin wrote:

> mxfdec can detect cases where there will be two separate fields in one
> KLV,

In practice the issue is not to detect I2 case in mxfdec (it saves us 
only a little during probing of the first frame, but I could add such 
signaling in a patch after this one because it is actually independent 
from the management of 2 fields in the decoder if we want to support 
buggy files), the issue is to split per field in mxfdec.

SMPTE ST 422 extracts:
"Users are cautioned that the code values for SOC and EOC are not 
protected and can occur within the image size marker segment (SIZ), 
quantization marker segment (QCD), comment marker segment (COM) and 
other places."
"Decoders can derive the bytestream offsets of each field by analysing 
the code stream format within the essence element as described in 
ISO/IEC 15444-1."

Note that this MXF + jp2k spec hints that separating fields should be 
done in the decoder, not the demuxer.
It is impossible to split per field in a codec-neutral manner due to 
lack of metadata for that in MXF, and doing that in mxfdec implies to 
duplicate jp2k header parser code in mxfdec, and to add a similar parser 
per supported video format in the future.

> and the decoder(s) can if I'm not mistaken be instructed to decode
> into an AVFrame with stride and offset set up for interlaced decoding.


I checked the MPEG-2 Video decoder and it does not do what you say, it 
does what I do with this patch:
- mpegvideo_parser (so the parser of raw files, equivalent to mxfdec) 
understands that the stream has 2 separate fields and puts them in 1 
single AVPacket. It could separate them put it doesn't.
- mpeg12dec (equivalent to jpeg2000dec) understands that there are 2 
separate fields and applies a stride and offset internally and outputs a 
frame in AVFrame, not a field. It could provide fields but it doesn't.
I checked only what I know well, MPEG-2 Video, maybe it is done the way 
you indicate elsewhere, currently I see no example about the idea 
that stride and offset should be provided by the demuxer, would you mind 
to show some code in FFmpeg doing this way?
And stride and offset in signaling would mean that the target decoder 
must support stride and offset in signaling (including jpeg2000dec so 
getting a part of my current patch anyway), so no more "universal" as 
far as I understand.

Also:
Other comments say that AVPacket is expected to receive the packet as it 
in the container so no split of packet.
Other comments say that AVFrame is expected to receive a frame and 
never, at least for the moment, a field.
I don't see how to respect theses 2 indications, while 
mpegvideo_parser.c + mpeg12dec.c are conforming to theses indications 
because they do as in this patch.

My understanding of other comments is that my patch proposal is the 
right way to do it, I am lost here with contradictions in the indicated 
path for the support of such file.
e.g. https://ffmpeg.org/pipermail/ffmpeg-devel/2024-February/321540.html

> It should be possible to have ffmpeg set up the necessary plumbing for
> this.

But is it how it works elsewhere in FFmpeg? Would such complex and deep 
modifications be accepted by others?
Please confirm that it would be accepted before I go so deep in the 
changes of FFmpeg code, or please indicate where such tip is already 
stored in codec context.
And it is not only plumbing, it is implementing a jp2k parser in mxfdec 
for splitting fields, impossible otherwise to split the fields and it is 
NOT for all codec at once (which is impossible in practice due to the 
need to have codec dependent split of fields).

And in practice, what it the inconvenience to do this way, with very few 
modifications and in a similar manner of what is done elsewhere in 
FFmpeg with separate fields?
Especially with patch v2 which adds nearly (a couple of comparisons 
between integers) no performance impact to previously supported content.

As a summary, IMO this patch is conform to what is done elsewhere in 
FFmpeg for separated fiels e.g. in mpeg12dec and is conform to what is 
hinted in the specification by checking the 2nd codestream offset in the 
decoder rather than in the demuxer.

Jérôme
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

  reply	other threads:[~2024-02-21 14:27 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-02 15:55 [FFmpeg-devel] [PATCH] " Jerome Martinez
2024-02-03 10:00 ` Tomas Härdin
2024-02-03 10:51   ` Jerome Martinez
2024-02-03 19:58     ` Tomas Härdin
2024-02-03 20:04       ` Tomas Härdin
2024-02-04  0:20         ` Pierre-Anthony Lemieux
2024-02-05  0:19           ` Tomas Härdin
2024-02-15 15:02             ` Jerome Martinez
2024-02-16  0:02               ` Vittorio Giovara
2024-02-16  2:17                 ` Kieran Kunhya
2024-02-18 23:14               ` Tomas Härdin
2024-02-19 11:08                 ` Tomas Härdin
2024-02-19 11:19                   ` Jerome Martinez
2024-02-16 10:32       ` Anton Khirnov
2024-02-18 23:43         ` Marton Balint
2024-02-19  8:22           ` Hendrik Leppkes
2024-02-19 16:14             ` Devin Heitmueller
2024-02-19 11:05           ` Tomas Härdin
2024-02-19 11:07             ` Tomas Härdin
2024-02-05  2:25   ` James Almer
2024-02-05 14:28     ` Tomas Härdin
2024-02-20 15:07 ` [FFmpeg-devel] [PATCH v2] " Jerome Martinez
2024-02-21 13:11   ` Tomas Härdin
2024-02-21 14:27     ` Jerome Martinez [this message]
2024-02-24 12:26       ` Tomas Härdin
2024-02-25  4:14         ` [FFmpeg-devel] [PATCH v3] " Jerome Martinez
2024-03-01 22:29           ` Tomas Härdin
2024-03-03 17:07             ` Jerome Martinez
2024-04-24 11:20   ` [FFmpeg-devel] [PATCH v2] " Jerome Martinez
2024-04-24 22:54     ` Tomas Härdin
2024-04-25  0:59     ` Michael Niedermayer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f25f1e3a-5646-4e42-89af-94b01fb54b5e@mediaarea.net \
    --to=jerome@mediaarea.net \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git