Re: [FFmpeg-devel] [PATCH v4] avformat/dvd: new dvd:// protocol for reading dvd folder/images

2023-01-21 Thread Stanislav Ionascu
On Tue, Jan 17, 2023 at 8:12 AM Nicolas George  wrote:
>
> Stanislav Ionascu (12023-01-15):
> > dvd:// protocol uses libdvdread for opening folders and/or disc-images,
> > it then either identifies the longest title-set, or uses the title-set
> > parameter.
> >
> > After opening the dvd, libdvdread-protocol will read and output all
> > VOBs, in the cell and pack sequence defined by the program-chain.
> >
> > The (split)-VOB content that is streamed from the folder/disc by
> > libdvdread, is given to ffmpeg probed demuxer/decoder, which decodes
> > and presents the frames.
> >
> > The chapter and language stream information is present in the
> > side-files (BUP/IFO), which are parsed for identifying the correct
> > main video-title-set, but not attached to the stream information.
>
> Thanks for the new patch. All this information needs to be in the user
> documentation, with a little more detail on what it means in practice
> (chapters, languages, late probing, etc.).
>

Thanks for having a look! I've updated the user-docs in the patch.
Please let me know if something requires more details.

Regards,
Stan.

> Regards,
>
> --
>   Nicolas George
___
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 v5] avformat/dvd: new dvd:// protocol for reading dvd folder/images

2023-01-21 Thread Stanislav Ionascu
dvd:// protocol uses libdvdread for opening folders and/or disc-images,
it then either identifies the longest title-set, or uses the title-set
parameter.

After opening the dvd, libdvdread-protocol will read and output all
VOBs, in the cell and pack sequence defined by the program-chain.

The (split)-VOB content that is streamed from the folder/disc by
libdvdread, is given to ffmpeg probed demuxer/decoder, which decodes
and presents the frames.

The chapter and language stream information is present in the
side-files (BUP/IFO), which are parsed for identifying the correct
main video-title-set, but not attached to the stream information.

Signed-off-by: Stanislav Ionascu 
---
 configure   |   5 +
 doc/protocols.texi  |  61 
 libavformat/Makefile|   1 +
 libavformat/dvd.c   | 327 
 libavformat/protocols.c |   1 +
 5 files changed, 395 insertions(+)
 create mode 100644 libavformat/dvd.c

diff --git a/configure b/configure
index df69d39669..4dcd1f1484 100755
--- a/configure
+++ b/configure
@@ -230,6 +230,7 @@ External library support:
   --enable-libdavs2enable AVS2 decoding via libdavs2 [no]
   --enable-libdc1394   enable IIDC-1394 grabbing using libdc1394
and libraw1394 [no]
+  --enable-libdvdread  enable DVD reading using libdvdread [no]
   --enable-libfdk-aac  enable AAC de/encoding via libfdk-aac [no]
   --enable-libfliteenable flite (voice synthesis) support via libflite 
[no]
   --enable-libfontconfig   enable libfontconfig, useful for drawtext filter 
[no]
@@ -1814,6 +1815,7 @@ EXTERNAL_LIBRARY_LIST="
 libdav1d
 libdc1394
 libdrm
+libdvdread
 libflite
 libfontconfig
 libfreetype
@@ -3557,6 +3559,7 @@ xv_outdev_deps="xlib_xv xlib_x11 xlib_xext"
 # protocols
 async_protocol_deps="threads"
 bluray_protocol_deps="libbluray"
+dvd_protocol_deps="libdvdread"
 ffrtmpcrypt_protocol_conflict="librtmp_protocol"
 ffrtmpcrypt_protocol_deps_any="gcrypt gmp openssl mbedtls"
 ffrtmpcrypt_protocol_select="tcp_protocol"
@@ -6568,6 +6571,8 @@ enabled libdav1d  && require_pkg_config libdav1d 
"dav1d >= 0.5.0" "dav1d
 enabled libdavs2  && require_pkg_config libdavs2 "davs2 >= 1.6.0" 
davs2.h davs2_decoder_open
 enabled libdc1394 && require_pkg_config libdc1394 libdc1394-2 
dc1394/dc1394.h dc1394_new
 enabled libdrm&& require_pkg_config libdrm libdrm xf86drm.h 
drmGetVersion
+enabled libdvdread&& enable dvdread
+enabled dvdread   && require_pkg_config libdvdread dvdread 
"dvdread/dvd_reader.h" DVDOpen2
 enabled libfdk_aac&& { check_pkg_config libfdk_aac fdk-aac 
"fdk-aac/aacenc_lib.h" aacEncOpen ||
{ require libfdk_aac fdk-aac/aacenc_lib.h 
aacEncOpen -lfdk-aac &&
  warn "using libfdk without pkg-config"; } }
diff --git a/doc/protocols.texi b/doc/protocols.texi
index 21ae6181a0..ec5be9c6e5 100644
--- a/doc/protocols.texi
+++ b/doc/protocols.texi
@@ -275,6 +275,67 @@ For example, to convert a GIF file given inline with 
@command{ffmpeg}:
 ffmpeg -i 
"data:image/gif;base64,R0lGODdhCAAIAMIE//8AAP//AP///ywACAAIAAADF0gEDLojDgdGiJdJqUX02iB4E8Q9jUMkADs="
 smiley.png
 @end example
 
+@section dvd
+
+Reads DVD titles from image or folder backups.
+
+After opening the dvd, the protocol will read and output the VOBs,
+associated with the longest or requested @command{title}, in the cell
+and pack sequence defined by the program-chain. It will stop, when reaching
+the end of the @command{title}.
+
+@subsection Limitations
+
+There are some limitations in the stream information that this protocol
+provides:
+@itemize @bullet
+@item
+Some of the streams, like subtitles, are discovered by @command{ffmpeg} while
+parsing the DVD stream, thus large enough @command{probesize} and 
@command{analyzeduration}
+are needed to discover those while probing or remuxing.
+@item
+The protocol does not handle the presentation or decoding timestamps, as 
decoding is done by
+the probed decoder, VOB. And so it might be necessary to generate the 
presentation
+timestamps for formats that need them via @command{-fflag +genpts}.
+@item
+The chapter and language stream information is present in the side-files 
(BUP/IFO),
+that are parsed for identifying the correct main video-title-set, but are not 
attached
+to the stream information.
+@end itemize
+
+The accepted options are:
+@table @option
+
+@item angle
+DVD angle
+
+@item title
+DVD title to read (VIDEO_TS/VTS_??_??.mpls)
+
+@end table
+
+@subsection Examples
+
+Read longest title from DVD mounted to /mnt/dvd:
+@example
+dvd:/mnt/dvd
+@end example
+
+Read longest title from DVD image backup

