[FFmpeg-devel] [PATCH 06/13] avformat/mxfenc: Add Sample width/height/x offset/y offset, Display x offset and F2 offset

2018-05-07 Thread Michael Niedermayer
Signed-off-by: Michael Niedermayer 
---
 libavformat/mxfenc.c| 39 +++--
 tests/ref/fate/copy-trac4914|  4 ++--
 tests/ref/fate/mxf-reel_name|  2 +-
 tests/ref/fate/time_base|  2 +-
 tests/ref/lavf/mxf  | 12 +-
 tests/ref/lavf/mxf_d10  |  4 ++--
 tests/ref/lavf/mxf_dv25 |  4 ++--
 tests/ref/lavf/mxf_dvcpro50 |  4 ++--
 tests/ref/lavf/mxf_opatom   |  4 ++--
 tests/ref/lavf/mxf_opatom_audio |  4 ++--
 10 files changed, 57 insertions(+), 22 deletions(-)

diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c
index 9140302b81..e79e1ec7e6 100644
--- a/libavformat/mxfenc.c
+++ b/libavformat/mxfenc.c
@@ -480,9 +480,16 @@ static const MXFLocalTagPair mxf_local_tag_batch[] = {
 { 0x320D, 
{0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x04,0x01,0x03,0x02,0x05,0x00,0x00,0x00}},
 /* Video Line Map */
 { 0x3203, 
{0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x01,0x04,0x01,0x05,0x02,0x02,0x00,0x00,0x00}},
 /* Stored Width */
 { 0x3202, 
{0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x01,0x04,0x01,0x05,0x02,0x01,0x00,0x00,0x00}},
 /* Stored Height */
+{ 0x3216, 
{0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x05,0x04,0x01,0x03,0x02,0x08,0x00,0x00,0x00}},
 /* Stored F2 Offset */
+{ 0x3205, 
{0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x01,0x04,0x01,0x05,0x01,0x08,0x00,0x00,0x00}},
 /* Sampled Width */
+{ 0x3204, 
{0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x01,0x04,0x01,0x05,0x01,0x07,0x00,0x00,0x00}},
 /* Sampled Height */
+{ 0x3206, 
{0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x01,0x04,0x01,0x05,0x01,0x09,0x00,0x00,0x00}},
 /* Sampled X Offset */
+{ 0x3207, 
{0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x01,0x04,0x01,0x05,0x01,0x0A,0x00,0x00,0x00}},
 /* Sampled Y Offset */
 { 0x3209, 
{0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x01,0x04,0x01,0x05,0x01,0x0C,0x00,0x00,0x00}},
 /* Display Width */
 { 0x3208, 
{0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x01,0x04,0x01,0x05,0x01,0x0B,0x00,0x00,0x00}},
 /* Display Height */
+{ 0x320A, 
{0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x01,0x04,0x01,0x05,0x01,0x0D,0x00,0x00,0x00}},
 /* Display X offset */
 { 0x320B, 
{0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x01,0x04,0x01,0x05,0x01,0x0E,0x00,0x00,0x00}},
 /* Presentation Y offset */
+{ 0x3217, 
{0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x05,0x04,0x01,0x03,0x02,0x07,0x00,0x00,0x00}},
 /* Display F2 offset */
 { 0x320E, 
{0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x01,0x04,0x01,0x01,0x01,0x01,0x00,0x00,0x00}},
 /* Aspect Ratio */
 { 0x3201, 
{0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x04,0x01,0x06,0x01,0x00,0x00,0x00,0x00}},
 /* Picture Essence Coding */
 { 0x3212, 
{0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x04,0x01,0x03,0x01,0x06,0x00,0x00,0x00}},
 /* Field Dominance (Opt) */
@@ -1135,11 +1142,13 @@ static void mxf_write_cdci_common(AVFormatContext *s, 
AVStream *st, const UID ke
 int stored_height = (st->codecpar->height+15)/16*16;
 int display_height;
 int f1, f2;
-unsigned desc_size = size+8+8+8+8+8+8+8+5+16+4+12+20+5;
+unsigned desc_size = size+8+8+8+8+8+8+8+5+16+4+12+20+5 + 5*8;
 if (sc->interlaced && sc->field_dominance)
 desc_size += 5;
 if (sc->signal_standard)
 desc_size += 5;
+if (sc->interlaced)
+desc_size += 8;
 
 mxf_write_generic_desc(s, st, key, desc_size);
 
@@ -1149,6 +1158,22 @@ static void mxf_write_cdci_common(AVFormatContext *s, 
AVStream *st, const UID ke
 mxf_write_local_tag(pb, 4, 0x3202);
 avio_wb32(pb, stored_height>>sc->interlaced);
 
+//Sampled width
+mxf_write_local_tag(pb, 4, 0x3205);
+avio_wb32(pb, st->codecpar->width);
+
+//Samples height
+mxf_write_local_tag(pb, 4, 0x3204);
+avio_wb32(pb, st->codecpar->height>>sc->interlaced);
+
+//Sampled X Offset
+mxf_write_local_tag(pb, 4, 0x3206);
+avio_wb32(pb, 0);
+
+//Sampled Y Offset
+mxf_write_local_tag(pb, 4, 0x3207);
+avio_wb32(pb, 0);
+
 mxf_write_local_tag(pb, 4, 0x3209);
 avio_wb32(pb, st->codecpar->width);
 
@@ -1162,10 +1187,20 @@ static void mxf_write_cdci_common(AVFormatContext *s, 
AVStream *st, const UID ke
 mxf_write_local_tag(pb, 4, 0x3208);
 avio_wb32(pb, display_height>>sc->interlaced);
 
-// presentation Y offset
+// display X offset
+mxf_write_local_tag(pb, 4, 0x320A);
+avio_wb32(pb, 0);
+
+// display Y offset
 mxf_write_local_tag(pb, 4, 0x320B);
 avio_wb32(pb, (st->codecpar->height - display_height)>>sc->interlaced);
 
+if (sc->interlaced) {
+//Display F2 Offset
+mxf_write_local_tag(pb, 4, 0x3217);
+avio_wb32(pb, -((st->codecpar->height - display_height)&1));
+}
+
 // component depth
 mxf_write_local_tag(pb, 4, 0x3301);
 avio_wb32(pb, sc->component_depth);
diff --git a/tests/ref/fate/copy-trac4914 b/tests/ref/fate/copy-trac4914
index 0d8f09176f..8f060eec38 100644
--- a/tests/ref/fate/copy-trac4914
+++ b/tests/ref/fate/copy-trac4914
@@ -1,5 +1,5 @@
-2bbcbc55eebf305aec776bce60d09f91 *t

Re: [FFmpeg-devel] [PATCH 06/13] avformat/mxfenc: Add Sample width/height/x offset/y offset, Display x offset and F2 offset

2018-05-08 Thread Tomas Härdin
mån 2018-05-07 klockan 12:38 +0200 skrev Michael Niedermayer:
> > Signed-off-by: Michael Niedermayer 
> +if (sc->interlaced) {
> +//Display F2 Offset
> +mxf_write_local_tag(pb, 4, 0x3217);
> +avio_wb32(pb, -((st->codecpar->height - display_height)&1));

Negative values for DisplayF2Offset are not valid

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


Re: [FFmpeg-devel] [PATCH 06/13] avformat/mxfenc: Add Sample width/height/x offset/y offset, Display x offset and F2 offset

2018-05-08 Thread Michael Niedermayer
On Tue, May 08, 2018 at 12:40:49PM +0200, Tomas Härdin wrote:
> mån 2018-05-07 klockan 12:38 +0200 skrev Michael Niedermayer:
> > > Signed-off-by: Michael Niedermayer 
> > +if (sc->interlaced) {
> > +//Display F2 Offset
> > +mxf_write_local_tag(pb, 4, 0x3217);
> > +avio_wb32(pb, -((st->codecpar->height - display_height)&1));
> 
> Negative values for DisplayF2Offset are not valid

The specification (SMPTE 377-1-2009) says:

The DisplayF2Offset Property adjusts the DisplayYOffset for the second field 
relative to that for the first field. Its
value shall be zero (0) or minus 1. A value of minus 1 shall invert the 
Displayed Topness relative to the Sampled
Topness.


[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Its not that you shouldnt use gotos but rather that you should write
readable code and code with gotos often but not always is less readable


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 06/13] avformat/mxfenc: Add Sample width/height/x offset/y offset, Display x offset and F2 offset

2018-05-09 Thread Tobias Rapp

On 08.05.2018 12:40, Tomas Härdin wrote:

mån 2018-05-07 klockan 12:38 +0200 skrev Michael Niedermayer:

Signed-off-by: Michael Niedermayer 

+if (sc->interlaced) {
+//Display F2 Offset
+mxf_write_local_tag(pb, 4, 0x3217);
+avio_wb32(pb, -((st->codecpar->height - display_height)&1));


Negative values for DisplayF2Offset are not valid


Can't say anything about the formula but according to The MXF Book (ISBN 
978-0240806938, page 187) the DisplayF2Offset property is defined as 
Int32, not UInt32.


Regards,
Tobias

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


Re: [FFmpeg-devel] [PATCH 06/13] avformat/mxfenc: Add Sample width/height/x offset/y offset, Display x offset and F2 offset

2018-05-10 Thread Tomas Härdin
tis 2018-05-08 klockan 18:26 +0200 skrev Michael Niedermayer:
> On Tue, May 08, 2018 at 12:40:49PM +0200, Tomas Härdin wrote:
> > mån 2018-05-07 klockan 12:38 +0200 skrev Michael Niedermayer:
> > > > Signed-off-by: Michael Niedermayer 
> > > 
> > > +if (sc->interlaced) {
> > > +//Display F2 Offset
> > > +mxf_write_local_tag(pb, 4, 0x3217);
> > > +avio_wb32(pb, -((st->codecpar->height -
> > > display_height)&1));
> > 
> > Negative values for DisplayF2Offset are not valid
> 
> The specification (SMPTE 377-1-2009) says:
> 
> The DisplayF2Offset Property adjusts the DisplayYOffset for the
> second field relative to that for the first field. Its
> value shall be zero (0) or minus 1. A value of minus 1 shall invert
> the Displayed Topness relative to the Sampled
> Topness.

Huh, the document I have is from 2004, which says "If the property is
not present, its value shall be assumed to be 0. Valid values are zero
or 1.". So I guess they changed that. I guess it's fine then.

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


Re: [FFmpeg-devel] [PATCH 06/13] avformat/mxfenc: Add Sample width/height/x offset/y offset, Display x offset and F2 offset

2018-05-10 Thread Michael Niedermayer
On Thu, May 10, 2018 at 10:48:59PM +0200, Tomas Härdin wrote:
> tis 2018-05-08 klockan 18:26 +0200 skrev Michael Niedermayer:
> > On Tue, May 08, 2018 at 12:40:49PM +0200, Tomas Härdin wrote:
> > > mån 2018-05-07 klockan 12:38 +0200 skrev Michael Niedermayer:
> > > > > Signed-off-by: Michael Niedermayer 
> > > > 
> > > > +if (sc->interlaced) {
> > > > +//Display F2 Offset
> > > > +mxf_write_local_tag(pb, 4, 0x3217);
> > > > +avio_wb32(pb, -((st->codecpar->height -
> > > > display_height)&1));
> > > 
> > > Negative values for DisplayF2Offset are not valid
> > 
> > The specification (SMPTE 377-1-2009) says:
> > 
> > The DisplayF2Offset Property adjusts the DisplayYOffset for the
> > second field relative to that for the first field. Its
> > value shall be zero (0) or minus 1. A value of minus 1 shall invert
> > the Displayed Topness relative to the Sampled
> > Topness.
> 
> Huh, the document I have is from 2004, which says "If the property is
> not present, its value shall be assumed to be 0. Valid values are zero
> or 1.". So I guess they changed that. I guess it's fine then.

will apply

thanks

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Awnsering whenever a program halts or runs forever is
On a turing machine, in general impossible (turings halting problem).
On any real computer, always possible as a real computer has a finite number
of states N, and will either halt in less than N cycles or never halt.


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel