[FFmpeg-devel] [PATCH v1] lavc/av1dec: drop redundant frame

2021-10-28 Thread Fei Wang
For some non-standard clip which contains multiple display frame
data in a ivf packet, drop the redundant frame can make the decode
continuously with some warning message shown. Otherwise decode will
interrupt with unexpected error.

Signed-off-by: Fei Wang 
---
 libavcodec/av1dec.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c
index db110c50c7..58d10672c1 100644
--- a/libavcodec/av1dec.c
+++ b/libavcodec/av1dec.c
@@ -916,6 +916,16 @@ static int set_output_frame(AVCodecContext *avctx, AVFrame 
*frame,
 av_log2(s->operating_point_idc >> 8) > s->cur_frame.spatial_id)
 return 0;
 
+/**
+ * Drop redundant frame data if there already exist one. Return 0 will
+ * make sure all frames can be decoded and maintainers a correct reference
+ * list.
+ */
+if (*got_frame) {
+av_log(avctx, AV_LOG_WARNING, "Redundant frame data dropped!\n");
+return 0;
+}
+
 ret = av_frame_ref(frame, srcframe);
 if (ret < 0)
 return ret;
-- 
2.25.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".


Re: [FFmpeg-devel] [PATCH] fftools/ffplay: don't disable x11 compositing

2021-10-28 Thread Marton Balint




On Fri, 29 Oct 2021, Marton Balint wrote:




On Wed, 27 Oct 2021, Zane van Iperen wrote:


 Prevents desktop stutters caused by the change (specifically on KDE).
 We're not a game, we don't actually need it disabled.

 Signed-off-by: Zane van Iperen 
 ---
 fftools/ffplay.c | 4 
 1 file changed, 4 insertions(+)

 diff --git a/fftools/ffplay.c b/fftools/ffplay.c
 index ccea0e4578..4b2e69e613 100644
 --- a/fftools/ffplay.c
 +++ b/fftools/ffplay.c
 @@ -3746,6 +3746,10 @@ int main(int argc, char **argv)
 flags |= SDL_WINDOW_BORDERLESS;
 else
 flags |= SDL_WINDOW_RESIZABLE;
 +
 +#ifdef SDL_HINT_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR
 +SDL_SetHint(SDL_HINT_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR, "0");
 +#endif


Shouldn't this be SDL_SetHintWithPriority so the user may override it from an 
environment variable?


Ah, never mind, SDL_SetHint can also be overidden. LGTM then, thanks.

Although this whole compositing mess is ugly and ideally we should not 
need something like this...


Regards,
Marton
___
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] fftools/ffplay: don't disable x11 compositing

2021-10-28 Thread Marton Balint




On Wed, 27 Oct 2021, Zane van Iperen wrote:


Prevents desktop stutters caused by the change (specifically on KDE).
We're not a game, we don't actually need it disabled.

Signed-off-by: Zane van Iperen 
---
fftools/ffplay.c | 4 
1 file changed, 4 insertions(+)

diff --git a/fftools/ffplay.c b/fftools/ffplay.c
index ccea0e4578..4b2e69e613 100644
--- a/fftools/ffplay.c
+++ b/fftools/ffplay.c
@@ -3746,6 +3746,10 @@ int main(int argc, char **argv)
flags |= SDL_WINDOW_BORDERLESS;
else
flags |= SDL_WINDOW_RESIZABLE;
+
+#ifdef SDL_HINT_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR
+SDL_SetHint(SDL_HINT_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR, "0");
+#endif


Shouldn't this be SDL_SetHintWithPriority so the user may override it from 
an environment variable?


Thanks,
Marton



window = SDL_CreateWindow(program_name, SDL_WINDOWPOS_UNDEFINED, 
SDL_WINDOWPOS_UNDEFINED, default_width, default_height, flags);
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "linear");
if (window) {
--
2.31.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 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 v7 4/4] avformat/movenc: Refactor mov_write_dvcc_dvvc_tag to use ff_isom_put_dvcc_dvvc

2021-10-28 Thread quietvoid
Improves code legibility by not using bit shifts.
Also avoids duplicating the dvcC/dvvC ISOM box writing code.