[FFmpeg-devel] [PATCH v4] avformat/dvd: new dvd:// protocol for reading dvd folder/images

2023-01-15 Thread Stanislav Ionascu
dvd:// protocol uses libdvdread for opening folders and/or disc-images,
it then either identifies the longest title-set, or uses the title-set
parameter.

After opening the dvd, libdvdread-protocol will read and output all
VOBs, in the cell and pack sequence defined by the program-chain.

The (split)-VOB content that is streamed from the folder/disc by
libdvdread, is given to ffmpeg probed demuxer/decoder, which decodes
and presents the frames.

The chapter and language stream information is present in the
side-files (BUP/IFO), which are parsed for identifying the correct
main video-title-set, but not attached to the stream information.

Signed-off-by: Stanislav Ionascu 
---
 configure   |   5 +
 libavformat/Makefile|   1 +
 libavformat/dvd.c   | 327 
 libavformat/protocols.c |   1 +
 4 files changed, 334 insertions(+)
 create mode 100644 libavformat/dvd.c

diff --git a/configure b/configure
index df69d39669..4dcd1f1484 100755
--- a/configure
+++ b/configure
@@ -230,6 +230,7 @@ External library support:
   --enable-libdavs2enable AVS2 decoding via libdavs2 [no]
   --enable-libdc1394   enable IIDC-1394 grabbing using libdc1394
and libraw1394 [no]
+  --enable-libdvdread  enable DVD reading using libdvdread [no]
   --enable-libfdk-aac  enable AAC de/encoding via libfdk-aac [no]
   --enable-libfliteenable flite (voice synthesis) support via libflite 
[no]
   --enable-libfontconfig   enable libfontconfig, useful for drawtext filter 
[no]
@@ -1814,6 +1815,7 @@ EXTERNAL_LIBRARY_LIST="
 libdav1d
 libdc1394
 libdrm
+libdvdread
 libflite
 libfontconfig
 libfreetype
@@ -3557,6 +3559,7 @@ xv_outdev_deps="xlib_xv xlib_x11 xlib_xext"
 # protocols
 async_protocol_deps="threads"
 bluray_protocol_deps="libbluray"
+dvd_protocol_deps="libdvdread"
 ffrtmpcrypt_protocol_conflict="librtmp_protocol"
 ffrtmpcrypt_protocol_deps_any="gcrypt gmp openssl mbedtls"
 ffrtmpcrypt_protocol_select="tcp_protocol"
@@ -6568,6 +6571,8 @@ enabled libdav1d  && require_pkg_config libdav1d 
"dav1d >= 0.5.0" "dav1d
 enabled libdavs2  && require_pkg_config libdavs2 "davs2 >= 1.6.0" 
davs2.h davs2_decoder_open
 enabled libdc1394 && require_pkg_config libdc1394 libdc1394-2 
dc1394/dc1394.h dc1394_new
 enabled libdrm&& require_pkg_config libdrm libdrm xf86drm.h 
drmGetVersion
+enabled libdvdread&& enable dvdread
+enabled dvdread   && require_pkg_config libdvdread dvdread 
"dvdread/dvd_reader.h" DVDOpen2
 enabled libfdk_aac&& { check_pkg_config libfdk_aac fdk-aac 
"fdk-aac/aacenc_lib.h" aacEncOpen ||
{ require libfdk_aac fdk-aac/aacenc_lib.h 
aacEncOpen -lfdk-aac &&
  warn "using libfdk without pkg-config"; } }
diff --git a/libavformat/Makefile b/libavformat/Makefile
index fa71ec12f7..b58ea0f4ac 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -644,6 +644,7 @@ OBJS-$(CONFIG_CONCAT_PROTOCOL)   += concat.o
 OBJS-$(CONFIG_CONCATF_PROTOCOL)  += concat.o
 OBJS-$(CONFIG_CRYPTO_PROTOCOL)   += crypto.o
 OBJS-$(CONFIG_DATA_PROTOCOL) += data_uri.o
+OBJS-$(CONFIG_DVD_PROTOCOL)  += dvd.o
 OBJS-$(CONFIG_FFRTMPCRYPT_PROTOCOL)  += rtmpcrypt.o rtmpdigest.o rtmpdh.o
 OBJS-$(CONFIG_FFRTMPHTTP_PROTOCOL)   += rtmphttp.o
 OBJS-$(CONFIG_FILE_PROTOCOL) += file.o