Signed-off-by: quietvoid 
---
 libavformat/movenc.c | 26 +-
 1 file changed, 9 insertions(+), 17 deletions(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 37d4403f7a..cd9c4a0b5e 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -27,6 +27,7 @@
 #include "movenc.h"
 #include "avformat.h"
 #include "avio_internal.h"
+#include "dovi_isom.h"
 #include "riff.h"
 #include "avio.h"
 #include "isom.h"
@@ -1911,6 +1912,9 @@ static int mov_write_sv3d_tag(AVFormatContext *s, 
AVIOContext *pb, AVSphericalMa
 
 static int mov_write_dvcc_dvvc_tag(AVFormatContext *s, AVIOContext *pb, 
AVDOVIDecoderConfigurationRecord *dovi)
 {
+uint8_t buf[ISOM_DVCC_DVVC_SIZE];
+int size;
+
 avio_wb32(pb, 32); /* size = 8 + 24 */
 if (dovi->dv_profile > 10)
 ffio_wfourcc(pb, "dvwC");
@@ -1918,23 +1922,11 @@ static int mov_write_dvcc_dvvc_tag(AVFormatContext *s, 
AVIOContext *pb, AVDOVIDe
 ffio_wfourcc(pb, "dvvC");
 else
 ffio_wfourcc(pb, "dvcC");
-avio_w8(pb, dovi->dv_version_major);
-avio_w8(pb, dovi->dv_version_minor);
-avio_wb16(pb, (dovi->dv_profile << 9) | (dovi->dv_level << 3) |
-  (dovi->rpu_present_flag << 2) | (dovi->el_present_flag << 1) |
-  dovi->bl_present_flag);
-avio_wb32(pb, (dovi->dv_bl_signal_compatibility_id << 28) | 0);
-
-ffio_fill(pb, 0, 4 * 4); /* reserved */
-av_log(s, AV_LOG_DEBUG, "DOVI in %s box, version: %d.%d, profile: %d, 
level: %d, "
-   "rpu flag: %d, el flag: %d, bl flag: %d, compatibility id: %d\n",
-   dovi->dv_profile > 10 ? "dvwC" : (dovi->dv_profile > 7 ? "dvvC" : 
"dvcC"),
-   dovi->dv_version_major, dovi->dv_version_minor,
-   dovi->dv_profile, dovi->dv_level,
-   dovi->rpu_present_flag,
-   dovi->el_present_flag,
-   dovi->bl_present_flag,
-   dovi->dv_bl_signal_compatibility_id);
+
+size = ff_isom_put_dvcc_dvvc(s, buf, sizeof(buf), dovi);
+
+avio_write(pb, buf, size);
+
 return 32; /* 8 + 24 */
 }
 
-- 
2.33.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 v7 3/4] avformat/mov: Refactor mov_read_dvcc_dvvc to use ff_isom_parse_dvcc_dvvc

2021-10-28 Thread quietvoid
To avoid duplicating code. The implementation in dovi_isom is identical.

Signed-off-by: quietvoid 
---
 libavformat/mov.c | 50 +--
 1 file changed, 9 insertions(+), 41 deletions(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 3fcb1dc908..5c393e45ad 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -55,6 +55,7 @@
 #include "avformat.h"
 #include "internal.h"
 #include "avio_internal.h"
+#include "dovi_isom.h"
 #include "riff.h"
 #include "isom.h"
 #include "libavcodec/get_bits.h"
@@ -7033,58 +7034,25 @@ static int mov_read_dmlp(MOVContext *c, AVIOContext 
*pb, MOVAtom atom)
 static int mov_read_dvcc_dvvc(MOVContext *c, AVIOContext *pb, MOVAtom atom)
 {
 AVStream *st;
-uint32_t buf;
-AVDOVIDecoderConfigurationRecord *dovi;
-size_t dovi_size;
+uint8_t buf[ISOM_DVCC_DVVC_SIZE + AV_INPUT_BUFFER_PADDING_SIZE];
 int ret;
+int64_t read_size = atom.size;
 
 if (c->fc->nb_streams < 1)
 return 0;
 st = c->fc->streams[c->fc->nb_streams-1];
 
-if ((uint64_t)atom.size > (1<<30) || atom.size < 4)
-return AVERROR_INVALIDDATA;
-
-dovi = av_dovi_alloc(_size);
-if (!dovi)
-return AVERROR(ENOMEM);
-
-dovi->dv_version_major = avio_r8(pb);
-dovi->dv_version_minor = avio_r8(pb);
-
-buf = avio_rb16(pb);
-dovi->dv_profile= (buf >> 9) & 0x7f;// 7 bits
-dovi->dv_level  = (buf >> 3) & 0x3f;// 6 bits
-dovi->rpu_present_flag  = (buf >> 2) & 0x01;// 1 bit
-dovi->el_present_flag   = (buf >> 1) & 0x01;// 1 bit
-dovi->bl_present_flag   =  buf   & 0x01;// 1 bit
-if (atom.size >= 24) {  // 4 + 4 + 4 * 4
-buf = avio_r8(pb);
-dovi->dv_bl_signal_compatibility_id = (buf >> 4) & 0x0f; // 4 bits
-} else {
-// 0 stands for None
-// Dolby Vision V1.2.93 profiles and levels
-dovi->dv_bl_signal_compatibility_id = 0;
+// At most 24 bytes
+if (read_size > ISOM_DVCC_DVVC_SIZE) {
+read_size = ISOM_DVCC_DVVC_SIZE;
 }
 
-ret = av_stream_add_side_data(st, AV_PKT_DATA_DOVI_CONF,
-  (uint8_t *)dovi, dovi_size);
-if (ret < 0) {
-av_free(dovi);
+if ((ret = avio_read(pb, buf, read_size)) < 0)
 return ret;
-}
 
-av_log(c, AV_LOG_TRACE, "DOVI in dvcC/dvvC/dvwC box, version: %d.%d, 
profile: %d, level: %d, "
-   "rpu flag: %d, el flag: %d, bl flag: %d, compatibility id: %d\n",
-   dovi->dv_version_major, dovi->dv_version_minor,
-   dovi->dv_profile, dovi->dv_level,
-   dovi->rpu_present_flag,
-   dovi->el_present_flag,
-   dovi->bl_present_flag,
-   dovi->dv_bl_signal_compatibility_id
-);
+read_size = ret;
 
-return 0;
+return ff_isom_parse_dvcc_dvvc(c->fc, st, buf, read_size);
 }
 
 static int mov_read_kind(MOVContext *c, AVIOContext *pb, MOVAtom atom)
-- 
2.33.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 v7 2/4] avformat/matroska{dec, enc}: Parse BlockAdditionMapping elements

2021-10-28 Thread quietvoid
Adds handling of dvcC/dvvC block addition mappings.

The parsing creates AVDOVIDecoderConfigurationRecord side data.
The configuration block is written when muxing into Matroska,
if DOVI side data is present for the track.

Most of the Matroska element parsing is based on Plex's FFmpeg source code.

Signed-off-by: quietvoid 
---
 libavformat/Makefile  |  4 +--
 libavformat/matroska.h|  9 ++
 libavformat/matroskadec.c | 58 +--
 libavformat/matroskaenc.c | 45 ++
 4 files changed, 112 insertions(+), 4 deletions(-)

diff --git a/libavformat/Makefile b/libavformat/Makefile
index 3d6c8ef8f5..f70db4551c 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -314,11 +314,11 @@ OBJS-$(CONFIG_M4V_MUXER) += rawenc.o
 OBJS-$(CONFIG_MATROSKA_DEMUXER)  += matroskadec.o matroska.o  \
 flac_picture.o isom_tags.o 
rmsipr.o \
 oggparsevorbis.o vorbiscomment.o \
-qtpalette.o replaygain.o
+qtpalette.o replaygain.o 
dovi_isom.o
 OBJS-$(CONFIG_MATROSKA_MUXER)+= matroskaenc.o matroska.o \
 av1.o avc.o hevc.o isom_tags.o \
 flacenc_header.o avlanguage.o \
-vorbiscomment.o wv.o
+vorbiscomment.o wv.o dovi_isom.o
 OBJS-$(CONFIG_MCA_DEMUXER)   += mca.o
 OBJS-$(CONFIG_MCC_DEMUXER)   += mccdec.o subtitles.o
 OBJS-$(CONFIG_MD5_MUXER) += hashenc.o
diff --git a/libavformat/matroska.h b/libavformat/matroska.h
index 2d04a6838b..16491aae22 100644
--- a/libavformat/matroska.h
+++ b/libavformat/matroska.h
@@ -111,6 +111,7 @@
 #define MATROSKA_ID_TRACKCONTENTENCODING 0x6240
 #define MATROSKA_ID_TRACKTIMECODESCALE 0x23314F
 #define MATROSKA_ID_TRACKMAXBLKADDID 0x55EE
+#define MATROSKA_ID_TRACKBLKADDMAPPING 0x41E4
 
 /* IDs in the trackvideo master */
 #define MATROSKA_ID_VIDEOFRAMERATE 0x2383E3
@@ -189,6 +190,12 @@
 #define MATROSKA_ID_ENCODINGSIGKEYID 0x47E4
 #define MATROSKA_ID_ENCODINGSIGNATURE 0x47E3
 
+/* IDs in the block addition mapping master */
+#define MATROSKA_ID_BLKADDIDVALUE 0x41F0
+#define MATROSKA_ID_BLKADDIDNAME 0x41A4
+#define MATROSKA_ID_BLKADDIDTYPE 0x41E7
+#define MATROSKA_ID_BLKADDIDEXTRADATA 0x41ED
+
 /* ID in the cues master */
 #define MATROSKA_ID_POINTENTRY 0xBB
 
@@ -385,4 +392,6 @@ extern const char * const 
ff_matroska_video_stereo_plane[MATROSKA_VIDEO_STEREO_P
 
 int ff_mkv_stereo3d_conv(AVStream *st, MatroskaVideoStereoModeType 
stereo_mode);
 
+#define DVCC_DVVC_BLOCK_TYPE_NAME "Dolby Vision configuration"
+
 #endif /* AVFORMAT_MATROSKA_H */
diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index b2c4927e43..9e922c70f1 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -53,6 +53,7 @@
 
 #include "avformat.h"
 #include "avio_internal.h"
+#include "dovi_isom.h"
 #include "internal.h"
 #include "isom.h"
 #include "matroska.h"
@@ -239,6 +240,13 @@ typedef struct MatroskaTrackOperation {
 EbmlList combine_planes;
 } MatroskaTrackOperation;
 
+typedef struct MatroskaBlockAdditionMapping {
+uint64_t value;
+char *name;
+uint64_t type;
+EbmlBin extradata;
+} MatroskaBlockAdditionMapping;
+
 typedef struct MatroskaTrack {
 uint64_t num;
 uint64_t uid;
@@ -269,6 +277,7 @@ typedef struct MatroskaTrack {
 int ms_compat;
 int needs_decoding;
 uint64_t max_block_additional_id;
+EbmlList block_addition_mappings;
 
 uint32_t palette[AVPALETTE_COUNT];
 int has_palette;
@@ -419,8 +428,8 @@ typedef struct MatroskaDemuxContext {
 // incomplete type (6.7.2 in C90, 6.9.2 in C99).
 // Removing the sizes breaks MSVC.
 static EbmlSyntax ebml_syntax[3], matroska_segment[9], 
matroska_track_video_color[15], matroska_track_video[19],
-  matroska_track[32], matroska_track_encoding[6], 
matroska_track_encodings[2],
-  matroska_track_combine_planes[2], 
matroska_track_operation[2], matroska_tracks[2],
+  matroska_track[33], matroska_track_encoding[6], 
matroska_track_encodings[2],
+  matroska_track_combine_planes[2], 
matroska_track_operation[2], matroska_block_addition_mapping[5], 
matroska_tracks[2],
   matroska_attachments[2], matroska_chapter_entry[9], 
matroska_chapter[6], matroska_chapters[2],
   matroska_index_entry[3], matroska_index[2], matroska_tag[3], 
matroska_tags[2], matroska_seekhead[2],
   matroska_blockadditions[2], matroska_blockgroup[8], 
matroska_cluster_parsing[8];
@@ -570,6 +579,14 @@ static EbmlSyntax matroska_track_operation[] = {
 CHILD_OF(matroska_track)
 };
 
+static EbmlSyntax matroska_block_addition_mapping[] 

[FFmpeg-devel] [PATCH v7 1/4] avformat/dovi_isom: Implement Dolby Vision configuration parsing/writing

2021-10-28 Thread quietvoid
Both parse/write implementations are based on mov/movenc.

This only adds support for the "Dolby Vision configuration box".
Other configuration boxes, such as
"Dolby Vision enhancement layer configuration box" are not supported.

The new functions will be used to implement parsing/writing the DOVI config
for Matroska, as well as to refactor both mov/movenc to use dovi_isom functions.

Signed-off-by: quietvoid 
---
 libavformat/dovi_isom.c | 121 
 libavformat/dovi_isom.h |  35 
 2 files changed, 156 insertions(+)
 create mode 100644 libavformat/dovi_isom.c
 create mode 100644 libavformat/dovi_isom.h

diff --git a/libavformat/dovi_isom.c b/libavformat/dovi_isom.c
new file mode 100644
index 00..54f17c90a5
--- /dev/null
+++ b/libavformat/dovi_isom.c
@@ -0,0 +1,121 @@
+/*
+ * DOVI ISO Media common code
+ * Copyright (c) 2021 quietvoid
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavutil/dovi_meta.h"
+
+#include "libavcodec/put_bits.h"
+
+#include "avformat.h"
+#include "dovi_isom.h"
+
+int ff_isom_parse_dvcc_dvvc(AVFormatContext *s, AVStream *st, const uint8_t 
*buf_ptr, uint64_t size)
+{
+uint32_t buf;
+AVDOVIDecoderConfigurationRecord *dovi;
+size_t dovi_size;
+int ret;
+
+if (size > (1 << 30) || size < 4)
+return AVERROR_INVALIDDATA;
+
+dovi = av_dovi_alloc(_size);
+if (!dovi)
+return AVERROR(ENOMEM);
+
+dovi->dv_version_major = *buf_ptr++;// 8 bits
+dovi->dv_version_minor = *buf_ptr++;// 8 bits
+
+buf = *buf_ptr++ << 8;
+buf |= *buf_ptr++;
+
+dovi->dv_profile= (buf >> 9) & 0x7f;// 7 bits
+dovi->dv_level  = (buf >> 3) & 0x3f;// 6 bits
+dovi->rpu_present_flag  = (buf >> 2) & 0x01;// 1 bit
+dovi->el_present_flag   = (buf >> 1) & 0x01;// 1 bit
+dovi->bl_present_flag   =  buf   & 0x01;// 1 bit
+
+// Has enough remaining data
+if (size >= 5) {
+dovi->dv_bl_signal_compatibility_id = ((*buf_ptr++) >> 4) & 0x0f; // 4 
bits
+} else {
+// 0 stands for None
+// Dolby Vision V1.2.93 profiles and levels
+dovi->dv_bl_signal_compatibility_id = 0;
+}
+
+ret = av_stream_add_side_data(st, AV_PKT_DATA_DOVI_CONF,
+  (uint8_t *)dovi, dovi_size);
+if (ret < 0) {
+av_free(dovi);
+return ret;
+}
+
+av_log(s, AV_LOG_TRACE, "DOVI in dvcC/dvvC/dvwC box, version: %d.%d, 
profile: %d, level: %d, "
+   "rpu flag: %d, el flag: %d, bl flag: %d, compatibility id: %d\n",
+   dovi->dv_version_major, dovi->dv_version_minor,
+   dovi->dv_profile, dovi->dv_level,
+   dovi->rpu_present_flag,
+   dovi->el_present_flag,
+   dovi->bl_present_flag,
+   dovi->dv_bl_signal_compatibility_id);
+
+return 0;
+}
+
+int ff_isom_put_dvcc_dvvc(AVFormatContext *s, uint8_t 
out[ISOM_DVCC_DVVC_SIZE], uint64_t size,
+  AVDOVIDecoderConfigurationRecord *dovi)
+{
+PutBitContext pb;
+
+if (size < ISOM_DVCC_DVVC_SIZE)
+return AVERROR(EINVAL);
+
+init_put_bits(, out, size);
+
+put_bits(, 8, dovi->dv_version_major);
+put_bits(, 8, dovi->dv_version_minor);
+put_bits(, 7, dovi->dv_profile);
+put_bits(, 6, dovi->dv_level);
+put_bits(, 1, dovi->rpu_present_flag);
+put_bits(, 1, dovi->el_present_flag);
+put_bits(, 1, dovi->bl_present_flag);
+put_bits(, 4, dovi->dv_bl_signal_compatibility_id);
+
+put_bits(, 28, 0); /* reserved */
+put_bits32(, 0); /* reserved */
+put_bits32(, 0); /* reserved */
+put_bits32(, 0); /* reserved */
+put_bits32(, 0); /* reserved */
+
+flush_put_bits();
+
+av_log(s, AV_LOG_DEBUG, "DOVI in %s box, version: %d.%d, profile: %d, 
level: %d, "
+   "rpu flag: %d, el flag: %d, bl flag: %d, compatibility id: %d\n",
+   dovi->dv_profile > 10 ? "dvwC" : (dovi->dv_profile > 7 ? "dvvC" : 
"dvcC"),
+   dovi->dv_version_major, dovi->dv_version_minor,
+   dovi->dv_profile, dovi->dv_level,
+   dovi->rpu_present_flag,
+   dovi->el_present_flag,
+   dovi->bl_present_flag,
+   dovi->dv_bl_signal_compatibility_id);

[FFmpeg-devel] [PATCH v7 0/4] Add support for Matroska BlockAdditionMapping elements

2021-10-28 Thread quietvoid
This patch set adds support for reading/writing the Matroska 
BlockAdditionMapping
elements, as well as for reading/writing dvcC/dvvC blocks in Matroska.

Created utility functions to read/write Dolby Vision boxes for ISOM.
This was done to avoid duplicating the code, as the Matroska blocks and MOV 
boxes
follow the same specification, defined by Dolby.

Refactored the reading/writing in mov/movenc to use the new dovi_isom functions.

Differences compared to v6:
  - Dropped the avformat/mpegts patch as suggested, because the specification
is different from the ISOM specification defined by Dolby.
  - Added a patch to refactor avformat/movenc to further reduce the duplicated
code. The implementation in dovi_isom is the same.
  - Moved init_put_bits after the size validation in ff_isom_put_dvcc_dvvc.
  - Added dvwC to the ff_isom_put_dvcc_dvvc logging.

quietvoid (4):
  avformat/dovi_isom: Implement Dolby Vision configuration
parsing/writing
  avformat/matroska{dec, enc}: Parse BlockAdditionMapping elements
  avformat/mov: Refactor mov_read_dvcc_dvvc to use
ff_isom_parse_dvcc_dvvc
  avformat/movenc: Refactor mov_write_dvcc_dvvc_tag to use
ff_isom_put_dvcc_dvvc

 libavformat/Makefile  |   4 +-
 libavformat/dovi_isom.c   | 121 ++
 libavformat/dovi_isom.h   |  35 +++
 libavformat/matroska.h|   9 +++
 libavformat/matroskadec.c |  58 +-
 libavformat/matroskaenc.c |  45 ++
 libavformat/mov.c |  50 +++-
 libavformat/movenc.c  |  26 +++-
 8 files changed, 286 insertions(+), 62 deletions(-)
 create mode 100644 libavformat/dovi_isom.c
 create mode 100644 libavformat/dovi_isom.h

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


Re: [FFmpeg-devel] [PATCH 1/2] avfilter/vf_zscale: deduplicate output color information setting

2021-10-28 Thread Jan Ekström
On Thu, Oct 28, 2021 at 1:24 AM Paul B Mahol  wrote:
>
> lgtm

Thanks for the reviews, applied these patches as
cd1d09e81b53d47380b494acd3432fd4abb3c17b and
27c0dd55609daf440a7744e96ac20c119bbeb80f .

Jan
___
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] avfilter: add wpsnr video filter

2021-10-28 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 libavfilter/Makefile |   1 +
 libavfilter/allfilters.c |   1 +
 libavfilter/vf_wpsnr.c   | 894 +++
 3 files changed, 896 insertions(+)
 create mode 100644 libavfilter/vf_wpsnr.c

diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 4e6d8bdeea..6ac6e3b764 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -503,6 +503,7 @@ OBJS-$(CONFIG_VSTACK_FILTER) += vf_stack.o 
framesync.o
 OBJS-$(CONFIG_W3FDIF_FILTER) += vf_w3fdif.o
 OBJS-$(CONFIG_WAVEFORM_FILTER)   += vf_waveform.o
 OBJS-$(CONFIG_WEAVE_FILTER)  += vf_weave.o
+OBJS-$(CONFIG_WPSNR_FILTER)  += vf_wpsnr.o framesync.o
 OBJS-$(CONFIG_XBR_FILTER)+= vf_xbr.o
 OBJS-$(CONFIG_XCORRELATE_FILTER) += vf_convolve.o framesync.o
 OBJS-$(CONFIG_XFADE_FILTER)  += vf_xfade.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index 04f1925c14..f5c539199c 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -479,6 +479,7 @@ extern const AVFilter ff_vf_vstack;
 extern const AVFilter ff_vf_w3fdif;
 extern const AVFilter ff_vf_waveform;
 extern const AVFilter ff_vf_weave;
+extern const AVFilter ff_vf_wpsnr;
 extern const AVFilter ff_vf_xbr;
 extern const AVFilter ff_vf_xcorrelate;
 extern const AVFilter ff_vf_xfade;
diff --git a/libavfilter/vf_wpsnr.c b/libavfilter/vf_wpsnr.c
new file mode 100644
index 00..bc4e88e183
--- /dev/null
+++ b/libavfilter/vf_wpsnr.c
@@ -0,0 +1,894 @@
+/*
+ * Copyright (c) 2021 Paul B Mahol
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file
+ * Calculate the WPSNR between two input videos.
+ */
+
+#include "libavutil/avstring.h"
+#include "libavutil/intreadwrite.h"
+#include "libavutil/opt.h"
+#include "libavutil/pixdesc.h"
+#include "avfilter.h"
+#include "drawutils.h"
+#include "formats.h"
+#include "framesync.h"
+#include "internal.h"
+#include "video.h"
+
+#define WIDTH 3840.
+#define HEIGHT 2160.
+
+typedef struct WPSNRContext {
+const AVClass *class;
+FFFrameSync fs;
+double wmse, min_wmse, max_wmse, wmse_comp[4];
+uint64_t nb_frames;
+int mode;
+int sizeN;
+int sizeM;
+double apic;
+double amin;
+int max[4], average_max;
+char comps[4];
+int nb_components;
+int nb_threads;
+int planewidth[4];
+int planeheight[4];
+double planeweight[4];
+double **score;
+
+uint16_t *tmp;
+uint64_t *sat;
+double   *weights;
+
+void (*compute_hx)(const uint8_t *ssrc,
+   int linesize,
+   int w, int h,
+   uint16_t *dstp,
+   int dst_linesize);
+
+void (*compute_sat)(const uint16_t *ssrc,
+int linesize,
+int w, int h,
+uint64_t *dstp,
+int dst_linesize);
+
+int (*compute_weights)(AVFilterContext *ctx, void *arg,
+   int jobnr, int nb_jobs);
+
+int (*compute_wmse)(AVFilterContext *ctx, void *arg,
+int jobnr, int nb_jobs);
+} WPSNRContext;
+
+#define OFFSET(x) offsetof(WPSNRContext, x)
+#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
+
+static const AVOption wpsnr_options[] = {
+{ "mode", "set the mode", OFFSET(mode), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, 
FLAGS, "mode" },
+{ "block",  "block based",  0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 1, FLAGS, 
"mode" },
+{ "sample", "sample based", 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 1, FLAGS, 
"mode" },
+{ NULL }
+};
+
+FRAMESYNC_DEFINE_CLASS(wpsnr, WPSNRContext, fs);
+
+#define COMPUTE_HX(type, stype, depth)   \
+static void compute_hx##depth(const uint8_t *ssrc,   \
+  int linesize,  \
+  int w, int h,  \
+  uint16_t *dstp,\
+  int dst_linesize)  \
+{\
+const type *src = (const type *)ssrc;\
+stype *dst = (stype *)dstp;  \
+

Re: [FFmpeg-devel] [PATCH] mfxenc add jpeg2000 frame field interlacing support

2021-10-28 Thread Erwann RENAN
Ok, i will split it

-Message d'origine-
De : ffmpeg-devel  De la part de Tomas Härdin
Envoyé : jeudi 28 octobre 2021 16:33
À : FFmpeg development discussions and patches 
Objet : Re: [FFmpeg-devel] [PATCH] mfxenc add jpeg2000 frame field interlacing 
support

Looks like you messed up the subject. You need two newlines between the title 
of the patch and the description.

This patch also mixes a lot of different changes. Please split it up.
The bigger a patch is the more rounds of review it tends to have to go through.

> +{ 0x840B,
> {0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0a,0x04,0x01,0x06,0x03,0x0B,0x0
> 0,0x00,0x00}}, /* 8+3n bytes : Array of picture components where each 
> component comprises 3 bytes named Ssizi, XRSizi, YRSizi  The array of 
> 3-byte groups is preceded by the array header comprising a 4-byte 
> value of the number of components followed by a 4-byte value of  3 .
> */

some kind of encoding problem in the comment

> @@ -843,7 +886,28 @@ static void mxf_write_track(AVFormatContext *s, 
> AVStream *st, MXFPackage *packag
>  
>  mxf_write_metadata_key(pb, 0x013b00);
>  PRINT_KEY(s, "track key", pb->buf_ptr - 16);
> -klv_encode_ber_length(pb, 80);
> +
> +if (st->codecpar) {
> +static const char * pcTrackName_Video = "Picture" ;
> +static const char * pcTrackName_Audio = "Sound" ;
> +static const char * pcTrackName_Anc = "Ancillary" ;

static is redundant here

> +if ( st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO )
> +{
> +//TrackName Video
> +klv_encode_ber_length(pb, 80 +
> mxf_utf16_local_tag_length(pcTrackName_Video));
> +mxf_write_local_tag_utf16(s, 0x4802 ,
> pcTrackName_Video);
> +} else if ( st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO )
> {
> +//TrackName Audio
> +klv_encode_ber_length(pb, 80 +
> mxf_utf16_local_tag_length(pcTrackName_Audio));
> +mxf_write_local_tag_utf16(s, 0x4802, pcTrackName_Audio);
> +} else {
> +//TrackName Ancillary
> +klv_encode_ber_length(pb, 80 +
> mxf_utf16_local_tag_length(pcTrackName_Anc));
> +mxf_write_local_tag_utf16(s, 0x4802, pcTrackName_Anc);
> +}
> +} else {
> +klv_encode_ber_length(pb, 80);
> +}

Is this hunk really necessary?

> @@ -1327,6 +1420,182 @@ static int64_t 
> mxf_write_cdci_common(AVFormatContext *s, AVStream *st, const UID
>  return pos;
>  }
>  
> +static int64_t mxf_write_jpeg2000_common(AVFormatContext *s,
> AVStream *st, const UID key)
> +{
> +MXFStreamContext *sc = st->priv_data;
> +MXFContext *mxf = s->priv_data;
> +AVIOContext *pb = s->pb;
> +int stored_width = st->codecpar->width;
> +int stored_height = st->codecpar->height;
> +int display_height;
> +int f1, f2;
> +UID transfer_ul = {0};
> +int64_t pos = mxf_write_generic_desc(s, st, key);
> +get_trc(transfer_ul, st->codecpar->color_trc);

Return value of get_trc() is not checked. Not sure if invalid values can ever 
get in here.

> +
> +mxf_write_local_tag(s, 4, 0x3203);
> +avio_wb32(pb, stored_width);
> +mxf_write_local_tag(s, 4, 0x3202);
> +avio_wb32(pb, stored_height);
> +
> +//Sampled width
> +mxf_write_local_tag(s, 4, 0x3205);
> +avio_wb32(pb, st->codecpar->width);
> +
> +//Samples height
> +mxf_write_local_tag(s, 4, 0x3204);
> +avio_wb32(pb, st->codecpar->height);

Why use stored_* and codecpar->*? Just use codecpar->* in both places.

> +
> +//Sampled X Offset
> +mxf_write_local_tag(s, 4, 0x3206);
> +avio_wb32(pb, 0);
> +
> +//Sampled Y Offset
> +mxf_write_local_tag(s, 4, 0x3207);
> +avio_wb32(pb, 0);
> +
> +mxf_write_local_tag(s, 4, 0x3209);
> +avio_wb32(pb, st->codecpar->width);
> +
> +if (st->codecpar->height == 608) // PAL + VBI
> +display_height = 576;
> +else if (st->codecpar->height == 512)  // NTSC + VBI
> +display_height = 486;
> +else
> +display_height = st->codecpar->height;
> +
> +mxf_write_local_tag(s, 4, 0x3208);
> +avio_wb32(pb, display_height);
> +
> +// display X offset
> +mxf_write_local_tag(s, 4, 0x320A);
> +avio_wb32(pb, 0);
> +
> +//display Y offset
> +mxf_write_local_tag(s, 4, 0x320B);
> +avio_wb32(pb, (st->codecpar->height - display_height));

Would be better if we could get this information via metadata instead of adding 
hacks to the muxer

> +// // Padding Bits
> +// mxf_write_local_tag(s, 2, 0x3307);
> +// avio_wb16(pb, 0);

Stray dead code

> +// video line map
> +{
> +int _field_height = (mxf->mxf_j2kinterlace) ? (2*st-
> >codecpar->height) : st->codecpar->height;
> +
> +if (st->codecpar->sample_aspect_ratio.num && st->codecpar-
> >sample_aspect_ratio.den) {
> +AVRational _ratio = av_mul_q(st->codecpar-
> >sample_aspect_ratio,
> +   av_make_q(st->codecpar->width, st-

Re: [FFmpeg-devel] [PATCH] mfxenc add jpeg2000 frame field interlacing support

2021-10-28 Thread Tomas Härdin
Looks like you messed up the subject. You need two newlines between the
title of the patch and the description.

This patch also mixes a lot of different changes. Please split it up.
The bigger a patch is the more rounds of review it tends to have to go
through.

> +    { 0x840B,
> {0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0a,0x04,0x01,0x06,0x03,0x0B,0x0
> 0,0x00,0x00}}, /* 8+3n bytes : Array of picture components where each
> component comprises 3 bytes named Ssizi, XRSizi, YRSizi  The array of
> 3-byte groups is preceded by the array header comprising a 4-byte
> value of the number of components followed by a 4-byte value of �3�.
> */

some kind of encoding problem in the comment

> @@ -843,7 +886,28 @@ static void mxf_write_track(AVFormatContext *s,
> AVStream *st, MXFPackage *packag
>  
>  mxf_write_metadata_key(pb, 0x013b00);
>  PRINT_KEY(s, "track key", pb->buf_ptr - 16);
> -    klv_encode_ber_length(pb, 80);
> +
> +    if (st->codecpar) {
> +    static const char * pcTrackName_Video = "Picture" ;
> +    static const char * pcTrackName_Audio = "Sound" ;
> +    static const char * pcTrackName_Anc = "Ancillary" ;

static is redundant here

> +    if ( st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO )
> +    {
> +    //TrackName Video
> +    klv_encode_ber_length(pb, 80 +
> mxf_utf16_local_tag_length(pcTrackName_Video));
> +    mxf_write_local_tag_utf16(s, 0x4802 ,
> pcTrackName_Video);
> +    } else if ( st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO )
> {
> +    //TrackName Audio
> +    klv_encode_ber_length(pb, 80 +
> mxf_utf16_local_tag_length(pcTrackName_Audio));
> +    mxf_write_local_tag_utf16(s, 0x4802, pcTrackName_Audio);
> +    } else {
> +    //TrackName Ancillary
> +    klv_encode_ber_length(pb, 80 +
> mxf_utf16_local_tag_length(pcTrackName_Anc));
> +    mxf_write_local_tag_utf16(s, 0x4802, pcTrackName_Anc);
> +    }
> +    } else {
> +    klv_encode_ber_length(pb, 80);
> +    }

Is this hunk really necessary?

> @@ -1327,6 +1420,182 @@ static int64_t
> mxf_write_cdci_common(AVFormatContext *s, AVStream *st, const UID
>  return pos;
>  }
>  
> +static int64_t mxf_write_jpeg2000_common(AVFormatContext *s,
> AVStream *st, const UID key)
> +{
> +    MXFStreamContext *sc = st->priv_data;
> +    MXFContext *mxf = s->priv_data;
> +    AVIOContext *pb = s->pb;
> +    int stored_width = st->codecpar->width;
> +    int stored_height = st->codecpar->height;
> +    int display_height;
> +    int f1, f2;
> +    UID transfer_ul = {0};
> +    int64_t pos = mxf_write_generic_desc(s, st, key);
> +    get_trc(transfer_ul, st->codecpar->color_trc);

Return value of get_trc() is not checked. Not sure if invalid values
can ever get in here.

> +
> +    mxf_write_local_tag(s, 4, 0x3203);
> +    avio_wb32(pb, stored_width);
> +    mxf_write_local_tag(s, 4, 0x3202);
> +    avio_wb32(pb, stored_height);
> +
> +    //Sampled width
> +    mxf_write_local_tag(s, 4, 0x3205);
> +    avio_wb32(pb, st->codecpar->width);
> +
> +    //Samples height
> +    mxf_write_local_tag(s, 4, 0x3204);
> +    avio_wb32(pb, st->codecpar->height);

Why use stored_* and codecpar->*? Just use codecpar->* in both places.

> +
> +    //Sampled X Offset
> +    mxf_write_local_tag(s, 4, 0x3206);
> +    avio_wb32(pb, 0);
> +
> +    //Sampled Y Offset
> +    mxf_write_local_tag(s, 4, 0x3207);
> +    avio_wb32(pb, 0);
> +
> +    mxf_write_local_tag(s, 4, 0x3209);
> +    avio_wb32(pb, st->codecpar->width);
> +
> +    if (st->codecpar->height == 608) // PAL + VBI
> +    display_height = 576;
> +    else if (st->codecpar->height == 512)  // NTSC + VBI
> +    display_height = 486;
> +    else
> +    display_height = st->codecpar->height;
> +
> +    mxf_write_local_tag(s, 4, 0x3208);
> +    avio_wb32(pb, display_height);
> +
> +    // display X offset
> +    mxf_write_local_tag(s, 4, 0x320A);
> +    avio_wb32(pb, 0);
> +
> +    //display Y offset
> +    mxf_write_local_tag(s, 4, 0x320B);
> +    avio_wb32(pb, (st->codecpar->height - display_height));

Would be better if we could get this information via metadata instead
of adding hacks to the muxer

> +    // // Padding Bits
> +    // mxf_write_local_tag(s, 2, 0x3307);
> +    // avio_wb16(pb, 0);

Stray dead code

> +    // video line map
> +    {
> +    int _field_height = (mxf->mxf_j2kinterlace) ? (2*st-
> >codecpar->height) : st->codecpar->height;
> +
> +    if (st->codecpar->sample_aspect_ratio.num && st->codecpar-
> >sample_aspect_ratio.den) {
> +    AVRational _ratio = av_mul_q(st->codecpar-
> >sample_aspect_ratio,
> +   av_make_q(st->codecpar->width, st-
> >codecpar->height));
> +    sc->aspect_ratio = _ratio;
> +
> +    switch (_field_height) {
> +    case  576: f1 = 23; f2 = st->codecpar->codec_id ==
> AV_CODEC_ID_DVVIDEO ? 335 : 336; break;
> +    case  608: f1 =  7; f2 = 320; break;

Re: [FFmpeg-devel] [PATCH] avformat/mxf: support MCA audio information

2021-10-28 Thread Tomas Härdin
ons 2021-10-27 klockan 15:50 +0200 skrev Marc-Antoine Arnaud:

> +if(channel_ordering_ptr->service_type !=
> AV_AUDIO_SERVICE_TYPE_NB) {
> +ast = (enum
> AVAudioServiceType*)av_stream_new_side_data(st,
> AV_PKT_DATA_AUDIO_SERVICE_TYPE, sizeof(*ast));

This needs a check for ast == NULL

> +static int mxf_audio_remapping(int* channel_ordering, uint8_t* data,
> int size, int sample_size, int channels)
> +{
> +int sample_offset = channels * sample_size;
> +int number_of_samples = size / sample_offset;
> +uint8_t tmp[FF_SANE_NB_CHANNELS * 4];
> +uint8_t* data_ptr = data;
> +
> +if (!tmp)
> +return AVERROR(ENOMEM);
> +
> +for (int sample = 0; sample < number_of_samples; ++sample) {
> +memcpy(tmp, data_ptr, sample_offset);
> +
> +for (int channel = 0; channel < channels; ++channel) {
> +for (int sample_index = 0; sample_index < sample_size;
> ++sample_index) {
> +data_ptr[sample_size * channel_ordering[channel] +
> sample_index] = tmp[sample_size * channel + sample_index];
> +}

What I meant with my previous comment on this is that the innermost
loop can be replaced with memcpy(), making the code simpler.

/Tomas

___
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] mfxenc add jpeg2000 frame field interlacing support. SPONSORED BY INA (Institut National de l'Audiovisuel) * the use of a jpeg2000 frame/field input is signaled by the option fl

2021-10-28 Thread Erwann Renan
---
 libavformat/mxf.h|   1 +
 libavformat/mxfenc.c | 371 +--
 2 files changed, 361 insertions(+), 11 deletions(-)

diff --git a/libavformat/mxf.h b/libavformat/mxf.h
index fe9c52732c..2ce637d4a8 100644
--- a/libavformat/mxf.h
+++ b/libavformat/mxf.h
@@ -50,6 +50,7 @@ enum MXFMetadataSetType {
 TaggedValue,
 TapeDescriptor,
 AVCSubDescriptor,
+JPEG2000SubDescriptor,
 };
 
 enum MXFFrameLayout {
diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c
index c36ebef932..5b8ec60358 100644
--- a/libavformat/mxfenc.c
+++ b/libavformat/mxfenc.c
@@ -99,6 +99,7 @@ typedef struct MXFStreamContext {
 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;
+char * pcTrackName;
 } MXFStreamContext;
 
 typedef struct MXFContainerEssenceEntry {
@@ -151,6 +152,7 @@ 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);
+static void mxf_write_jpeg2000_desc(AVFormatContext *s, AVStream *st);
 
 static const MXFContainerEssenceEntry mxf_essence_container_uls[] = {
 { { 
0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x02,0x0D,0x01,0x03,0x01,0x02,0x04,0x60,0x01 
},
@@ -190,6 +192,10 @@ static const MXFContainerEssenceEntry 
mxf_essence_container_uls[] = {
   { 
0x06,0x0e,0x2b,0x34,0x01,0x02,0x01,0x01,0x0d,0x01,0x03,0x01,0x15,0x01,0x08,0x00 
},
   { 
0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x07,0x04,0x01,0x02,0x02,0x03,0x01,0x01,0x00 
},
   mxf_write_cdci_desc },
+{ { 
0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x07,0x0d,0x01,0x03,0x01,0x02,0x0c,0x01,0x00 
},
+  { 
0x06,0x0e,0x2b,0x34,0x01,0x02,0x01,0x01,0x0d,0x01,0x03,0x01,0x15,0x01,0x08,0x00 
},
+  { 
0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0A,0x04,0x01,0x02,0x02,0x03,0x01,0x01,0x7F 
},
+  mxf_write_jpeg2000_desc },
 // H.264
 { { 
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 
},
@@ -295,6 +301,8 @@ static const MXFLocalTagPair mxf_local_tag_batch[] = {
 { 0x4B01, 
{0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x05,0x30,0x04,0x05,0x00,0x00,0x00,0x00}},
 /* Edit Rate */
 { 0x4B02, 
{0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x07,0x02,0x01,0x03,0x01,0x03,0x00,0x00}},
 /* Origin */
 { 0x4803, 
{0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x06,0x01,0x01,0x04,0x02,0x04,0x00,0x00}},
 /* Sequence reference */
+// Track name
+{ 0x4802, 
{0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x01,0x07,0x01,0x02,0x01,0x00,0x00,0x00}},
 /* TrackName */
 // Sequence
 { 0x0201, 
{0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x04,0x07,0x01,0x00,0x00,0x00,0x00,0x00}},
 /* Data Definition UL */
 { 0x0202, 
{0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x07,0x02,0x02,0x01,0x01,0x03,0x00,0x00}},
 /* Duration */
@@ -386,6 +394,20 @@ static const MXFLocalTagPair mxf_local_tag_batch[] = {
 { 0x8302, FF_MXF_MasteringDisplayWhitePointChromaticity },
 { 0x8303, FF_MXF_MasteringDisplayMaximumLuminance },
 { 0x8304, FF_MXF_MasteringDisplayMinimumLuminance },
+// ff_mxf_jpeg2000_local_tags
+{ 0x8400, 
{0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x09,0x06,0x01,0x01,0x04,0x06,0x10,0x00,0x00}},
 /* Sub Descriptors / Opt Ordered array of strong references to sub descriptor 
sets */
+{ 0x8401, 
{0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0a,0x04,0x01,0x06,0x03,0x01,0x00,0x00,0x00}},
 /* 2 bytes : An enumerated value that defines the decoder capabilities.  */
+{ 0x8402, 
{0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0a,0x04,0x01,0x06,0x03,0x02,0x00,0x00,0x00}},
 /* 4 bytes : Width of the reference grid */
+{ 0x8403, 
{0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0a,0x04,0x01,0x06,0x03,0x03,0x00,0x00,0x00}},
 /* 4 bytes : Height of the reference grid */
+{ 0x8404, 
{0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0a,0x04,0x01,0x06,0x03,0x04,0x00,0x00,0x00}},
 /* 4 bytes : Horizontal offset from the origin of the reference grid to the 
left side of the image area */
+{ 0x8405, 
{0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0a,0x04,0x01,0x06,0x03,0x05,0x00,0x00,0x00}},
 /* 4 bytes : Vertical offset from the origin of the reference grid to the left 
side of the image area */
+{ 0x8406, 
{0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0a,0x04,0x01,0x06,0x03,0x06,0x00,0x00,0x00}},
 /* 4 bytes : Width of one reference tile with respect to the reference grid, */
+{ 0x8407, 
{0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0a,0x04,0x01,0x06,0x03,0x07,0x00,0x00,0x00}},
 /* 4 bytes : Height of one reference tile with respect to the reference grid, 
*/
+{ 0x8408, 
{0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0a,0x04,0x01,0x06,0x03,0x08,0x00,0x00,0x00}},
 /* 4 bytes : Horizontal 

Re: [FFmpeg-devel] [PATCH] flvenc: flush after write header

2021-10-28 Thread Steven Liu


> 2021年10月28日 下午2:32,Lingjiang Fang  写道:
> 
> keep align with movenc, or it seems a little weired when debug
> ---
> libavformat/flvenc.c | 2 ++
> 1 file changed, 2 insertions(+)
> 
> diff --git a/libavformat/flvenc.c b/libavformat/flvenc.c
> index 3f24c7e192..f4798dc9a6 100644
> --- a/libavformat/flvenc.c
> +++ b/libavformat/flvenc.c
> @@ -767,6 +767,8 @@ static int flv_write_header(AVFormatContext *s)
> flv_write_codec_header(s, s->streams[i]->codecpar, 0);
> }
> 
> +avio_flush(pb);
> +
> flv->datastart_offset = avio_tell(pb);
> return 0;
> }
> -- 
> 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".
> 

LGTM

Thanks

Steven Liu

___
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] avfilter/vf_zscale: fix mapping of zimg_chroma_location_e to AVChromaLocation

2021-10-28 Thread Jan Ekström
On Thu, Oct 28, 2021 at 1:25 AM Paul B Mahol  wrote:
>
> probably fine

This can be verified by specifying - say - chromal topleft, and seeing
that the ffmpeg.c Output: bit right now would end up being "left"
(most likely). While if you apply this, you should get "topleft".

Technically if the values were unsanitized, having a mapping function
like we have the other way would be better, but since the code already
utilized +/- 1... I went with that way of just fixing the logic to go
the right way.

For verification of the internal values, something like the following
can be utilized:

diff --git a/libavfilter/vf_zscale.c b/libavfilter/vf_zscale.c
index 1288c5efc1..50df90e9ec 100644
--- a/libavfilter/vf_zscale.c
+++ b/libavfilter/vf_zscale.c
@@ -126,6 +126,8 @@ typedef struct ZScaleContext {
 enum AVColorPrimaries in_primaries, out_primaries;
 enum AVColorRange in_range, out_range;
 enum AVChromaLocation in_chromal, out_chromal;
+
+int lel;
 } ZScaleContext;

 static av_cold int init(AVFilterContext *ctx)
@@ -687,6 +689,12 @@ static int filter_frame(AVFilterLink *link, AVFrame *in)

 update_output_color_information(s, out);

+av_log_once(s, AV_LOG_VERBOSE, AV_LOG_TRACE, &(s->lel),
+"output frame chroma location: %s "
+"(s->chromal: %d, dst_format.chroma_location: %d)\n",
+av_chroma_location_name(out->chroma_location),
+s->chromal, s->dst_format.chroma_location);
+
 av_reduce(>sample_aspect_ratio.num, >sample_aspect_ratio.den,
   (int64_t)in->sample_aspect_ratio.num * outlink->h * link->w,
   (int64_t)in->sample_aspect_ratio.den * outlink->w * link->h,
___
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 3/5] avformat/imf: Demuxer implementation

2021-10-28 Thread Paul B Mahol
On Thu, Oct 28, 2021 at 6:32 AM Pierre-Anthony Lemieux 
wrote:

> On Wed, Oct 27, 2021 at 12:54 AM Paul B Mahol  wrote:
> >
> >
> >
> > On Fri, Oct 8, 2021 at 1:42 AM  wrote:
> >>
> >> From: Pierre-Anthony Lemieux 
> >>
> >> Signed-off-by: Pierre-Anthony Lemieux 
> >> ---
> >>
> >> Notes:
> >> Implements the IMF demuxer.
> >>
> >>  libavformat/imfdec.c | 660 +++
> >>  1 file changed, 660 insertions(+)
> >>  create mode 100644 libavformat/imfdec.c
> >>
> >> diff --git a/libavformat/imfdec.c b/libavformat/imfdec.c
> >> new file mode 100644
> >> index 00..0c64fe0c03
> >> --- /dev/null
> >> +++ b/libavformat/imfdec.c
> >> @@ -0,0 +1,660 @@
> >> +/*
> >> + * Copyright (c) Sandflow Consulting LLC
> >> + *
> >> + * Redistribution and use in source and binary forms, with or without
> >> + * modification, are permitted provided that the following conditions
> are met:
> >> + *
> >> + * * Redistributions of source code must retain the above copyright
> notice, this
> >> + *   list of conditions and the following disclaimer.
> >> + * * Redistributions in binary form must reproduce the above copyright
> notice,
> >> + *   this list of conditions and the following disclaimer in the
> documentation
> >> + *   and/or other materials provided with the distribution.
> >> + *
> >> + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
> "AS IS"
> >> + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
> TO, THE
> >> + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
> PURPOSE
> >> + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
> CONTRIBUTORS BE
> >> + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
> >> + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
> >> + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
> BUSINESS
> >> + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
> WHETHER IN
> >> + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
> OTHERWISE)
> >> + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
> OF THE
> >> + * POSSIBILITY OF SUCH DAMAGE.
> >> + *
> >> + * This file is part of FFmpeg.
> >> + *
> >> + * FFmpeg is free software; you can redistribute it and/or
> >> + * modify it under the terms of the GNU Lesser General Public
> >> + * License as published by the Free Software Foundation; either
> >> + * version 2.1 of the License, or (at your option) any later version.
> >> + *
> >> + * FFmpeg is distributed in the hope that it will be useful,
> >> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> >> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> >> + * Lesser General Public License for more details.
> >> + *
> >> + * You should have received a copy of the GNU Lesser General Public
> >> + * License along with FFmpeg; if not, write to the Free Software
> >> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
> 02110-1301 USA
> >> + */
> >> +
> >> +/**
> >> + * Demuxes an IMF Composition
> >> + *
> >> + * References
> >> + * OV 2067-0:2018 - SMPTE Overview Document - Interoperable Master
> Format
> >> + * ST 2067-2:2020 - SMPTE Standard - Interoperable Master Format —
> Core Constraints
> >> + * ST 2067-3:2020 - SMPTE Standard - Interoperable Master Format —
> Composition Playlist
> >> + * ST 2067-5:2020 - SMPTE Standard - Interoperable Master Format —
> Essence Component
> >> + * ST 2067-20:2016 - SMPTE Standard - Interoperable Master Format —
> Application #2
> >> + * ST 2067-21:2020 - SMPTE Standard - Interoperable Master Format —
> Application #2 Extended
> >> + * ST 2067-102:2017 - SMPTE Standard - Interoperable Master Format —
> Common Image Pixel Color Schemes
> >> + * ST 429-9:2007 - SMPTE Standard - D-Cinema Packaging — Asset Mapping
> and File Segmentation
> >> + *
> >> + * @author Marc-Antoine Arnaud
> >> + * @author Valentin Noel
> >> + * @file
> >> + * @ingroup lavu_imf
> >> + */
> >> +
> >> +#include "imf.h"
> >> +#include "imf_internal.h"
> >> +#include "internal.h"
> >> +#include "libavutil/opt.h"
> >> +#include "libavutil/bprint.h"
> >> +#include "libavutil/avstring.h"
> >> +#include "mxf.h"
> >> +#include "url.h"
> >> +#include 
> >> +#include 
> >> +
> >> +#define MAX_BPRINT_READ_SIZE (UINT_MAX - 1)
> >> +#define DEFAULT_ASSETMAP_SIZE 8 * 1024
> >> +
> >> +typedef struct IMFVirtualTrackResourcePlaybackCtx {
> >> +IMFAssetLocator *locator;
> >> +IMFTrackFileResource *resource;
> >> +AVFormatContext *ctx;
> >> +} IMFVirtualTrackResourcePlaybackCtx;
> >> +
> >> +typedef struct IMFVirtualTrackPlaybackCtx {
> >> +// Track index in playlist
> >> +int32_t index;
> >> +// Time counters
> >> +AVRational current_timestamp;
> >> +AVRational duration;
> >> +// Resources
> >> +unsigned int resource_count;
> >> +IMFVirtualTrackResourcePlaybackCtx **resources;
> >> +// 

Re: [FFmpeg-devel] [PATCH 2/5] avformat/imf: CPL processor

2021-10-28 Thread Paul B Mahol
On Thu, Oct 28, 2021 at 6:34 AM Pierre-Anthony Lemieux 
wrote:

> On Wed, Oct 27, 2021 at 12:57 AM Paul B Mahol  wrote:
> >
> >
> >
> > On Wed, Oct 20, 2021 at 4:55 PM  wrote:
> >>
> >> From: Pierre-Anthony Lemieux 
> >>
> >> Signed-off-by: Pierre-Anthony Lemieux 
> >> ---
> >>
> >> Notes:
> >> Implements IMF Composition Playlist (CPL) parsing.
> >>
> >>  libavformat/imf_cpl.c | 666 ++
> >>  1 file changed, 666 insertions(+)
> >>  create mode 100644 libavformat/imf_cpl.c
> >>
> >> diff --git a/libavformat/imf_cpl.c b/libavformat/imf_cpl.c
> >> new file mode 100644
> >> index 00..8ef574ad78
> >> --- /dev/null
> >> +++ b/libavformat/imf_cpl.c
> >> @@ -0,0 +1,666 @@
> >> +/*
> >> + * Copyright (c) Sandflow Consulting LLC
> >> + *
> >> + * Redistribution and use in source and binary forms, with or without
> >> + * modification, are permitted provided that the following conditions
> are met:
> >> + *
> >> + * * Redistributions of source code must retain the above copyright
> notice, this
> >> + *   list of conditions and the following disclaimer.
> >> + * * Redistributions in binary form must reproduce the above copyright
> notice,
> >> + *   this list of conditions and the following disclaimer in the
> documentation
> >> + *   and/or other materials provided with the distribution.
> >> + *
> >> + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
> "AS IS"
> >> + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
> TO, THE
> >> + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
> PURPOSE
> >> + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
> CONTRIBUTORS BE
> >> + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
> >> + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
> >> + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
> BUSINESS
> >> + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
> WHETHER IN
> >> + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
> OTHERWISE)
> >> + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
> OF THE
> >> + * POSSIBILITY OF SUCH DAMAGE.
> >> + *
> >> + * This file is part of FFmpeg.
> >> + *
> >> + * FFmpeg is free software; you can redistribute it and/or
> >> + * modify it under the terms of the GNU Lesser General Public
> >> + * License as published by the Free Software Foundation; either
> >> + * version 2.1 of the License, or (at your option) any later version.
> >> + *
> >> + * FFmpeg is distributed in the hope that it will be useful,
> >> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> >> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> >> + * Lesser General Public License for more details.
> >> + *
> >> + * You should have received a copy of the GNU Lesser General Public
> >> + * License along with FFmpeg; if not, write to the Free Software
> >> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
> 02110-1301 USA
> >> + */
> >> +
> >> +/**
> >> + * Implements IMP CPL processing
> >> + *
> >> + * @author Pierre-Anthony Lemieux
> >> + * @file
> >> + * @ingroup lavu_imf
> >> + */
> >> +
> >> +#include "imf.h"
> >> +#include "imf_internal.h"
> >> +#include "libavformat/mxf.h"
> >> +#include "libavutil/bprint.h"
> >> +#include "libavutil/error.h"
> >> +#include 
> >> +
> >> +xmlNodePtr xml_get_child_element_by_name(xmlNodePtr parent, const char
> *name_utf8) {
> >> +xmlNodePtr cur_element;
> >> +
> >> +cur_element = xmlFirstElementChild(parent);
> >> +while (cur_element) {
> >> +if (xmlStrcmp(cur_element->name, name_utf8) == 0)
> >> +return cur_element;
> >> +cur_element = xmlNextElementSibling(cur_element);
> >> +}
> >> +return NULL;
> >> +}
> >> +
> >> +int xml_read_UUID(xmlNodePtr element, uint8_t uuid[16]) {
> >> +xmlChar *element_text = NULL;
> >> +int scanf_ret;
> >> +int ret = 0;
> >> +
> >> +element_text = xmlNodeListGetString(element->doc,
> element->xmlChildrenNode, 1);
> >> +scanf_ret = sscanf(element_text,
> >> +UUID_FORMAT,
> >> +[0],
> >> +[1],
> >> +[2],
> >> +[3],
> >> +[4],
> >> +[5],
> >> +[6],
> >> +[7],
> >> +[8],
> >> +[9],
> >> +[10],
> >> +[11],
> >> +[12],
> >> +[13],
> >> +[14],
> >> +[15]);
> >> +if (scanf_ret != 16) {
> >> +av_log(NULL, AV_LOG_ERROR, "Invalid UUID\n");
> >> +ret = AVERROR_INVALIDDATA;
> >> +}
> >> +xmlFree(element_text);
> >> +
> >> +return ret;
> >> +}
> >> +
> >> +int xml_read_rational(xmlNodePtr element, AVRational *rational) {
> >> +xmlChar *element_text = NULL;
> >> +int ret = 0;
> >> +
> >> +element_text = xmlNodeListGetString(element->doc,
> element->xmlChildrenNode, 1);
> >> +if 

[FFmpeg-devel] [PATCH] flvenc: flush after write header

2021-10-28 Thread Lingjiang Fang
keep align with movenc, or it seems a little weired when debug
---
 libavformat/flvenc.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavformat/flvenc.c b/libavformat/flvenc.c
index 3f24c7e192..f4798dc9a6 100644
--- a/libavformat/flvenc.c
+++ b/libavformat/flvenc.c
@@ -767,6 +767,8 @@ static int flv_write_header(AVFormatContext *s)
 flv_write_codec_header(s, s->streams[i]->codecpar, 0);
 }
 
+avio_flush(pb);
+
 flv->datastart_offset = avio_tell(pb);
 return 0;
 }
-- 
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".