diff --git a/libavformat/dvd.c b/libavformat/dvd.c
new file mode 100644
index 00..7a70189c69
--- /dev/null
+++ b/libavformat/dvd.c
@@ -0,0 +1,327 @@
+/*
+ * DVD (libdvdread) protocol
+ * Copyright (c) 2023 Stan Ionascu 
+ *
+ * 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 
+#include 
+#include 
+
+#include "libavformat/avformat.h"
+#include "libavformat/url.h"
+#include "libavutil/avstring.h"
+#include "libavutil/opt.h"
+
+#define DVD_PROTO_PREFIX "dvd:"
+#define DVD_SECTOR_SIZE 2048
+
+typ

[FFmpeg-devel] [PATCH v3] avformat/dvd: new dvd:// protocol for reading dvd folder/images

2023-01-08 Thread Stanislav Ionascu
dvd:// protocol uses libdvdread for opening folders and/or disc-images,
it then either identifies the longest title-set, or uses the title-set
parameter.

After opening the dvd, it will read and output all VOBs, in sequence
defined by the program-chain.

Signed-off-by: Stanislav Ionascu 
---
 configure   |   5 +
 libavformat/Makefile|   1 +
 libavformat/dvd.c   | 327 
 libavformat/protocols.c |   1 +
 4 files changed, 334 insertions(+)
 create mode 100644 libavformat/dvd.c

diff --git a/configure b/configure
index 870d426b0e..312144c105 100755
--- a/configure
+++ b/configure
@@ -230,6 +230,7 @@ External library support:
   --enable-libdavs2enable AVS2 decoding via libdavs2 [no]
   --enable-libdc1394   enable IIDC-1394 grabbing using libdc1394
and libraw1394 [no]
+  --enable-libdvdread  enable DVD reading using libdvdread [no]
   --enable-libfdk-aac  enable AAC de/encoding via libfdk-aac [no]
   --enable-libfliteenable flite (voice synthesis) support via libflite 
[no]
   --enable-libfontconfig   enable libfontconfig, useful for drawtext filter 
[no]
@@ -1814,6 +1815,7 @@ EXTERNAL_LIBRARY_LIST="
 libdav1d
 libdc1394
 libdrm
+libdvdread
 libflite
 libfontconfig
 libfreetype
@@ -3557,6 +3559,7 @@ xv_outdev_deps="xlib_xv xlib_x11 xlib_xext"
 # protocols
 async_protocol_deps="threads"
 bluray_protocol_deps="libbluray"
+dvd_protocol_deps="libdvdread"
 ffrtmpcrypt_protocol_conflict="librtmp_protocol"
 ffrtmpcrypt_protocol_deps_any="gcrypt gmp openssl mbedtls"
 ffrtmpcrypt_protocol_select="tcp_protocol"
@@ -6568,6 +6571,8 @@ enabled libdav1d  && require_pkg_config libdav1d 
"dav1d >= 0.5.0" "dav1d
 enabled libdavs2  && require_pkg_config libdavs2 "davs2 >= 1.6.0" 
davs2.h davs2_decoder_open
 enabled libdc1394 && require_pkg_config libdc1394 libdc1394-2 
dc1394/dc1394.h dc1394_new
 enabled libdrm&& require_pkg_config libdrm libdrm xf86drm.h 
drmGetVersion
+enabled libdvdread&& enable dvdread
+enabled dvdread   && require_pkg_config libdvdread dvdread 
"dvdread/dvd_reader.h" DVDOpen2
 enabled libfdk_aac&& { check_pkg_config libfdk_aac fdk-aac 
"fdk-aac/aacenc_lib.h" aacEncOpen ||
{ require libfdk_aac fdk-aac/aacenc_lib.h 
aacEncOpen -lfdk-aac &&
  warn "using libfdk without pkg-config"; } }
diff --git a/libavformat/Makefile b/libavformat/Makefile
index d7f198bf39..a31fafcadb 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -644,6 +644,7 @@ OBJS-$(CONFIG_CONCAT_PROTOCOL)   += concat.o
 OBJS-$(CONFIG_CONCATF_PROTOCOL)  += concat.o
 OBJS-$(CONFIG_CRYPTO_PROTOCOL)   += crypto.o
 OBJS-$(CONFIG_DATA_PROTOCOL) += data_uri.o
+OBJS-$(CONFIG_DVD_PROTOCOL)  += dvd.o
 OBJS-$(CONFIG_FFRTMPCRYPT_PROTOCOL)  += rtmpcrypt.o rtmpdigest.o rtmpdh.o
 OBJS-$(CONFIG_FFRTMPHTTP_PROTOCOL)   += rtmphttp.o
 OBJS-$(CONFIG_FILE_PROTOCOL) += file.o
diff --git a/libavformat/dvd.c b/libavformat/dvd.c
new file mode 100644
index 00..7a70189c69
--- /dev/null
+++ b/libavformat/dvd.c
@@ -0,0 +1,327 @@
+/*
+ * DVD (libdvdread) protocol
+ * Copyright (c) 2023 Stan Ionascu 
+ *
+ * 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 
+#include 
+#include 
+
+#include "libavformat/avformat.h"
+#include "libavformat/url.h"
+#include "libavutil/avstring.h"
+#include "libavutil/opt.h"
+
+#define DVD_PROTO_PREFIX "dvd:"
+#define DVD_SECTOR_SIZE 2048
+
+typedef struct {
+const AVClass *class;
+
+dvd_reader_t *dvd;
+dvd_logger_cb dvd_logger;
+
+int title_nr;
+int angle_nr;
+dvd_file_t *dvd_title_file;
+ifo_handle_t *vmg_ifo;
+ifo_handle_t *vts_ifo;
+pgc_t *current_pgc;
+int current_cell;
+
+int start_sector;
+int current_sector;
+int end_sector;
+
+} DvdProtocolContext;
+
+static int bcd2int(int

[FFmpeg-devel] [PATCH v2] avformat/dvd: new dvd:// protocol for reading dvd folder/images

2023-01-07 Thread Stanislav Ionascu
dvd:// protocol uses libdvdread for opening folders and/or disc-images,
it then either identifies the longest title-set, or uses the title-set
parameter.

After opening the dvd, it will read and output all VOBs, in sequence
defined by the program-chain.

Signed-off-by: Stanislav Ionascu 
---
 configure   |   5 +
 libavformat/Makefile|   1 +
 libavformat/dvd.c   | 307 
 libavformat/protocols.c |   1 +
 4 files changed, 314 insertions(+)
 create mode 100644 libavformat/dvd.c

diff --git a/configure b/configure
index 870d426b0e..312144c105 100755
--- a/configure
+++ b/configure
@@ -230,6 +230,7 @@ External library support:
   --enable-libdavs2enable AVS2 decoding via libdavs2 [no]
   --enable-libdc1394   enable IIDC-1394 grabbing using libdc1394
and libraw1394 [no]
+  --enable-libdvdread  enable DVD reading using libdvdread [no]
   --enable-libfdk-aac  enable AAC de/encoding via libfdk-aac [no]
   --enable-libfliteenable flite (voice synthesis) support via libflite 
[no]
   --enable-libfontconfig   enable libfontconfig, useful for drawtext filter 
[no]
@@ -1814,6 +1815,7 @@ EXTERNAL_LIBRARY_LIST="
 libdav1d
 libdc1394
 libdrm
+libdvdread
 libflite
 libfontconfig
 libfreetype
@@ -3557,6 +3559,7 @@ xv_outdev_deps="xlib_xv xlib_x11 xlib_xext"
 # protocols
 async_protocol_deps="threads"
 bluray_protocol_deps="libbluray"
+dvd_protocol_deps="libdvdread"
 ffrtmpcrypt_protocol_conflict="librtmp_protocol"
 ffrtmpcrypt_protocol_deps_any="gcrypt gmp openssl mbedtls"
 ffrtmpcrypt_protocol_select="tcp_protocol"
@@ -6568,6 +6571,8 @@ enabled libdav1d  && require_pkg_config libdav1d 
"dav1d >= 0.5.0" "dav1d
 enabled libdavs2  && require_pkg_config libdavs2 "davs2 >= 1.6.0" 
davs2.h davs2_decoder_open
 enabled libdc1394 && require_pkg_config libdc1394 libdc1394-2 
dc1394/dc1394.h dc1394_new
 enabled libdrm&& require_pkg_config libdrm libdrm xf86drm.h 
drmGetVersion
+enabled libdvdread&& enable dvdread
+enabled dvdread   && require_pkg_config libdvdread dvdread 
"dvdread/dvd_reader.h" DVDOpen2
 enabled libfdk_aac&& { check_pkg_config libfdk_aac fdk-aac 
"fdk-aac/aacenc_lib.h" aacEncOpen ||
{ require libfdk_aac fdk-aac/aacenc_lib.h 
aacEncOpen -lfdk-aac &&
  warn "using libfdk without pkg-config"; } }
diff --git a/libavformat/Makefile b/libavformat/Makefile
index d7f198bf39..a31fafcadb 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -644,6 +644,7 @@ OBJS-$(CONFIG_CONCAT_PROTOCOL)   += concat.o
 OBJS-$(CONFIG_CONCATF_PROTOCOL)  += concat.o
 OBJS-$(CONFIG_CRYPTO_PROTOCOL)   += crypto.o
 OBJS-$(CONFIG_DATA_PROTOCOL) += data_uri.o
+OBJS-$(CONFIG_DVD_PROTOCOL)  += dvd.o
 OBJS-$(CONFIG_FFRTMPCRYPT_PROTOCOL)  += rtmpcrypt.o rtmpdigest.o rtmpdh.o
 OBJS-$(CONFIG_FFRTMPHTTP_PROTOCOL)   += rtmphttp.o
 OBJS-$(CONFIG_FILE_PROTOCOL) += file.o
diff --git a/libavformat/dvd.c b/libavformat/dvd.c
new file mode 100644
index 00..8d7780f760
--- /dev/null
+++ b/libavformat/dvd.c
@@ -0,0 +1,307 @@
+/*
+ * DVD (libdvdread) protocol
+ * Copyright (c) 2023 Stan Ionascu 
+ *
+ * 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 
+#include 
+#include 
+
+#include "libavformat/avformat.h"
+#include "libavformat/url.h"
+#include "libavutil/avstring.h"
+#include "libavutil/opt.h"
+
+#define DVD_PROTO_PREFIX "dvd:"
+#define DVD_SECTOR_SIZE 2048
+
+typedef struct {
+const AVClass *class;
+
+dvd_reader_t *dvd;
+dvd_logger_cb dvd_logger;
+
+int title_set_nr;
+int angle_nr;
+dvd_file_t *dvd_title_file;
+ifo_handle_t *vmg_ifo;
+ifo_handle_t *vts_ifo;
+pgc_t *current_pgc;
+int current_cell;
+
+int start_sector;
+int current_sector;
+int end_sector;
+
+} DvdProtocolContext;

Re: [FFmpeg-devel] [PATCH 1/1] avformat/matroska: fully parse stsd atom in v_quicktime tracks

2019-08-22 Thread Stanislav Ionascu
Hi!

On Tue, Aug 20, 2019 at 10:19 AM Michael Niedermayer
 wrote:
>
> On Sun, Aug 18, 2019 at 12:32:03PM +0200, Stanislav Ionascu wrote:
> > Hi,
> >
> > thanks for looking into this.
> >
> > On Sun, Aug 18, 2019 at 4:55 AM Andreas Rheinhardt
> >  wrote:
> > >
> > > Hello,
> > >
> > > I am no expert on mov (and so this should definitely be looked at from
> > > someone who is), but I have some points:
> > >
> > > Stanislav Ionascu:
> > > > diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
> > > > index 1ea9b807e6..2a397c909a 100644
> > > > --- a/libavformat/matroskadec.c
> > > > +++ b/libavformat/matroskadec.c
> > > > @@ -2473,25 +2473,58 @@ static int
> > > matroska_parse_tracks(AVFormatContext *s)
> > > >  } else if (!strcmp(track->codec_id, "V_QUICKTIME") &&
> > > > (track->codec_priv.size >= 21)  &&
> > > > (track->codec_priv.data)) {
> > > > +MOVStreamContext *msc;
> > > > +MOVContext *mc = NULL;
> > > > +void *priv_data;
> > > > +int nb_streams;
> > >
> > > You could initialize nb_streams and priv_data here. And the
> > > initialization of mc is unnecessary.
> >
> > Done.
> >
> > >
> > > >  int ret = get_qt_codec(track, , _id);
> > > >  if (ret < 0)
> > > >  return ret;
> > > > -if (codec_id == AV_CODEC_ID_NONE &&
> > > AV_RL32(track->codec_priv.data+4) == AV_RL32("SMI ")) {
> > > > -fourcc = MKTAG('S','V','Q','3');
> > > > -codec_id = ff_codec_get_id(ff_codec_movvideo_tags,
> > > fourcc);
> > > > +mc = av_mallocz(sizeof(*mc));
> > > > +if (!mc)
> > > > +return AVERROR(ENOMEM);
> > > > +priv_data = st->priv_data;
> > > > +nb_streams = s->nb_streams;
> > > > +mc->fc = s;
> > > > +st->priv_data = msc = av_mallocz(sizeof(MOVStreamContext));
> > > > +if (!msc) {
> > > > +av_free(mc);
> > > > +st->priv_data = priv_data;
> > > > +return AVERROR(ENOMEM);
> > > >  }
> > > > +ffio_init_context(, track->codec_priv.data,
> > > > +  track->codec_priv.size,
> > > > +  0, NULL, NULL, NULL, NULL);
> > > > +
> > > > +/* ff_mov_read_stsd_entries updates stream s->nb_streams-1,
> > > > + * so set it temporarily to indicate which stream to
> > > update. */
> > > > +s->nb_streams = st->index + 1;
> > > > +ff_mov_read_stsd_entries(mc, , 1);
> > >
> > > Is it intentional that you don't check the return value here?.
> >
> > Added the check.
> >
> > >
> > > > +
> > > > +/* copy palette from MOVStreamContext */
> > > > +track->has_palette = msc->has_palette;
> > > > +if (track->has_palette) {
> > > > +/* leave bit_depth = -1, to reuse
> > > bits_per_coded_sample  */
> > > > +memcpy(track->palette, msc->palette, AVPALETTE_COUNT);
> > >
> > > In case the track has a palette, your patch would only copy 256 bytes
> > > of it, but a palette consists of 256 uint32_t. (This link
> > > https://drive.google.com/drive/folders/0B3_pEBoLs0faWElmM2FnLTZYNlk
> > > from the commit message that added the palette stuff seems to still
> > > work if you need samples for this.)
> >
> > Indeed. I've corrected that. Also remuxed all mov's into mkv's, and
> > verified that they all still work.
> >
> > >
> > > > +}
> > > > +
> > > > +av_free(msc);
> > > > +av_free(mc);
> > > > +st->priv_data = priv_data;
> > > > +s->nb_streams = nb_streams;
> > > > +fourcc = st->codecpar->codec_tag;
> > > > +codec_id = st->codecpar->codec_id;
> > > > +
> > > 

Re: [FFmpeg-devel] [PATCH 1/1] avformat/matroska: fully parse stsd atom in v_quicktime tracks

2019-08-18 Thread Stanislav Ionascu
Hi,

thanks for looking into this.

On Sun, Aug 18, 2019 at 4:55 AM Andreas Rheinhardt
 wrote:
>
> Hello,
>
> I am no expert on mov (and so this should definitely be looked at from
> someone who is), but I have some points:
>
> Stanislav Ionascu:
> > diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
> > index 1ea9b807e6..2a397c909a 100644
> > --- a/libavformat/matroskadec.c
> > +++ b/libavformat/matroskadec.c
> > @@ -2473,25 +2473,58 @@ static int
> matroska_parse_tracks(AVFormatContext *s)
> >  } else if (!strcmp(track->codec_id, "V_QUICKTIME") &&
> > (track->codec_priv.size >= 21)  &&
> > (track->codec_priv.data)) {
> > +MOVStreamContext *msc;
> > +MOVContext *mc = NULL;
> > +void *priv_data;
> > +int nb_streams;
>
> You could initialize nb_streams and priv_data here. And the
> initialization of mc is unnecessary.

Done.

>
> >  int ret = get_qt_codec(track, , _id);
> >  if (ret < 0)
> >  return ret;
> > -if (codec_id == AV_CODEC_ID_NONE &&
> AV_RL32(track->codec_priv.data+4) == AV_RL32("SMI ")) {
> > -fourcc = MKTAG('S','V','Q','3');
> > -codec_id = ff_codec_get_id(ff_codec_movvideo_tags,
> fourcc);
> > +mc = av_mallocz(sizeof(*mc));
> > +if (!mc)
> > +return AVERROR(ENOMEM);
> > +priv_data = st->priv_data;
> > +nb_streams = s->nb_streams;
> > +mc->fc = s;
> > +st->priv_data = msc = av_mallocz(sizeof(MOVStreamContext));
> > +if (!msc) {
> > +av_free(mc);
> > +st->priv_data = priv_data;
> > +return AVERROR(ENOMEM);
> >  }
> > +ffio_init_context(, track->codec_priv.data,
> > +  track->codec_priv.size,
> > +  0, NULL, NULL, NULL, NULL);
> > +
> > +/* ff_mov_read_stsd_entries updates stream s->nb_streams-1,
> > + * so set it temporarily to indicate which stream to
> update. */
> > +s->nb_streams = st->index + 1;
> > +ff_mov_read_stsd_entries(mc, , 1);
>
> Is it intentional that you don't check the return value here?.

Added the check.

>
> > +
> > +/* copy palette from MOVStreamContext */
> > +track->has_palette = msc->has_palette;
> > +if (track->has_palette) {
> > +/* leave bit_depth = -1, to reuse
> bits_per_coded_sample  */
> > +memcpy(track->palette, msc->palette, AVPALETTE_COUNT);
>
> In case the track has a palette, your patch would only copy 256 bytes
> of it, but a palette consists of 256 uint32_t. (This link
> https://drive.google.com/drive/folders/0B3_pEBoLs0faWElmM2FnLTZYNlk
> from the commit message that added the palette stuff seems to still
> work if you need samples for this.)

Indeed. I've corrected that. Also remuxed all mov's into mkv's, and
verified that they all still work.

>
> > +}
> > +
> > +av_free(msc);
> > +av_free(mc);
> > +st->priv_data = priv_data;
> > +s->nb_streams = nb_streams;
> > +fourcc = st->codecpar->codec_tag;
> > +codec_id = st->codecpar->codec_id;
> > +
> > +av_log(matroska->ctx, AV_LOG_TRACE,
> > +   "mov FourCC found %s.\n", av_fourcc2str(fourcc));
> > +
> >  if (codec_id == AV_CODEC_ID_NONE)
> >  av_log(matroska->ctx, AV_LOG_ERROR,
> > -   "mov FourCC not found %s.\n",
> av_fourcc2str(fourcc));
>
> If the codec_id turns out to be AV_CODEC_ID_NONE, two strings will be
> output (at least on loglevel trace): "mov FourCC found %s.\n" and then
> "mov FourCC not found %s.\n". The first of these is superfluous in
> this case.

Removed it, as stsd parser will also trace the FourCC code.

>
> > -if (track->codec_priv.size >= 86) {
> > -bit_depth = AV_RB16(track->codec_priv.data + 82);
> > -ffio_init_context(, track->codec_priv.data,
> > -  track->codec_priv.size,
> > -  0, NULL, NULL, NULL, NULL);
> > -  

Re: [FFmpeg-devel] [PATCH 1/1] avformat/matroska: fully parse stsd atom in v_quicktime tracks

2019-08-17 Thread Stanislav Ionascu
Hi!

On Sat, Aug 17, 2019 at 12:53 AM Michael Niedermayer
 wrote:
>
> On Thu, Aug 15, 2019 at 07:59:28AM +0200, Stanislav Ionascu wrote:
> > Hi,
> >
> > On Wed, Aug 14, 2019 at 11:50 PM Michael Niedermayer
> >  wrote:
> > >
> > > On Wed, Aug 14, 2019 at 08:44:11PM +0200, Stanislav Ionascu wrote:
> > > > On Tue, Aug 13, 2019 at 10:22 PM Andreas Rheinhardt
> > > >  wrote:
> > > > >
> > > > > Stanislav Ionascu:
> > > > > > Per matroska spec, v_quicktime contains the complete stsd atom, 
> > > > > > after
> > > > > > the mandatory size + fourcc. By properly parsing the hvcc sub-atoms 
> > > > > > of
> > > > > > the track, it becomes possible to demux/decode mp4/mov tracks 
> > > > > > stored as is
> > > > > > in matroska containers.
> > > > > >
> > > > > > Also dvh1 in stsd in matroska is more likely hevc codec than dv.
> > > > > >
> > > > > > Signed-off-by: Stanislav Ionascu 
> > > > > > ---
> > > > > >  libavformat/matroskadec.c | 51 
> > > > > > +++
> > > > > >  1 file changed, 36 insertions(+), 15 deletions(-)
> > > > > >
> > > > > > diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
> > > > > > index 4e20f15792..88bc89c545 100644
> > > > > > --- a/libavformat/matroskadec.c
> > > > > > +++ b/libavformat/matroskadec.c
> > > > > > @@ -2473,25 +2473,46 @@ static int 
> > > > > > matroska_parse_tracks(AVFormatContext *s)
> > > > > >  } else if (!strcmp(track->codec_id, "V_QUICKTIME") &&
> > > > > > (track->codec_priv.size >= 21)  &&
> > > > > > (track->codec_priv.data)) {
> > > > > > +MOVStreamContext *msc;
> > > > > > +MOVContext *mc = NULL;
> > > > > > +AVIOContext *stsd_ctx = NULL;
> > > > > > +void *priv_data;
> > > > > > +int nb_streams;
> > > > > >  int ret = get_qt_codec(track, , _id);
> > > > > >  if (ret < 0)
> > > > > >  return ret;
> > > > > > -if (codec_id == AV_CODEC_ID_NONE && 
> > > > > > AV_RL32(track->codec_priv.data+4) == AV_RL32("SMI ")) {
> > > > > > -fourcc = MKTAG('S','V','Q','3');
> > > > > > -codec_id = ff_codec_get_id(ff_codec_movvideo_tags, 
> > > > > > fourcc);
> > > > > > +av_log(matroska->ctx, AV_LOG_TRACE,
> > > > > > +   "FourCC found %s.\n", av_fourcc2str(fourcc));
> > > > > > +priv_data = st->priv_data;
> > > > > > +nb_streams = s->nb_streams;
> > > > > > +mc = av_mallocz(sizeof(*mc));
> > > > > > +if (!mc)
> > > > > > +return AVERROR(ENOMEM);
> > > > > > +stsd_ctx = avio_alloc_context(track->codec_priv.data,
> > > > > > +track->codec_priv.size,
> > > > > > +0, NULL, NULL, NULL, NULL);
> > > > > > +if (!stsd_ctx)
> > > > > > +return AVERROR(ENOMEM);
> > > > > I haven't looked at this patch deeply yet, but it seems to me that you
> > > > > should rather use ffio_init_context like it is done in the code that
> > > > > you intend to delete. That saves allocating and freeing stsd_ctx. You
> > > > > can even reuse the AVIOContext b that already exists on the stack.
> > > >
> > > > Done.
> > > >
> > > > > > +mc->fc = s;
> > > > > > +st->priv_data = msc = 
> > > > > > av_mallocz(sizeof(MOVStreamContext));
> > > > > > +if (!msc) {
> > > > > > +av_free(mc);
> > > > > > +st->priv_data = priv_data;
> > > > > > +return AVERROR(ENOMEM);
> > > > > &

Re: [FFmpeg-devel] [PATCH 1/1] avformat/matroska: fully parse stsd atom in v_quicktime tracks

2019-08-15 Thread Stanislav Ionascu
Hi,

On Wed, Aug 14, 2019 at 11:50 PM Michael Niedermayer
 wrote:
>
> On Wed, Aug 14, 2019 at 08:44:11PM +0200, Stanislav Ionascu wrote:
> > On Tue, Aug 13, 2019 at 10:22 PM Andreas Rheinhardt
> >  wrote:
> > >
> > > Stanislav Ionascu:
> > > > Per matroska spec, v_quicktime contains the complete stsd atom, after
> > > > the mandatory size + fourcc. By properly parsing the hvcc sub-atoms of
> > > > the track, it becomes possible to demux/decode mp4/mov tracks stored as 
> > > > is
> > > > in matroska containers.
> > > >
> > > > Also dvh1 in stsd in matroska is more likely hevc codec than dv.
> > > >
> > > > Signed-off-by: Stanislav Ionascu 
> > > > ---
> > > >  libavformat/matroskadec.c | 51 +++
> > > >  1 file changed, 36 insertions(+), 15 deletions(-)
> > > >
> > > > diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
> > > > index 4e20f15792..88bc89c545 100644
> > > > --- a/libavformat/matroskadec.c
> > > > +++ b/libavformat/matroskadec.c
> > > > @@ -2473,25 +2473,46 @@ static int 
> > > > matroska_parse_tracks(AVFormatContext *s)
> > > >  } else if (!strcmp(track->codec_id, "V_QUICKTIME") &&
> > > > (track->codec_priv.size >= 21)  &&
> > > > (track->codec_priv.data)) {
> > > > +MOVStreamContext *msc;
> > > > +MOVContext *mc = NULL;
> > > > +AVIOContext *stsd_ctx = NULL;
> > > > +void *priv_data;
> > > > +int nb_streams;
> > > >  int ret = get_qt_codec(track, , _id);
> > > >  if (ret < 0)
> > > >  return ret;
> > > > -if (codec_id == AV_CODEC_ID_NONE && 
> > > > AV_RL32(track->codec_priv.data+4) == AV_RL32("SMI ")) {
> > > > -fourcc = MKTAG('S','V','Q','3');
> > > > -codec_id = ff_codec_get_id(ff_codec_movvideo_tags, 
> > > > fourcc);
> > > > +av_log(matroska->ctx, AV_LOG_TRACE,
> > > > +   "FourCC found %s.\n", av_fourcc2str(fourcc));
> > > > +priv_data = st->priv_data;
> > > > +nb_streams = s->nb_streams;
> > > > +mc = av_mallocz(sizeof(*mc));
> > > > +if (!mc)
> > > > +return AVERROR(ENOMEM);
> > > > +stsd_ctx = avio_alloc_context(track->codec_priv.data,
> > > > +track->codec_priv.size,
> > > > +0, NULL, NULL, NULL, NULL);
> > > > +if (!stsd_ctx)
> > > > +return AVERROR(ENOMEM);
> > > I haven't looked at this patch deeply yet, but it seems to me that you
> > > should rather use ffio_init_context like it is done in the code that
> > > you intend to delete. That saves allocating and freeing stsd_ctx. You
> > > can even reuse the AVIOContext b that already exists on the stack.
> >
> > Done.
> >
> > > > +mc->fc = s;
> > > > +st->priv_data = msc = av_mallocz(sizeof(MOVStreamContext));
> > > > +if (!msc) {
> > > > +av_free(mc);
> > > > +st->priv_data = priv_data;
> > > > +return AVERROR(ENOMEM);
> > > >  }
> > > > -if (codec_id == AV_CODEC_ID_NONE)
> > > > -av_log(matroska->ctx, AV_LOG_ERROR,
> > > > -   "mov FourCC not found %s.\n", 
> > > > av_fourcc2str(fourcc));
> > > > -if (track->codec_priv.size >= 86) {
> > > > -bit_depth = AV_RB16(track->codec_priv.data + 82);
> > > > -ffio_init_context(, track->codec_priv.data,
> > > > -  track->codec_priv.size,
> > > > -  0, NULL, NULL, NULL, NULL);
> > > > -if (ff_get_qtpalette(codec_id, , track->palette)) {
> > > > -bit_depth &= 0x1F;
> > > > -track->has_palette = 1;
> > > Why are you removing 

[FFmpeg-devel] [PATCH v2] avformat/matroskadec: properly parse stsd in v_quicktime

2019-08-14 Thread Stanislav Ionascu
Per matroska spec, v_quicktime contains the complete stsd atom, after
the mandatory size + fourcc. By properly parsing the hvcc sub-atoms of
the track, it becomes possible to demux/decode mp4/mov tracks stored as is
in matroska containers.

Also dvh1 in stsd in matroska is more likely hevc codec than dv.
QuickTime palette parsing is reused from the stsd parser results.

Signed-off-by: Stanislav Ionascu 
---
 libavformat/matroskadec.c | 62 +++
 1 file changed, 44 insertions(+), 18 deletions(-)

diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index 4e20f15792..9ca9efe6b1 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -2473,25 +2473,51 @@ static int matroska_parse_tracks(AVFormatContext *s)
 } else if (!strcmp(track->codec_id, "V_QUICKTIME") &&
(track->codec_priv.size >= 21)  &&
(track->codec_priv.data)) {
-int ret = get_qt_codec(track, , _id);
-if (ret < 0)
-return ret;
-if (codec_id == AV_CODEC_ID_NONE && 
AV_RL32(track->codec_priv.data+4) == AV_RL32("SMI ")) {
-fourcc = MKTAG('S','V','Q','3');
-codec_id = ff_codec_get_id(ff_codec_movvideo_tags, fourcc);
+MOVStreamContext *msc;
+MOVContext *mc = NULL;
+void *priv_data;
+int nb_streams;
+priv_data = st->priv_data;
+nb_streams = s->nb_streams;
+mc = av_mallocz(sizeof(*mc));
+if (!mc)
+return AVERROR(ENOMEM);
+mc->fc = s;
+st->priv_data = msc = av_mallocz(sizeof(MOVStreamContext));
+if (!msc) {
+av_free(mc);
+st->priv_data = priv_data;
+return AVERROR(ENOMEM);
 }
-if (codec_id == AV_CODEC_ID_NONE)
-av_log(matroska->ctx, AV_LOG_ERROR,
-   "mov FourCC not found %s.\n", av_fourcc2str(fourcc));
-if (track->codec_priv.size >= 86) {
-bit_depth = AV_RB16(track->codec_priv.data + 82);
-ffio_init_context(, track->codec_priv.data,
-  track->codec_priv.size,
-  0, NULL, NULL, NULL, NULL);
-if (ff_get_qtpalette(codec_id, , track->palette)) {
-bit_depth &= 0x1F;
-track->has_palette = 1;
-}
+ffio_init_context(, track->codec_priv.data,
+  track->codec_priv.size,
+  0, NULL, NULL, NULL, NULL);
+
+/* ff_mov_read_stsd_entries updates stream s->nb_streams-1,
+ * so set it temporarily to indicate which stream to update. */
+s->nb_streams = st->index + 1;
+ff_mov_read_stsd_entries(mc, , 1);
+
+/* copy palette from MOVStreamContext */
+track->has_palette = msc->has_palette;
+if (track->has_palette) {
+/* leave bit_depth = -1, to reuse bits_per_coded_sample  */
+memcpy(track->palette, msc->palette, AVPALETTE_COUNT);
+}
+
+av_free(msc);
+av_free(mc);
+st->priv_data = priv_data;
+s->nb_streams = nb_streams;
+fourcc = st->codecpar->codec_tag;
+codec_id = st->codecpar->codec_id;
+
+av_log(matroska->ctx, AV_LOG_TRACE,
+   "mov FourCC found %s.\n", av_fourcc2str(fourcc));
+
+// dvh1 in mkv is likely HEVC
+if (st->codecpar->codec_tag == MKTAG('d','v','h','1')) {
+codec_id = AV_CODEC_ID_HEVC;
 }
 } else if (codec_id == AV_CODEC_ID_PCM_S16BE) {
 switch (track->audio.bitdepth) {
-- 
2.20.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/1] avformat/matroska: fully parse stsd atom in v_quicktime tracks

2019-08-14 Thread Stanislav Ionascu
On Tue, Aug 13, 2019 at 10:22 PM Andreas Rheinhardt
 wrote:
>
> Stanislav Ionascu:
> > Per matroska spec, v_quicktime contains the complete stsd atom, after
> > the mandatory size + fourcc. By properly parsing the hvcc sub-atoms of
> > the track, it becomes possible to demux/decode mp4/mov tracks stored as is
> > in matroska containers.
> >
> > Also dvh1 in stsd in matroska is more likely hevc codec than dv.
> >
> > Signed-off-by: Stanislav Ionascu 
> > ---
> >  libavformat/matroskadec.c | 51 +++
> >  1 file changed, 36 insertions(+), 15 deletions(-)
> >
> > diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
> > index 4e20f15792..88bc89c545 100644
> > --- a/libavformat/matroskadec.c
> > +++ b/libavformat/matroskadec.c
> > @@ -2473,25 +2473,46 @@ static int matroska_parse_tracks(AVFormatContext *s)
> >  } else if (!strcmp(track->codec_id, "V_QUICKTIME") &&
> > (track->codec_priv.size >= 21)  &&
> > (track->codec_priv.data)) {
> > +MOVStreamContext *msc;
> > +MOVContext *mc = NULL;
> > +AVIOContext *stsd_ctx = NULL;
> > +void *priv_data;
> > +int nb_streams;
> >  int ret = get_qt_codec(track, , _id);
> >  if (ret < 0)
> >  return ret;
> > -if (codec_id == AV_CODEC_ID_NONE && 
> > AV_RL32(track->codec_priv.data+4) == AV_RL32("SMI ")) {
> > -fourcc = MKTAG('S','V','Q','3');
> > -codec_id = ff_codec_get_id(ff_codec_movvideo_tags, fourcc);
> > +av_log(matroska->ctx, AV_LOG_TRACE,
> > +   "FourCC found %s.\n", av_fourcc2str(fourcc));
> > +priv_data = st->priv_data;
> > +nb_streams = s->nb_streams;
> > +mc = av_mallocz(sizeof(*mc));
> > +if (!mc)
> > +return AVERROR(ENOMEM);
> > +stsd_ctx = avio_alloc_context(track->codec_priv.data,
> > +track->codec_priv.size,
> > +0, NULL, NULL, NULL, NULL);
> > +if (!stsd_ctx)
> > +return AVERROR(ENOMEM);
> I haven't looked at this patch deeply yet, but it seems to me that you
> should rather use ffio_init_context like it is done in the code that
> you intend to delete. That saves allocating and freeing stsd_ctx. You
> can even reuse the AVIOContext b that already exists on the stack.

Done.

> > +mc->fc = s;
> > +st->priv_data = msc = av_mallocz(sizeof(MOVStreamContext));
> > +if (!msc) {
> > +av_free(mc);
> > +st->priv_data = priv_data;
> > +return AVERROR(ENOMEM);
> >  }
> > -if (codec_id == AV_CODEC_ID_NONE)
> > -av_log(matroska->ctx, AV_LOG_ERROR,
> > -   "mov FourCC not found %s.\n", 
> > av_fourcc2str(fourcc));
> > -if (track->codec_priv.size >= 86) {
> > -bit_depth = AV_RB16(track->codec_priv.data + 82);
> > -ffio_init_context(, track->codec_priv.data,
> > -  track->codec_priv.size,
> > -  0, NULL, NULL, NULL, NULL);
> > -if (ff_get_qtpalette(codec_id, , track->palette)) {
> > -bit_depth &= 0x1F;
> > -track->has_palette = 1;
> Why are you removing this code? What about tracks that ought to have a
> palette?

The palette parsing is done in the stsd parser, but it still has to be
copied back into the track,
which is done in the later patch.

> > -}
> > +/* ff_mov_read_stsd_entries updates stream s->nb_streams-1,
> > + * so set it temporarily to indicate which stream to update. */
> > +s->nb_streams = st->index + 1;
> > +ff_mov_read_stsd_entries(mc, stsd_ctx, 1);
> > +av_free(msc);
> > +av_free(mc);
> > +avio_context_free(_ctx);
> > +st->priv_data = priv_data;
> > +s->nb_streams = nb_streams;
> > +
> > +// dvh1 in mkv is likely HEVC
> > +if (st->codecpar->codec_tag == MKTAG('d','v','h','1')) {
> > +codec_id =

Re: [FFmpeg-devel] [PATCH 0/1] Parsing quicktime tracks in matroska containers

2019-08-14 Thread Stanislav Ionascu
It affects all codecs which need the data stored in stsd sub-atoms (and
which mkvtoolnix is unable to extract). So far it's the case for dvh1, and
these are hvcC and dvcC.
The patch proposes to rely on the existing methods from
avformat/isom, instead of parsing those (again) in matroskadec.

Thanks!
Stan.



On Tue, Aug 13, 2019 at 9:35 PM Kieran O Leary 
wrote:

> On Tue, 13 Aug 2019, 20:25 Stanislav Ionascu,  >
> wrote:
>
> > Hi All,
> >
> > when remuxing some of the mp4 files into the mkv container, not all
> > video codecs can be properly represented.
>
>
> Purely out of curiosity, what other codes does this affect?
>
> Best,
>
> Kieran O'Leary
> Irish Film Institute
> ___
> 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 1/1] avformat/matroska: fully parse stsd atom in v_quicktime tracks

2019-08-13 Thread Stanislav Ionascu
Per matroska spec, v_quicktime contains the complete stsd atom, after
the mandatory size + fourcc. By properly parsing the hvcc sub-atoms of
the track, it becomes possible to demux/decode mp4/mov tracks stored as is
in matroska containers.

Also dvh1 in stsd in matroska is more likely hevc codec than dv.

Signed-off-by: Stanislav Ionascu 
---
 libavformat/matroskadec.c | 51 +++
 1 file changed, 36 insertions(+), 15 deletions(-)

diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index 4e20f15792..88bc89c545 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -2473,25 +2473,46 @@ static int matroska_parse_tracks(AVFormatContext *s)
 } else if (!strcmp(track->codec_id, "V_QUICKTIME") &&
(track->codec_priv.size >= 21)  &&
(track->codec_priv.data)) {
+MOVStreamContext *msc;
+MOVContext *mc = NULL;
+AVIOContext *stsd_ctx = NULL;
+void *priv_data;
+int nb_streams;
 int ret = get_qt_codec(track, , _id);
 if (ret < 0)
 return ret;
-if (codec_id == AV_CODEC_ID_NONE && 
AV_RL32(track->codec_priv.data+4) == AV_RL32("SMI ")) {
-fourcc = MKTAG('S','V','Q','3');
-codec_id = ff_codec_get_id(ff_codec_movvideo_tags, fourcc);
+av_log(matroska->ctx, AV_LOG_TRACE,
+   "FourCC found %s.\n", av_fourcc2str(fourcc));
+priv_data = st->priv_data;
+nb_streams = s->nb_streams;
+mc = av_mallocz(sizeof(*mc));
+if (!mc)
+return AVERROR(ENOMEM);
+stsd_ctx = avio_alloc_context(track->codec_priv.data,
+track->codec_priv.size,
+0, NULL, NULL, NULL, NULL);
+if (!stsd_ctx)
+return AVERROR(ENOMEM);
+mc->fc = s;
+st->priv_data = msc = av_mallocz(sizeof(MOVStreamContext));
+if (!msc) {
+av_free(mc);
+st->priv_data = priv_data;
+return AVERROR(ENOMEM);
 }
-if (codec_id == AV_CODEC_ID_NONE)
-av_log(matroska->ctx, AV_LOG_ERROR,
-   "mov FourCC not found %s.\n", av_fourcc2str(fourcc));
-if (track->codec_priv.size >= 86) {
-bit_depth = AV_RB16(track->codec_priv.data + 82);
-ffio_init_context(, track->codec_priv.data,
-  track->codec_priv.size,
-  0, NULL, NULL, NULL, NULL);
-if (ff_get_qtpalette(codec_id, , track->palette)) {
-bit_depth &= 0x1F;
-track->has_palette = 1;
-}
+/* ff_mov_read_stsd_entries updates stream s->nb_streams-1,
+ * so set it temporarily to indicate which stream to update. */
+s->nb_streams = st->index + 1;
+ff_mov_read_stsd_entries(mc, stsd_ctx, 1);
+av_free(msc);
+av_free(mc);
+avio_context_free(_ctx);
+st->priv_data = priv_data;
+s->nb_streams = nb_streams;
+
+// dvh1 in mkv is likely HEVC
+if (st->codecpar->codec_tag == MKTAG('d','v','h','1')) {
+codec_id = AV_CODEC_ID_HEVC;
 }
 } else if (codec_id == AV_CODEC_ID_PCM_S16BE) {
 switch (track->audio.bitdepth) {
-- 
2.20.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 0/1] Parsing quicktime tracks in matroska containers

2019-08-13 Thread Stanislav Ionascu
Hi All,

when remuxing some of the mp4 files into the mkv container, not all
video codecs can be properly represented. As such, to make the codec
configuration complete, mkvtoolnix muxes in the full stsd box.

I also switched "detecting" DVH1 in a v_quicktime track in an mkv file, as a 
HEVC
codec, as I did not find a better way (yet) to check if hvcC box exists in
stsd.

The easiest way to verify the patch. Is to take a dolby vision profile 5
mp4, and mux it with mkv-toolnix into an mkv. Without this patch, the
file is unplayable.

I'm open to any other approaches for solving the issue.

Thanks!
Stan.

Stanislav Ionascu (1):
  avformat/matroska: fully parse stsd atom in v_quicktime tracks

 libavformat/matroskadec.c | 51 +++
 1 file changed, 36 insertions(+), 15 deletions(-)

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