[FFmpeg-devel] [PATCH 1/2] avformat/hls: support avio_seek in encryption mode

2020-07-22 Thread Steven Liu
Signed-off-by: Steven Liu 
---
 libavformat/hls.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/hls.c b/libavformat/hls.c
index ba17c4ed96..5bc775cd8b 100644
--- a/libavformat/hls.c
+++ b/libavformat/hls.c
@@ -1291,7 +1291,7 @@ static int open_input(HLSContext *c, struct playlist 
*pls, struct segment *seg,
  * as would be expected. Wrong offset received from the server will not be
  * noticed without the call, though.
  */
-if (ret == 0 && !is_http && seg->key_type == KEY_NONE && seg->url_offset) {
+if (ret == 0 && !is_http && seg->url_offset) {
 int64_t seekret = avio_seek(*in, seg->url_offset, SEEK_SET);
 if (seekret < 0) {
 av_log(pls->parent, AV_LOG_ERROR, "Unable to seek to offset 
%"PRId64" of HLS segment '%s'\n", seg->url_offset, seg->url);
-- 
2.25.0



___
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 2/2] avformat/hlsenc: write temp file for append single file by encryption mode

2020-07-22 Thread Steven Liu
fix ticket: 8783
Because in single file by encryption mode, it cannot get the last one
block of the file, it need ff_format_io_close for get full file size,
then hlsenc can get the total size of the encryption content,
so write the content into temp file first, and get the temp file content
append the temp file content into append to single file, then hlsenc can
get the correct file/content size and offset.

Signed-off-by: Steven Liu 
---
 libavformat/hlsenc.c | 70 ++--
 1 file changed, 68 insertions(+), 2 deletions(-)

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index df84e6487d..0b859ae579 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -69,6 +69,7 @@ typedef enum {
 #define KEYSIZE 16
 #define LINE_BUFFER_SIZE MAX_URL_SIZE
 #define HLS_MICROSECOND_UNIT   100
+#define BUFSIZE (16 * 1024)
 #define POSTFIX_PATTERN "_%d"
 
 typedef struct HLSSegment {
@@ -119,6 +120,7 @@ typedef struct VariantStream {
 ff_const59 AVOutputFormat *oformat;
 ff_const59 AVOutputFormat *vtt_oformat;
 AVIOContext *out;
+AVIOContext *out_single_file;
 int packets_written;
 int init_range_length;
 uint8_t *temp_buffer;
@@ -149,6 +151,7 @@ typedef struct VariantStream {
 HLSSegment *last_segment;
 HLSSegment *old_segments;
 
+char *basename_tmp;
 char *basename;
 char *vtt_basename;
 char *vtt_m3u8_name;
@@ -1722,12 +1725,34 @@ static int hls_start(AVFormatContext *s, VariantStream 
*vs)
 av_opt_set(oc->priv_data, "mpegts_flags", "resend_headers", 0);
 }
 if (c->flags & HLS_SINGLE_FILE) {
+if (c->key_info_file || c->encrypt) {
+av_dict_set(&options, "encryption_key", vs->key_string, 0);
+av_dict_set(&options, "encryption_iv", vs->iv_string, 0);
+
+/* Write temp file with cryption content */
+av_freep(&vs->basename_tmp);
+vs->basename_tmp = av_asprintf("crypto:%s.tmp", oc->url);
+
+/* append temp file content into single file */
+av_freep(&vs->basename);
+vs->basename = av_asprintf("%s", oc->url);
+} else {
+vs->basename_tmp = vs->basename;
+}
 set_http_options(s, &options, c);
-if ((err = hlsenc_io_open(s, &vs->out, oc->url, &options)) < 0) {
+if (!vs->out_single_file)
+if ((err = hlsenc_io_open(s, &vs->out_single_file, 
vs->basename, &options)) < 0) {
+if (c->ignore_io_errors)
+err = 0;
+goto fail;
+}
+
+if ((err = hlsenc_io_open(s, &vs->out, vs->basename_tmp, 
&options)) < 0) {
 if (c->ignore_io_errors)
 err = 0;
 goto fail;
 }
+
 }
 }
 if (vs->vtt_basename) {
@@ -2258,6 +2283,38 @@ static int hls_init_file_resend(AVFormatContext *s, 
VariantStream *vs)
 return ret;
 }
 
+static int64_t append_single_file(AVFormatContext *s, VariantStream *vs)
+{
+int ret = 0;
+int64_t read_byte = 0;
+int64_t total_size = 0;
+char *filename = NULL;
+char buf[BUFSIZE];
+AVFormatContext *oc = vs->avf;
+
+hlsenc_io_close(s, &vs->out, vs->basename_tmp);
+filename = av_asprintf("%s.tmp", oc->url);
+ret = s->io_open(s, &vs->out, filename, AVIO_FLAG_READ, NULL);
+if (ret < 0) {
+av_free(filename);
+return ret;
+}
+
+do {
+memset(buf, 0, sizeof(BUFSIZE));
+read_byte = avio_read(vs->out, buf, BUFSIZE);
+avio_write(vs->out_single_file, buf, read_byte);
+if (read_byte > 0) {
+total_size += read_byte;
+ret = total_size;
+}
+} while (read_byte > 0);
+
+hlsenc_io_close(s, &vs->out, filename);
+av_free(filename);
+
+return ret;
+}
 static int hls_write_packet(AVFormatContext *s, AVPacket *pkt)
 {
 HLSContext *hls = s->priv_data;
@@ -2383,6 +2440,8 @@ static int hls_write_packet(AVFormatContext *s, AVPacket 
*pkt)
 return ret;
 }
 vs->size = range_length;
+if (hls->key_info_file || hls->encrypt)
+vs->size = append_single_file(s, vs);
 } else {
 if (oc->url[0]) {
 proto = avio_find_protocol_name(oc->url);
@@ -2484,6 +2543,8 @@ static int hls_write_packet(AVFormatContext *s, AVPacket 
*pkt)
 
 if (hls->flags & HLS_SINGLE_FILE) {
 vs->start_pos += vs->size;
+if (hls->key_info_file || hls->encrypt)
+ret = hls_start(s, vs);
 } else if (hls->max_seg_size > 0) {
 if (vs->size + vs->start_pos >= hls->max_seg_size) {
 vs->sequence++;
@@ -2644,7 +2705,12 @@ static int hls_write_trailer(struct AVFormatContext *s)
 if (ret < 0)
 av_log(s, AV_LOG_WARNING, "Failed to up

Re: [FFmpeg-devel] [PATCH 2/3] avutil/timecode: fix av_timecode_get_smpte_from_framenum with 50/60 fps

2020-07-22 Thread Marton Balint



On Wed, 22 Jul 2020, lance.lmw...@gmail.com wrote:


On Mon, Jul 20, 2020 at 11:04:38PM +0200, Marton Balint wrote:

50/60 fps timecode is using the field bit (which is the same as the phase
correction bit) to signal the least significant bit of a 50/60 fps timecode.
See SMPTE ST 12-1:2014 section 12.1.

Let's add support for this by using the recently added av_timecode_get_smpte
function which handles this properly.

This change affects DV and MXF encoder, MXF has no fate for 50/60fps content,
DV does, therefore the changes. It also affects decklink indev.

MediaInfo (a recent version) confirms that half-frame timecode must be
inserted. (although MediaInfo does not seem to check the field flag).
MXFInspect confirms valid timecode insertion to the System Item of MXF files.

Signed-off-by: Marton Balint 
---
 libavutil/timecode.c   | 15 +--
 libavutil/timecode.h   |  7 +++
 tests/ref/vsynth/vsynth1-dv-hd |  2 +-
 tests/ref/vsynth/vsynth2-dv-hd |  2 +-
 tests/ref/vsynth/vsynth3-dv-hd |  2 +-
 tests/ref/vsynth/vsynth_lena-dv-hd |  2 +-
 6 files changed, 8 insertions(+), 22 deletions(-)

diff --git a/libavutil/timecode.c b/libavutil/timecode.c
index cca53d73c4..cb916970ef 100644
--- a/libavutil/timecode.c
+++ b/libavutil/timecode.c
@@ -65,20 +65,7 @@ uint32_t av_timecode_get_smpte_from_framenum(const 
AVTimecode *tc, int framenum)
 ss = framenum / fps  % 60;
 mm = framenum / (fps*60) % 60;
 hh = framenum / (fps*3600) % 24;
-return 0 << 31 | // color frame flag (0: unsync mode, 1: sync mode)
-   drop  << 30 | // drop  frame flag (0: non drop,1: drop)
-   (ff / 10) << 28 | // tens  of frames
-   (ff % 10) << 24 | // units of frames
-   0 << 23 | // PC (NTSC) or BGF0 (PAL)
-   (ss / 10) << 20 | // tens  of seconds
-   (ss % 10) << 16 | // units of seconds
-   0 << 15 | // BGF0 (NTSC) or BGF2 (PAL)
-   (mm / 10) << 12 | // tens  of minutes
-   (mm % 10) <<  8 | // units of minutes
-   0 <<  7 | // BGF2 (NTSC) or PC (PAL)
-   0 <<  6 | // BGF1
-   (hh / 10) <<  4 | // tens  of hours
-   (hh % 10);// units of hours
+return av_timecode_get_smpte(tc->rate, drop, hh, mm, ss, ff);
 }

 uint32_t av_timecode_get_smpte(AVRational rate, int drop, int hh, int mm, int 
ss, int ff)
diff --git a/libavutil/timecode.h b/libavutil/timecode.h
index 5801330921..e54b116e93 100644
--- a/libavutil/timecode.h
+++ b/libavutil/timecode.h
@@ -66,11 +66,11 @@ int av_timecode_adjust_ntsc_framenum2(int framenum, int 
fps);
  * the format description as follows:
  * bits 0-5:   hours, in BCD(6bits)
  * bits 6: BGF1
- * bits 7: BGF2 (NTSC) or PC (PAL)
+ * bits 7: BGF2 (NTSC) or FIELD (PAL)


If the format is coming from SMPTE 314m-1999, 4.4.2.2.1 Time code pack (TC), 
then
it use PC instead of FIELD for the interpretation of the bits.

PC: Biphase mark polarity correction
0 = even
1 = odd

About the bits interpretation:
FIELD is used by VITC
https://en.wikipedia.org/wiki/Vertical_interval_timecode

PC is used by LTC
https://en.wikipedia.org/wiki/Linear_timecode

So I prefer to change to PC/FIELD instead of FIELD only if want to update the
interpretation of the bits.


I don't think it is a good idea, after all this supposed to document the 
format the function returns and not what is in the DV standard. Note that 
this function is used for both DV and MXF and you are also using the same 
term "SMPTE 12M binary representation" in av_timecode_get_smpte() and that 
is already using the PC flag as FIELDS, and it would be confusing for that

function to refer to a different binary representation...

Therefore I'd rather keep things as is.

Regards,
Marton





  * bits 8-14:  minutes, in BCD(7bits)
  * bits 15:BGF0 (NTSC) or BGF2 (PAL)
  * bits 16-22: seconds, in BCD(7bits)
- * bits 23:PC (NTSC) or BGF0 (PAL)
+ * bits 23:FIELD (NTSC) or BGF0 (PAL)
  * bits 24-29: frames, in BCD(6bits)
  * bits 30:drop  frame flag (0: non drop,1: drop)
  * bits 31:color frame flag (0: unsync mode, 1: sync mode)
@@ -78,8 +78,7 @@ int av_timecode_adjust_ntsc_framenum2(int framenum, int fps);
  * @note Frame number adjustment is automatically done in case of drop 
timecode,
  *   you do NOT have to call av_timecode_adjust_ntsc_framenum2().
  * @note The frame number is relative to tc->start.
- * @note Color frame (CF), binary group flags (BGF) and biphase mark polarity
- *   correction (PC) bits are set to zero.
+ * @note Color frame (CF) and binary group flags (BGF) bits are set to zero.
  */
 uint32_t av_timecode_get_smpte_from_framenum(const AVTimecode *tc, int 
framenum);

diff --git a/tests/ref/vsynth/vsynth1-dv-hd b/tests/ref/vsynth/vsynth1-dv-hd
index e22f28c704..a93ce50ec0 100644
--- a/tests/ref/vsynth/vsynth1-dv-hd
+++ b/tests/ref/vsynth/vsynth1-dv-hd
@@ -1,4 +1,4 @@
-77f146c73a24495

[FFmpeg-devel] [PATCH v2 2/2] avformat/hlsenc: write temp file for append single file by encryption mode

2020-07-22 Thread Steven Liu
fix ticket: 8783
Because in single file by encryption mode, it cannot get the last one
block of the file, it need ff_format_io_close for get full file size,
then hlsenc can get the total size of the encryption content,
so write the content into temp file first, and get the temp file content
append the temp file content into append to single file, then hlsenc can
get the correct file/content size and offset.

Signed-off-by: Steven Liu 
---
 libavformat/hlsenc.c | 70 ++--
 1 file changed, 68 insertions(+), 2 deletions(-)

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index df84e6487d..f1e4a302d8 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -69,6 +69,7 @@ typedef enum {
 #define KEYSIZE 16
 #define LINE_BUFFER_SIZE MAX_URL_SIZE
 #define HLS_MICROSECOND_UNIT   100
+#define BUFSIZE (16 * 1024)
 #define POSTFIX_PATTERN "_%d"
 
 typedef struct HLSSegment {
@@ -119,6 +120,7 @@ typedef struct VariantStream {
 ff_const59 AVOutputFormat *oformat;
 ff_const59 AVOutputFormat *vtt_oformat;
 AVIOContext *out;
+AVIOContext *out_single_file;
 int packets_written;
 int init_range_length;
 uint8_t *temp_buffer;
@@ -149,6 +151,7 @@ typedef struct VariantStream {
 HLSSegment *last_segment;
 HLSSegment *old_segments;
 
+char *basename_tmp;
 char *basename;
 char *vtt_basename;
 char *vtt_m3u8_name;
@@ -1722,12 +1725,34 @@ static int hls_start(AVFormatContext *s, VariantStream 
*vs)
 av_opt_set(oc->priv_data, "mpegts_flags", "resend_headers", 0);
 }
 if (c->flags & HLS_SINGLE_FILE) {
+if (c->key_info_file || c->encrypt) {
+av_dict_set(&options, "encryption_key", vs->key_string, 0);
+av_dict_set(&options, "encryption_iv", vs->iv_string, 0);
+
+/* Write temp file with cryption content */
+av_freep(&vs->basename_tmp);
+vs->basename_tmp = av_asprintf("crypto:%s.tmp", oc->url);
+
+/* append temp file content into single file */
+av_freep(&vs->basename);
+vs->basename = av_asprintf("%s", oc->url);
+} else {
+vs->basename_tmp = vs->basename;
+}
 set_http_options(s, &options, c);
-if ((err = hlsenc_io_open(s, &vs->out, oc->url, &options)) < 0) {
+if (!vs->out_single_file)
+if ((err = hlsenc_io_open(s, &vs->out_single_file, 
vs->basename, &options)) < 0) {
+if (c->ignore_io_errors)
+err = 0;
+goto fail;
+}
+
+if ((err = hlsenc_io_open(s, &vs->out, vs->basename_tmp, 
&options)) < 0) {
 if (c->ignore_io_errors)
 err = 0;
 goto fail;
 }
+
 }
 }
 if (vs->vtt_basename) {
@@ -2258,6 +2283,38 @@ static int hls_init_file_resend(AVFormatContext *s, 
VariantStream *vs)
 return ret;
 }
 
+static int64_t append_single_file(AVFormatContext *s, VariantStream *vs)
+{
+int ret = 0;
+int64_t read_byte = 0;
+int64_t total_size = 0;
+char *filename = NULL;
+char buf[BUFSIZE];
+AVFormatContext *oc = vs->avf;
+
+hlsenc_io_close(s, &vs->out, vs->basename_tmp);
+filename = av_asprintf("%s.tmp", oc->url);
+ret = s->io_open(s, &vs->out, filename, AVIO_FLAG_READ, NULL);
+if (ret < 0) {
+av_free(filename);
+return ret;
+}
+
+do {
+memset(buf, 0, sizeof(BUFSIZE));
+read_byte = avio_read(vs->out, buf, BUFSIZE);
+avio_write(vs->out_single_file, buf, read_byte);
+if (read_byte > 0) {
+total_size += read_byte;
+ret = total_size;
+}
+} while (read_byte > 0);
+
+hlsenc_io_close(s, &vs->out, filename);
+av_free(filename);
+
+return ret;
+}
 static int hls_write_packet(AVFormatContext *s, AVPacket *pkt)
 {
 HLSContext *hls = s->priv_data;
@@ -2383,6 +2440,8 @@ static int hls_write_packet(AVFormatContext *s, AVPacket 
*pkt)
 return ret;
 }
 vs->size = range_length;
+if (hls->key_info_file || hls->encrypt)
+vs->size = append_single_file(s, vs);
 } else {
 if (oc->url[0]) {
 proto = avio_find_protocol_name(oc->url);
@@ -2484,6 +2543,8 @@ static int hls_write_packet(AVFormatContext *s, AVPacket 
*pkt)
 
 if (hls->flags & HLS_SINGLE_FILE) {
 vs->start_pos += vs->size;
+if (hls->key_info_file || hls->encrypt)
+ret = hls_start(s, vs);
 } else if (hls->max_seg_size > 0) {
 if (vs->size + vs->start_pos >= hls->max_seg_size) {
 vs->sequence++;
@@ -2644,7 +2705,12 @@ static int hls_write_trailer(struct AVFormatContext *s)
 if (ret < 0)
 av_log(s, AV_LOG_WARNING, "Failed to up

[FFmpeg-devel] [PATCH v2 1/2] avformat/hls: support avio_seek in encryption mode

2020-07-22 Thread Steven Liu
Signed-off-by: Steven Liu 
---
 libavformat/hls.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/hls.c b/libavformat/hls.c
index ba17c4ed96..5bc775cd8b 100644
--- a/libavformat/hls.c
+++ b/libavformat/hls.c
@@ -1291,7 +1291,7 @@ static int open_input(HLSContext *c, struct playlist 
*pls, struct segment *seg,
  * as would be expected. Wrong offset received from the server will not be
  * noticed without the call, though.
  */
-if (ret == 0 && !is_http && seg->key_type == KEY_NONE && seg->url_offset) {
+if (ret == 0 && !is_http && seg->url_offset) {
 int64_t seekret = avio_seek(*in, seg->url_offset, SEEK_SET);
 if (seekret < 0) {
 av_log(pls->parent, AV_LOG_ERROR, "Unable to seek to offset 
%"PRId64" of HLS segment '%s'\n", seg->url_offset, seg->url);
-- 
2.25.0



___
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 v2 1/3] libavutil/imgutils: add utility to get plane sizes

2020-07-22 Thread Nicolas George
James Almer (12020-07-20):
> No, i'll push v3 soon if my argumentation below was not enough to
> convince Nicolas or Michael. My intention is to use ints for the new
> function, not to postpone committing it in any form indefinitely.

Sorry, I missed you mail earlier, I only read your arguments nowish.

You are emphasizing that the "future-proof" argument is rather weak,
which I was already aware. And you are underplaying the fact that it
belongs to a trend to always delay necessary changes.

Anyway, even if all the arguments for using the proper types are all
very weak, there are several, and together I am still convinced they
exceed "consistency" easily.

consistently good > inconsistently good and bad > consistently bad
^
|
 this is the discussion we are having

Or, as John Oliver pointed last Sunday: just because you reopened
restaurants does not mean you have to reopen schools too for the sake of
consistency.

Regards,

-- 
  Nicolas George


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

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

Re: [FFmpeg-devel] [PATCH 3/3] avformat/mxfdec: Fix memleak upon repeating tags

2020-07-22 Thread Tomas Härdin
mån 2020-07-20 klockan 08:15 +0200 skrev Andreas Rheinhardt:
> When parsing MXF encountering some tags leads to allocations. And when
> these tags were encountered repeatedly, this could lead to memleaks,
> because the pointer to the old data got simply overwritten with a
> pointer to the new data (or to NULL on allocation failure). This has
> been fixed.
> 
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavformat/mxfdec.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
> index 3016885e75..f0975f409e 100644
> --- a/libavformat/mxfdec.c
> +++ b/libavformat/mxfdec.c
> @@ -850,6 +850,7 @@ static int mxf_read_cryptographic_context(void *arg, 
> AVIOContext *pb, int tag, i
>  static int mxf_read_strong_ref_array(AVIOContext *pb, UID **refs, int *count)
>  {
>  *count = avio_rb32(pb);
> +av_free(*refs);
>  *refs = av_calloc(*count, sizeof(UID));
>  if (!*refs) {
>  *count = 0;
> @@ -903,10 +904,8 @@ static int mxf_read_content_storage(void *arg, 
> AVIOContext *pb, int tag, int siz
>  case 0x1901:
>  if (mxf->packages_refs)
>  av_log(mxf->fc, AV_LOG_VERBOSE, "Multiple packages_refs\n");
> -av_free(mxf->packages_refs);
>  return mxf_read_strong_ref_array(pb, &mxf->packages_refs, 
> &mxf->packages_count);
>  case 0x1902:
> -av_free(mxf->essence_container_data_refs);

Good catch. Looks OK

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

Re: [FFmpeg-devel] [PATCH 1/3] avformat/mxfdec: Fix memleak when adding element to array fails

2020-07-22 Thread Tomas Härdin
mån 2020-07-20 klockan 08:15 +0200 skrev Andreas Rheinhardt:
> Said array contains pointers to other structs and both the designated
> new element as well as other stuff contained in it (e.g. strings)
> leak
> if the new element can't be added to the array.
> 
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavformat/mxfdec.c | 14 +++---
>  1 file changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
> index 90546d42b3..08ad92cc0c 100644
> --- a/libavformat/mxfdec.c
> +++ b/libavformat/mxfdec.c
> @@ -822,15 +822,17 @@ static int mxf_read_partition_pack(void *arg,
> AVIOContext *pb, int tag, int size
>  return 0;
>  }
>  
> -static int mxf_add_metadata_set(MXFContext *mxf, void *metadata_set)
> +static int mxf_add_metadata_set(MXFContext *mxf, MXFMetadataSet
> **metadata_set)
>  {
>  MXFMetadataSet **tmp;
>  
>  tmp = av_realloc_array(mxf->metadata_sets, mxf-
> >metadata_sets_count + 1, sizeof(*mxf->metadata_sets));
> -if (!tmp)
> +if (!tmp) {
> +mxf_free_metadataset(metadata_set, 1);

Went and double-checked that mxf_free_metadataset nulls *metadata_set
which it does, so this patch OK.

/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] working with file descriptors on Android

2020-07-22 Thread Alex Cohn
Usually, we employ the `pipe:` protocol to deal with the numerical
file descriptors, and this answers all our needs. On Android, there is
a different use case in which numerical file descriptors appear, and
this is not covered well with `pipe:` protocol.

This happens when a file is opened in scoped storage
(https://developer.android.com/training/data-storage#scoped-storage).
Currently, there is an exception that still allows `stdio.h` - based
access to the media files
(https://developer.android.com/preview/privacy/storage#media-files-raw-paths),
but the document says that it may be slow (we still cannot have true
evidence since Android 11 is not released yet), and anyways the clean
way to access media files on what is known as 'external storage' is
through a document picker Intent
(https://developer.android.com/reference/android/content/Intent#ACTION_OPEN_DOCUMENT
and 
https://developer.android.com/reference/android/content/Intent#ACTION_CREATE_DOCUMENT).

The Intent produces a `content://` URI from which a DocumentProvider
can produce an integer file descriptor. This descriptor can be passed
to ffmpeg via pipe: protocol, and almost works, except for a few
glitches.

 1. This fd must be closed after use. Pipe is not closeable.

 2. This fd is seekable, and therefore can be used to work with `.mp4`
or some other file formats that don't work through pipe protocol.

 3. We can find the actual file name extension for this fd, to
facilitate `av_guess_format()` both for input and for output.

I have recently prepared two approaches to face this issue. One is an
easy patch for the `file:` protocol that recognizes the `/proc/self/`
prefix and uses the number as fd. This relies heavily on Java (or
Kotlin) processing of the results of document picker. The other way
adds a `content://` protocol and does all heavy lifting (calling
system Java API through JNI) itself.

I would like to submit my contribution to ffmpeg-devel, but I am in
doubt which of the two approaches may better fit the ffmpeg
development paradigm, if any.

Best Regards,
Alex Cohn
___
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/3] avformat/mxfdec: Fix memleak when parsing tag fails

2020-07-22 Thread Tomas Härdin
mån 2020-07-20 klockan 08:15 +0200 skrev Andreas Rheinhardt:
> --- a/libavformat/mxfdec.c
> +++ b/libavformat/mxfdec.c
> @@ -2714,6 +2714,7 @@ static const MXFMetadataReadTableEntry 
> mxf_metadata_read_table[] = {
>  
>  static int mxf_metadataset_init(MXFMetadataSet *ctx, enum MXFMetadataSetType 
> type)
>  {
> +ctx->type = type;
>  switch (type){
>  case MultipleDescriptor:
>  case Descriptor:
> @@ -2734,7 +2735,8 @@ static int mxf_read_local_tags(MXFContext *mxf, 
> KLVPacket *klv, MXFMetadataReadF
>  
>  if (!ctx)
>  return AVERROR(ENOMEM);
> -mxf_metadataset_init(ctx, type);
> +if (ctx_size)
> +mxf_metadataset_init(ctx, type);
>  while (avio_tell(pb) + 4 < klv_end && !avio_feof(pb)) {
>  int ret;
>  int tag = avio_rb16(pb);
> @@ -2770,7 +2772,6 @@ static int mxf_read_local_tags(MXFContext *mxf, 
> KLVPacket *klv, MXFMetadataReadF
>   * it extending past the end of the KLV though (zzuf5.mxf). */
>  if (avio_tell(pb) > klv_end) {
>  if (ctx_size) {
> -ctx->type = type;
>  mxf_free_metadataset(&ctx, 1);
>  }
>  
> @@ -2781,7 +2782,6 @@ static int mxf_read_local_tags(MXFContext *mxf, 
> KLVPacket *klv, MXFMetadataReadF
>  } else if (avio_tell(pb) <= next)   /* only seek forward, else this 
> can loop for a long time */
>  avio_seek(pb, next, SEEK_SET);
>  }
> -if (ctx_size) ctx->type = type;

Looks OK as far as I can tell. It's been a while since I dug into
mxfdec's type system.

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

Re: [FFmpeg-devel] [PATCH 3/9] avformat/mxfdec: Simplify cleanup after read_header failure

2020-07-22 Thread Tomas Härdin
tis 2020-07-21 klockan 04:12 +0200 skrev Andreas Rheinhardt:
> by setting the AVFMT_HEADER_CLEANUP flag.
> 
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavformat/mxfdec.c | 24 +++-
>  1 file changed, 7 insertions(+), 17 deletions(-)

I was confused for a while since "git grep AVFMT_HEADER_CLEANUP" didn't
give any results, before I noticed this is part of a patchset.

This makes cleanup much cleaner -> approved!

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

Re: [FFmpeg-devel] [PATCH v3 1/4] libavutil/imgutils: add utility to get plane sizes

2020-07-22 Thread James Almer
On 7/13/2020 9:19 PM, Brian Kim wrote:
> On Mon, Jul 13, 2020 at 11:22 AM James Almer  wrote:
> [...]
>> You would need to cast height to size_t for this, i think, but seeing
>> av_image_check_size() currently rejects line sizes and plane sizes
>> bigger than INT_MAX, maybe we should just keep INT_MAX in the above
>> check instead (No need to send a new revision for this, i can amend it
>> before pushing with either solution. I just want your opinion).
> 
> If we move towards using size_t/ptrdiff_t, it seems to make sense to
> use SIZE_MAX so that we do not have to come back and update this
> afterwards. It seems like even if we limited the values to INT_MAX
> users would think that they should check the range again anyways based
> on the type.
> 
> However, I am fine with keeping it limited to INT_MAX to keep things
> consistent until we can actually use the full range in other places.

Left it with SIZE_MAX checks and height cast to size_t, and pushed the set.

Thanks
___
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 5/8] avformat/mpegtsenc: use local variable store st->codecpar->codec_id

2020-07-22 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
 libavformat/mpegtsenc.c | 17 +
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 28d535a..718ddab 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -453,6 +453,7 @@ static int mpegts_write_pmt(AVFormatContext *s, 
MpegTSService *service)
 AVStream *st = s->streams[i];
 MpegTSWriteStream *ts_st = st->priv_data;
 AVDictionaryEntry *lang = av_dict_get(st->metadata, "language", NULL, 
0);
+enum AVCodecID codec_id = st->codecpar->codec_id;
 
 if (s->nb_programs) {
 int k, found = 0;
@@ -484,19 +485,19 @@ static int mpegts_write_pmt(AVFormatContext *s, 
MpegTSService *service)
 switch (st->codecpar->codec_type) {
 case AVMEDIA_TYPE_AUDIO:
 if (ts->flags & MPEGTS_FLAG_SYSTEM_B) {
-if (st->codecpar->codec_id==AV_CODEC_ID_AC3) {
+if (codec_id == AV_CODEC_ID_AC3) {
 *q++=0x6a; // AC3 descriptor see A038 DVB SI
 *q++=1; // 1 byte, all flags sets to 0
 *q++=0; // omit all fields...
-} else if (st->codecpar->codec_id==AV_CODEC_ID_EAC3) {
+} else if (codec_id == AV_CODEC_ID_EAC3) {
 *q++=0x7a; // EAC3 descriptor see A038 DVB SI
 *q++=1; // 1 byte, all flags sets to 0
 *q++=0; // omit all fields...
 }
 }
-if (st->codecpar->codec_id==AV_CODEC_ID_S302M)
+if (codec_id == AV_CODEC_ID_S302M)
 put_registration_descriptor(&q, MKTAG('B', 'S', 'S', 'D'));
-if (st->codecpar->codec_id==AV_CODEC_ID_OPUS) {
+if (codec_id == AV_CODEC_ID_OPUS) {
 /* 6 bytes registration descriptor, 4 bytes Opus audio 
descriptor */
 if (q - data > SECTION_LENGTH - 6 - 4) {
 err = 1;
@@ -611,7 +612,7 @@ static int mpegts_write_pmt(AVFormatContext *s, 
MpegTSService *service)
const char default_language[] = "und";
const char *language = lang && strlen(lang->value) >= 3 ? 
lang->value : default_language;
 
-   if (st->codecpar->codec_id == AV_CODEC_ID_DVB_SUBTITLE) {
+   if (codec_id == AV_CODEC_ID_DVB_SUBTITLE) {
uint8_t *len_ptr;
int extradata_copied = 0;
 
@@ -653,7 +654,7 @@ static int mpegts_write_pmt(AVFormatContext *s, 
MpegTSService *service)
}
 
*len_ptr = q - len_ptr - 1;
-   } else if (st->codecpar->codec_id == AV_CODEC_ID_DVB_TELETEXT) {
+   } else if (codec_id == AV_CODEC_ID_DVB_TELETEXT) {
uint8_t *len_ptr = NULL;
int extradata_copied = 0;
 
@@ -697,9 +698,9 @@ static int mpegts_write_pmt(AVFormatContext *s, 
MpegTSService *service)
 }
 break;
 case AVMEDIA_TYPE_DATA:
-if (st->codecpar->codec_id == AV_CODEC_ID_SMPTE_KLV) {
+if (codec_id == AV_CODEC_ID_SMPTE_KLV) {
 put_registration_descriptor(&q, MKTAG('K', 'L', 'V', 'A'));
-} else if (st->codecpar->codec_id == AV_CODEC_ID_TIMED_ID3) {
+} else if (codec_id == AV_CODEC_ID_TIMED_ID3) {
 const char *tag = "ID3 ";
 *q++ = 0x26; /* metadata descriptor */
 *q++ = 13;
-- 
1.8.3.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 8/8] swscale/yuv2rgb: cosmetics

2020-07-22 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
 libswscale/yuv2rgb.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/libswscale/yuv2rgb.c b/libswscale/yuv2rgb.c
index e02d74f..6a3956e 100644
--- a/libswscale/yuv2rgb.c
+++ b/libswscale/yuv2rgb.c
@@ -983,9 +983,10 @@ av_cold int ff_yuv2rgb_c_init_tables(SwsContext *c, const 
int inv_table[4],
 y_table32[i + 2 * table_plane_size] = yval << bbase;
 yb += cy;
 }
-if (isNotNe)
-for (i = 0; i < table_plane_size * 3; i++)
-y_table32[i] = av_bswap32(y_table32[i]);
+if (isNotNe) {
+for (i = 0; i < table_plane_size * 3; i++)
+y_table32[i] = av_bswap32(y_table32[i]);
+}
 fill_table(c->table_rV, 4, crv, y_table32 + yoffs);
 fill_table(c->table_gU, 4, cgu, y_table32 + yoffs + table_plane_size);
 fill_table(c->table_bU, 4, cbu, y_table32 + yoffs + 2 * 
table_plane_size);
-- 
1.8.3.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 7/8] avformat/mpegtsenc: add registration descriptor for AC-3 and EAC3

2020-07-22 Thread lance . lmwang
From: Limin Wang 

copy the atsc ac3 audio in ts like below:
./ffmpeg -i atsc_audio.ts -c:v copy -c:a copy out.ts
Stream #0:6[0x64](eng): Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, stereo, fltp, 
192 kb/s

./ffmpeg -i out.ts
Before:
Stream #0:1[0x101](eng): Audio: ac3 ([129][0][0][0] / 0x0081), 48000 Hz, 
stereo, fltp, 192 kb/s

After applied patch:
Stream #0:1[0x101](eng): Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, stereo, 
fltp, 192 kb/s

Signed-off-by: Limin Wang 
---
 libavformat/mpegtsenc.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index a5b45fb..f060ea6 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -535,6 +535,11 @@ static int mpegts_write_pmt(AVFormatContext *s, 
MpegTSService *service)
 *q++=1; // 1 byte, all flags sets to 0
 *q++=0; // omit all fields...
 }
+} else {
+if (codec_id == AV_CODEC_ID_AC3)
+put_registration_descriptor(&q, MKTAG('A', 'C', '-', '3'));
+else if (codec_id == AV_CODEC_ID_EAC3)
+put_registration_descriptor(&q, MKTAG('E', 'A', 'C', '3'));
 }
 if (codec_id == AV_CODEC_ID_S302M)
 put_registration_descriptor(&q, MKTAG('B', 'S', 'S', 'D'));
-- 
1.8.3.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 3/8] avformat/mpegtsenc: simplify code for condition checks

2020-07-22 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
 libavformat/mpegtsenc.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index d827ba3..2d7a8ab 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -483,16 +483,18 @@ static int mpegts_write_pmt(AVFormatContext *s, 
MpegTSService *service)
 /* write optional descriptors here */
 switch (st->codecpar->codec_type) {
 case AVMEDIA_TYPE_AUDIO:
-if (st->codecpar->codec_id==AV_CODEC_ID_AC3 && (ts->flags & 
MPEGTS_FLAG_SYSTEM_B)) {
+if (ts->flags & MPEGTS_FLAG_SYSTEM_B) {
+if (st->codecpar->codec_id==AV_CODEC_ID_AC3) {
 *q++=0x6a; // AC3 descriptor see A038 DVB SI
 *q++=1; // 1 byte, all flags sets to 0
 *q++=0; // omit all fields...
 }
-if (st->codecpar->codec_id==AV_CODEC_ID_EAC3 && (ts->flags & 
MPEGTS_FLAG_SYSTEM_B)) {
+else if (st->codecpar->codec_id==AV_CODEC_ID_EAC3) {
 *q++=0x7a; // EAC3 descriptor see A038 DVB SI
 *q++=1; // 1 byte, all flags sets to 0
 *q++=0; // omit all fields...
 }
+}
 if (st->codecpar->codec_id==AV_CODEC_ID_S302M)
 put_registration_descriptor(&q, MKTAG('B', 'S', 'S', 'D'));
 if (st->codecpar->codec_id==AV_CODEC_ID_OPUS) {
-- 
1.8.3.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 4/8] avformat/mpegtsenc: reindent the last commit

2020-07-22 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
 libavformat/mpegtsenc.c | 19 +--
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 2d7a8ab..28d535a 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -484,16 +484,15 @@ static int mpegts_write_pmt(AVFormatContext *s, 
MpegTSService *service)
 switch (st->codecpar->codec_type) {
 case AVMEDIA_TYPE_AUDIO:
 if (ts->flags & MPEGTS_FLAG_SYSTEM_B) {
-if (st->codecpar->codec_id==AV_CODEC_ID_AC3) {
-*q++=0x6a; // AC3 descriptor see A038 DVB SI
-*q++=1; // 1 byte, all flags sets to 0
-*q++=0; // omit all fields...
-}
-else if (st->codecpar->codec_id==AV_CODEC_ID_EAC3) {
-*q++=0x7a; // EAC3 descriptor see A038 DVB SI
-*q++=1; // 1 byte, all flags sets to 0
-*q++=0; // omit all fields...
-}
+if (st->codecpar->codec_id==AV_CODEC_ID_AC3) {
+*q++=0x6a; // AC3 descriptor see A038 DVB SI
+*q++=1; // 1 byte, all flags sets to 0
+*q++=0; // omit all fields...
+} else if (st->codecpar->codec_id==AV_CODEC_ID_EAC3) {
+*q++=0x7a; // EAC3 descriptor see A038 DVB SI
+*q++=1; // 1 byte, all flags sets to 0
+*q++=0; // omit all fields...
+}
 }
 if (st->codecpar->codec_id==AV_CODEC_ID_S302M)
 put_registration_descriptor(&q, MKTAG('B', 'S', 'S', 'D'));
-- 
1.8.3.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 6/8] avformat/mpegtsenc: support dvb ac3 descriptor by metadata

2020-07-22 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
 libavformat/mpegtsenc.c | 45 +++--
 1 file changed, 43 insertions(+), 2 deletions(-)

diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 718ddab..a5b45fb 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -486,9 +486,50 @@ static int mpegts_write_pmt(AVFormatContext *s, 
MpegTSService *service)
 case AVMEDIA_TYPE_AUDIO:
 if (ts->flags & MPEGTS_FLAG_SYSTEM_B) {
 if (codec_id == AV_CODEC_ID_AC3) {
+int len = 1;
+uint8_t component_type_flag = 0;
+uint8_t bsid_flag   = 0;
+uint8_t mainid_flag = 0;
+uint8_t asvc_flag   = 0;
+uint8_t componenet_type_value, bsid_value, mainid_value, 
asvc_value;
+AVDictionaryEntry *component_type = 
av_dict_get(st->metadata, "dvb.ac3_desc.component_type", NULL, 0);
+AVDictionaryEntry *bsid   = av_dict_get(st->metadata, 
"dvb.ac3_desc.bsid", NULL, 0);
+AVDictionaryEntry *mainid = av_dict_get(st->metadata, 
"dvb.ac3_desc.mainid", NULL, 0);
+AVDictionaryEntry *asvc   = av_dict_get(st->metadata, 
"dvb.ac3_desc.asvc", NULL, 0);
+
 *q++=0x6a; // AC3 descriptor see A038 DVB SI
-*q++=1; // 1 byte, all flags sets to 0
-*q++=0; // omit all fields...
+
+if (component_type) {
+component_type_flag   = 1;
+componenet_type_value = atoi(component_type->value);
+len ++;
+}
+if (bsid) {
+bsid_flag= 1;
+bsid_value   = atoi(bsid->value);
+len ++;
+}
+if (mainid) {
+mainid_flag  = 1;
+mainid_value = atoi(mainid->value);
+len ++;
+}
+if (asvc) {
+asvc_flag= 1;
+asvc_value   = atoi(asvc->value);
+len ++;
+}
+
+*q++ = len;
+*q++ = component_type_flag << 7 | bsid_flag << 6 | 
mainid_flag << 5 | asvc_flag << 4;
+if (component_type_flag)
+*q++ = componenet_type_value;
+if (bsid_flag)
+*q++ = bsid_value;
+if (mainid_flag)
+*q++ = mainid_value;
+if (asvc_flag)
+*q++ = asvc_value;
 } else if (codec_id == AV_CODEC_ID_EAC3) {
 *q++=0x7a; // EAC3 descriptor see A038 DVB SI
 *q++=1; // 1 byte, all flags sets to 0
-- 
1.8.3.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 2/8] avformat/mpegts: decode and export ATSC AC-3 descriptor

2020-07-22 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
 libavformat/mpegts.c | 42 ++
 1 file changed, 42 insertions(+)

diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index 1ed7eaf..d450507 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -1990,6 +1990,48 @@ int ff_parse_mpeg2_descriptor(AVFormatContext *fc, 
AVStream *st, int stream_type
 st->request_probe = 50;
 }
 break;
+case 0x81: /* ATSC AC-3 descriptor */
+{
+uint8_t buf;
+uint8_t sample_rate_code, bsid,bitrate_code,surround_mode, bsmod;
+uint8_t num_channels, full_svc, mainid, priority, asvcflags;
+
+if (desc_len < 4)
+return AVERROR_INVALIDDATA;
+
+buf = get8(pp, desc_end);
+sample_rate_code = (buf >> 5 ) & 0x07;
+bsid =  buf& 0x1F;
+av_dict_set_int(&st->metadata, "atsc.ac3_desc.sample_rate_code", 
sample_rate_code, 0);
+av_dict_set_int(&st->metadata, "atsc.ac3_desc.bsid", bsid, 0);
+
+buf = get8(pp, desc_end);
+bitrate_code = (buf >> 2 ) & 0x1F;
+surround_mode = buf& 0x03;
+av_dict_set_int(&st->metadata, "atsc.ac3_desc.bitrate_code", 
bitrate_code, 0);
+av_dict_set_int(&st->metadata, "atsc.ac3_desc.surround_mode", 
surround_mode, 0);
+
+buf = get8(pp, desc_end);
+bsmod= (buf >> 5) & 0x07;
+num_channels = (buf >> 1) & 0x0F;
+full_svc = buf & 0x01;
+av_dict_set_int(&st->metadata, "atsc.ac3_desc.bsmod", bsmod, 0);
+av_dict_set_int(&st->metadata, "atsc.ac3_desc.num_channels", 
num_channels, 0);
+av_dict_set_int(&st->metadata, "atsc.ac3_desc.full_svc", full_svc, 
0);
+
+buf = get8(pp, desc_end);
+if (bsmod < 2) {
+mainid   = (buf >> 5) & 0x7;
+priority = (buf >> 3) & 0x3;
+av_dict_set_int(&st->metadata, "atsc.ac3_desc.mainid", mainid, 
0);
+av_dict_set_int(&st->metadata, "atsc.ac3_desc.priority", 
priority, 0);
+} else {
+asvcflags = buf;
+av_dict_set_int(&st->metadata, "atsc.ac3_desc.asvc", 
asvcflags, 0);
+}
+/* other field in standard will be skipped  */
+}
+break;
 case 0x52: /* stream identifier descriptor */
 st->stream_identifier = 1 + get8(pp, desc_end);
 break;
-- 
1.8.3.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 1/8] avformat/mpegts: add dvb ac3 descriptor metadata

2020-07-22 Thread lance . lmwang
From: Limin Wang 

Below is one metadata information for the ts with dvb ac3 descriptor audio:
 ./ffmpeg -i ac3_desc.ts
...
Stream #0:1[0x294]: Audio: ac3 ([6][0][0][0] / 0x0006), 48000 Hz, 
5.1(side), fltp, 448 kb/s
Metadata:
  dvb.ac3_desc.component_type: 68
  dvb.ac3_desc.bsid: 6
  dvb.ac3_desc.mainid: 0

Signed-off-by: Limin Wang 
---
 libavformat/mpegts.c | 22 --
 1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index c6fd3e1..1ed7eaf 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -2073,15 +2073,33 @@ int ff_parse_mpeg2_descriptor(AVFormatContext *fc, 
AVStream *st, int stream_type
 break;
 case 0x6a: /* ac-3_descriptor */
 {
-int component_type_flag = get8(pp, desc_end) & (1 << 7);
+uint8_t flags = get8(pp, desc_end);
+uint8_t component_type_flag = flags & (1 << 7);
+uint8_t bsid_flag   = flags & (1 << 6);
+uint8_t mainid_flag = flags & (1 << 5);
+uint8_t asvc_flag   = flags & (1 << 4);
+
 if (component_type_flag) {
-int component_type = get8(pp, desc_end);
+uint8_t component_type = get8(pp, desc_end);
 int service_type_mask = 0x38;  // 0b00111000
 int service_type = ((component_type & service_type_mask) >> 3);
 if (service_type == 0x02 /* 0b010 */) {
 st->disposition |= AV_DISPOSITION_DESCRIPTIONS;
 av_log(ts ? ts->stream : fc, AV_LOG_DEBUG, "New track 
disposition for id %u: %u\n", st->id, st->disposition);
 }
+av_dict_set_int(&st->metadata, "dvb.ac3_desc.component_type", 
component_type, 0);
+}
+if (bsid_flag) {
+uint8_t bsid = get8(pp, desc_end);
+av_dict_set_int(&st->metadata, "dvb.ac3_desc.bsid", bsid, 0);
+}
+if (mainid_flag) {
+uint8_t mainid = get8(pp, desc_end);
+av_dict_set_int(&st->metadata, "dvb.ac3_desc.mainid", mainid, 
0);
+}
+if (asvc_flag) {
+uint8_t asvc = get8(pp, desc_end);
+av_dict_set_int(&st->metadata, "dvb.ac3_desc.asvc", asvc, 0);
 }
 }
 break;
-- 
1.8.3.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/8] avformat/mpegts: add dvb ac3 descriptor metadata

2020-07-22 Thread Marton Balint



On Wed, 22 Jul 2020, lance.lmw...@gmail.com wrote:


From: Limin Wang 

Below is one metadata information for the ts with dvb ac3 descriptor audio:
./ffmpeg -i ac3_desc.ts
   ...
   Stream #0:1[0x294]: Audio: ac3 ([6][0][0][0] / 0x0006), 48000 Hz, 5.1(side), 
fltp, 448 kb/s
   Metadata:
 dvb.ac3_desc.component_type: 68
 dvb.ac3_desc.bsid: 6
 dvb.ac3_desc.mainid: 0


I don't think it is a good idea to use metadata for this. See how dolby 
vision stores the descripor data, it is using side data and not metadata. 
Also it might make sense to create a generic mpegts descriptor side data 
type?


Regards.
Marton



Signed-off-by: Limin Wang 
---
libavformat/mpegts.c | 22 --
1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index c6fd3e1..1ed7eaf 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -2073,15 +2073,33 @@ int ff_parse_mpeg2_descriptor(AVFormatContext *fc, 
AVStream *st, int stream_type
break;
case 0x6a: /* ac-3_descriptor */
{
-int component_type_flag = get8(pp, desc_end) & (1 << 7);
+uint8_t flags = get8(pp, desc_end);
+uint8_t component_type_flag = flags & (1 << 7);
+uint8_t bsid_flag   = flags & (1 << 6);
+uint8_t mainid_flag = flags & (1 << 5);
+uint8_t asvc_flag   = flags & (1 << 4);
+
if (component_type_flag) {
-int component_type = get8(pp, desc_end);
+uint8_t component_type = get8(pp, desc_end);
int service_type_mask = 0x38;  // 0b00111000
int service_type = ((component_type & service_type_mask) >> 3);
if (service_type == 0x02 /* 0b010 */) {
st->disposition |= AV_DISPOSITION_DESCRIPTIONS;
av_log(ts ? ts->stream : fc, AV_LOG_DEBUG, "New track disposition for 
id %u: %u\n", st->id, st->disposition);
}
+av_dict_set_int(&st->metadata, "dvb.ac3_desc.component_type", 
component_type, 0);
+}
+if (bsid_flag) {
+uint8_t bsid = get8(pp, desc_end);
+av_dict_set_int(&st->metadata, "dvb.ac3_desc.bsid", bsid, 0);
+}
+if (mainid_flag) {
+uint8_t mainid = get8(pp, desc_end);
+av_dict_set_int(&st->metadata, "dvb.ac3_desc.mainid", mainid, 
0);
+}
+if (asvc_flag) {
+uint8_t asvc = get8(pp, desc_end);
+av_dict_set_int(&st->metadata, "dvb.ac3_desc.asvc", asvc, 0);
}
}
break;
--
1.8.3.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".

Re: [FFmpeg-devel] [PATCH 2/8] avformat/mpegts: decode and export ATSC AC-3 descriptor

2020-07-22 Thread Marton Balint



On Wed, 22 Jul 2020, lance.lmw...@gmail.com wrote:


From: Limin Wang 

Signed-off-by: Limin Wang 
---
libavformat/mpegts.c | 42 ++
1 file changed, 42 insertions(+)

diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index 1ed7eaf..d450507 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -1990,6 +1990,48 @@ int ff_parse_mpeg2_descriptor(AVFormatContext *fc, 
AVStream *st, int stream_type
st->request_probe = 50;
}
break;
+case 0x81: /* ATSC AC-3 descriptor */
+{
+uint8_t buf;
+uint8_t sample_rate_code, bsid,bitrate_code,surround_mode, bsmod;
+uint8_t num_channels, full_svc, mainid, priority, asvcflags;
+
+if (desc_len < 4)
+return AVERROR_INVALIDDATA;
+
+buf = get8(pp, desc_end);
+sample_rate_code = (buf >> 5 ) & 0x07;
+bsid =  buf& 0x1F;
+av_dict_set_int(&st->metadata, "atsc.ac3_desc.sample_rate_code", 
sample_rate_code, 0);
+av_dict_set_int(&st->metadata, "atsc.ac3_desc.bsid", bsid, 0);


Same comments as for patch 1/8, do not use metadata for this, either 
define a new side data type for the descriptor data or a side data type 
for arbitrary descriptors...


Regards,
Marton


+
+buf = get8(pp, desc_end);
+bitrate_code = (buf >> 2 ) & 0x1F;
+surround_mode = buf& 0x03;
+av_dict_set_int(&st->metadata, "atsc.ac3_desc.bitrate_code", 
bitrate_code, 0);
+av_dict_set_int(&st->metadata, "atsc.ac3_desc.surround_mode", 
surround_mode, 0);
+
+buf = get8(pp, desc_end);
+bsmod= (buf >> 5) & 0x07;
+num_channels = (buf >> 1) & 0x0F;
+full_svc = buf & 0x01;
+av_dict_set_int(&st->metadata, "atsc.ac3_desc.bsmod", bsmod, 0);
+av_dict_set_int(&st->metadata, "atsc.ac3_desc.num_channels", 
num_channels, 0);
+av_dict_set_int(&st->metadata, "atsc.ac3_desc.full_svc", full_svc, 
0);
+
+buf = get8(pp, desc_end);
+if (bsmod < 2) {
+mainid   = (buf >> 5) & 0x7;
+priority = (buf >> 3) & 0x3;
+av_dict_set_int(&st->metadata, "atsc.ac3_desc.mainid", mainid, 
0);
+av_dict_set_int(&st->metadata, "atsc.ac3_desc.priority", 
priority, 0);
+} else {
+asvcflags = buf;
+av_dict_set_int(&st->metadata, "atsc.ac3_desc.asvc", 
asvcflags, 0);
+}
+/* other field in standard will be skipped  */
+}
+break;
case 0x52: /* stream identifier descriptor */
st->stream_identifier = 1 + get8(pp, desc_end);
break;
--
1.8.3.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".

Re: [FFmpeg-devel] [PATCH 4/8] avformat/mpegtsenc: reindent the last commit

2020-07-22 Thread Marton Balint



On Wed, 22 Jul 2020, lance.lmw...@gmail.com wrote:


From: Limin Wang 

Signed-off-by: Limin Wang 
---
libavformat/mpegtsenc.c | 19 +--
1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 2d7a8ab..28d535a 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -484,16 +484,15 @@ static int mpegts_write_pmt(AVFormatContext *s, 
MpegTSService *service)
switch (st->codecpar->codec_type) {
case AVMEDIA_TYPE_AUDIO:
if (ts->flags & MPEGTS_FLAG_SYSTEM_B) {
-if (st->codecpar->codec_id==AV_CODEC_ID_AC3) {
-*q++=0x6a; // AC3 descriptor see A038 DVB SI
-*q++=1; // 1 byte, all flags sets to 0
-*q++=0; // omit all fields...
-}
-else if (st->codecpar->codec_id==AV_CODEC_ID_EAC3) {
-*q++=0x7a; // EAC3 descriptor see A038 DVB SI
-*q++=1; // 1 byte, all flags sets to 0
-*q++=0; // omit all fields...
-}
+if (st->codecpar->codec_id==AV_CODEC_ID_AC3) {
+*q++=0x6a; // AC3 descriptor see A038 DVB SI
+*q++=1; // 1 byte, all flags sets to 0
+*q++=0; // omit all fields...
+} else if (st->codecpar->codec_id==AV_CODEC_ID_EAC3) {
+*q++=0x7a; // EAC3 descriptor see A038 DVB SI
+*q++=1; // 1 byte, all flags sets to 0
+*q++=0; // omit all fields...
+}
}


LGTM, thanks.

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 3/8] avformat/mpegtsenc: simplify code for condition checks

2020-07-22 Thread Marton Balint



On Wed, 22 Jul 2020, lance.lmw...@gmail.com wrote:


From: Limin Wang 

Signed-off-by: Limin Wang 
---
libavformat/mpegtsenc.c | 6 --
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index d827ba3..2d7a8ab 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -483,16 +483,18 @@ static int mpegts_write_pmt(AVFormatContext *s, 
MpegTSService *service)
/* write optional descriptors here */
switch (st->codecpar->codec_type) {
case AVMEDIA_TYPE_AUDIO:
-if (st->codecpar->codec_id==AV_CODEC_ID_AC3 && (ts->flags & 
MPEGTS_FLAG_SYSTEM_B)) {
+if (ts->flags & MPEGTS_FLAG_SYSTEM_B) {
+if (st->codecpar->codec_id==AV_CODEC_ID_AC3) {
*q++=0x6a; // AC3 descriptor see A038 DVB SI
*q++=1; // 1 byte, all flags sets to 0
*q++=0; // omit all fields...
}
-if (st->codecpar->codec_id==AV_CODEC_ID_EAC3 && (ts->flags & 
MPEGTS_FLAG_SYSTEM_B)) {
+else if (st->codecpar->codec_id==AV_CODEC_ID_EAC3) {
*q++=0x7a; // EAC3 descriptor see A038 DVB SI
*q++=1; // 1 byte, all flags sets to 0
*q++=0; // omit all fields...
}
+}
if (st->codecpar->codec_id==AV_CODEC_ID_S302M)
put_registration_descriptor(&q, MKTAG('B', 'S', 'S', 'D'));
if (st->codecpar->codec_id==AV_CODEC_ID_OPUS) {



LGTM, thanks.

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 5/8] avformat/mpegtsenc: use local variable store st->codecpar->codec_id

2020-07-22 Thread Marton Balint



On Wed, 22 Jul 2020, lance.lmw...@gmail.com wrote:


From: Limin Wang 

Signed-off-by: Limin Wang 
---
libavformat/mpegtsenc.c | 17 +
1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 28d535a..718ddab 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -453,6 +453,7 @@ static int mpegts_write_pmt(AVFormatContext *s, 
MpegTSService *service)
AVStream *st = s->streams[i];
MpegTSWriteStream *ts_st = st->priv_data;
AVDictionaryEntry *lang = av_dict_get(st->metadata, "language", NULL, 
0);
+enum AVCodecID codec_id = st->codecpar->codec_id;

if (s->nb_programs) {
int k, found = 0;
@@ -484,19 +485,19 @@ static int mpegts_write_pmt(AVFormatContext *s, 
MpegTSService *service)
switch (st->codecpar->codec_type) {
case AVMEDIA_TYPE_AUDIO:
if (ts->flags & MPEGTS_FLAG_SYSTEM_B) {
-if (st->codecpar->codec_id==AV_CODEC_ID_AC3) {
+if (codec_id == AV_CODEC_ID_AC3) {
*q++=0x6a; // AC3 descriptor see A038 DVB SI
*q++=1; // 1 byte, all flags sets to 0
*q++=0; // omit all fields...
-} else if (st->codecpar->codec_id==AV_CODEC_ID_EAC3) {
+} else if (codec_id == AV_CODEC_ID_EAC3) {
*q++=0x7a; // EAC3 descriptor see A038 DVB SI
*q++=1; // 1 byte, all flags sets to 0
*q++=0; // omit all fields...
}
}
-if (st->codecpar->codec_id==AV_CODEC_ID_S302M)
+if (codec_id == AV_CODEC_ID_S302M)
put_registration_descriptor(&q, MKTAG('B', 'S', 'S', 'D'));
-if (st->codecpar->codec_id==AV_CODEC_ID_OPUS) {
+if (codec_id == AV_CODEC_ID_OPUS) {
/* 6 bytes registration descriptor, 4 bytes Opus audio 
descriptor */
if (q - data > SECTION_LENGTH - 6 - 4) {
err = 1;
@@ -611,7 +612,7 @@ static int mpegts_write_pmt(AVFormatContext *s, 
MpegTSService *service)
   const char default_language[] = "und";
   const char *language = lang && strlen(lang->value) >= 3 ? 
lang->value : default_language;

-   if (st->codecpar->codec_id == AV_CODEC_ID_DVB_SUBTITLE) {
+   if (codec_id == AV_CODEC_ID_DVB_SUBTITLE) {
   uint8_t *len_ptr;
   int extradata_copied = 0;

@@ -653,7 +654,7 @@ static int mpegts_write_pmt(AVFormatContext *s, 
MpegTSService *service)
   }

   *len_ptr = q - len_ptr - 1;
-   } else if (st->codecpar->codec_id == AV_CODEC_ID_DVB_TELETEXT) {
+   } else if (codec_id == AV_CODEC_ID_DVB_TELETEXT) {
   uint8_t *len_ptr = NULL;
   int extradata_copied = 0;

@@ -697,9 +698,9 @@ static int mpegts_write_pmt(AVFormatContext *s, 
MpegTSService *service)
}
break;
case AVMEDIA_TYPE_DATA:
-if (st->codecpar->codec_id == AV_CODEC_ID_SMPTE_KLV) {
+if (codec_id == AV_CODEC_ID_SMPTE_KLV) {
put_registration_descriptor(&q, MKTAG('K', 'L', 'V', 'A'));
-} else if (st->codecpar->codec_id == AV_CODEC_ID_TIMED_ID3) {
+} else if (codec_id == AV_CODEC_ID_TIMED_ID3) {
const char *tag = "ID3 ";
*q++ = 0x26; /* metadata descriptor */
*q++ = 13;


LGTM, thanks.

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

[FFmpeg-devel] [RFC Patch 1/2] libavformat/rtpdec_jpeg2000: RTP Demuxing for JPEG2000

2020-07-22 Thread gautamramk
From: Gautam Ramakrishnan 

This patch adds support to receive JPEG2000 RTP streams.
---
 libavformat/Makefile  |   1 +
 libavformat/rtpdec.c  |   1 +
 libavformat/rtpdec_formats.h  |   1 +
 libavformat/rtpdec_jpeg2000.c | 116 ++
 4 files changed, 119 insertions(+)
 create mode 100644 libavformat/rtpdec_jpeg2000.c

diff --git a/libavformat/Makefile b/libavformat/Makefile
index 62d8cbb54e..4495047e3a 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -46,6 +46,7 @@ OBJS-$(CONFIG_RTPDEC)+= rdt.o 
  \
 rtpdec_hevc.o   \
 rtpdec_ilbc.o   \
 rtpdec_jpeg.o   \
+rtpdec_jpeg2000.o   \
 rtpdec_latm.o   \
 rtpdec_mpa_robust.o \
 rtpdec_mpeg12.o \
diff --git a/libavformat/rtpdec.c b/libavformat/rtpdec.c
index 3d5b200099..b47dfdfebc 100644
--- a/libavformat/rtpdec.c
+++ b/libavformat/rtpdec.c
@@ -118,6 +118,7 @@ static const RTPDynamicProtocolHandler 
*rtp_dynamic_protocol_handler_list[] = {
 &ff_vorbis_dynamic_handler,
 &ff_vp8_dynamic_handler,
 &ff_vp9_dynamic_handler,
+&ff_jpeg2000_dynamic_handler,
 &gsm_dynamic_handler,
 &l24_dynamic_handler,
 &opus_dynamic_handler,
diff --git a/libavformat/rtpdec_formats.h b/libavformat/rtpdec_formats.h
index dad2b8ac1b..78ea4fb384 100644
--- a/libavformat/rtpdec_formats.h
+++ b/libavformat/rtpdec_formats.h
@@ -89,5 +89,6 @@ extern const RTPDynamicProtocolHandler 
ff_vc2hq_dynamic_handler;
 extern const RTPDynamicProtocolHandler ff_vorbis_dynamic_handler;
 extern const RTPDynamicProtocolHandler ff_vp8_dynamic_handler;
 extern const RTPDynamicProtocolHandler ff_vp9_dynamic_handler;
+extern const RTPDynamicProtocolHandler ff_jpeg2000_dynamic_handler;
 
 #endif /* AVFORMAT_RTPDEC_FORMATS_H */
diff --git a/libavformat/rtpdec_jpeg2000.c b/libavformat/rtpdec_jpeg2000.c
new file mode 100644
index 00..b5337a9cdb
--- /dev/null
+++ b/libavformat/rtpdec_jpeg2000.c
@@ -0,0 +1,116 @@
+/*
+ * Code for the RTP depacketization of JPEG2000.
+ * Copyright (c) 2020 Gautam Ramakrishnan
+ *
+ * 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
+ * @brief JPEG2000 / RTP Code
+ * @author Gautam Ramakrishnan
+ */
+
+#include "rtpdec_formats.h"
+#include "avio_internal.h"
+#include "internal.h"
+#include "libavutil/attributes.h"
+#include "libavutil/avstring.h"
+#include "libavcodec/get_bits.h"
+
+#define PAYLOAD_HDR_SIZ 8
+
+/**
+ * RTP/JPEG specific private data.
+ */
+struct PayloadContext {
+AVIOContext *frame; // current frame buffer
+uint32_ttimestamp;  // current frame timestamp
+};
+
+static void jpeg2000_close_context(PayloadContext *data)
+{
+ffio_free_dyn_buf(&data->frame);
+}
+
+static int jpeg2000_parse_packet(AVFormatContext *ctx, PayloadContext *data,
+AVStream *st, AVPacket *pkt, uint32_t 
*timestamp,
+const uint8_t *buf, int len, uint16_t seq,
+int flags)
+{
+int ret;
+int off;
+
+if (len < 8) {
+av_log(ctx, AV_LOG_ERROR, "Too short RTP/JPEG packet.\n");
+return AVERROR_INVALIDDATA;
+}
+off = (uint64_t)AV_RB64(buf) & 0xFF;
+buf += 8;
+len -= 8;
+if (!off) {
+/* Skip the current frame in case of the end packet
+ * has been lost somewhere. */
+ffio_free_dyn_buf(&data->frame);
+
+if ((ret = avio_open_dyn_buf(&data->frame)) < 0)
+return ret;
+data->timestamp = *timestamp;
+}
+if (!data->frame) {
+av_log(ctx, AV_LOG_ERROR,
+   "Received packet without a start chunk; dropping frame.\n");
+return AVERROR(EAGAIN);
+}
+
+if (data->timestamp != *timestamp) {
+/* Skip the current frame if timestamp is incorrect.
+ * A start packet has been lost somewhere. */
+ffio_free_dyn

[FFmpeg-devel] [RFC Patch 2/2] libavformat/rtpenc_jpeg2000 JPEG2000 RTP Muxer

2020-07-22 Thread gautamramk
From: Gautam Ramakrishnan 

This patch adds support to mux JPEG2000 streams over
RTP.
---
 libavformat/Makefile  |   1 +
 libavformat/rtpenc.c  |   4 ++
 libavformat/rtpenc.h  |   1 +
 libavformat/rtpenc_jpeg2000.c | 121 ++
 libavformat/sdp.c |  32 +
 5 files changed, 159 insertions(+)
 create mode 100644 libavformat/rtpenc_jpeg2000.c

diff --git a/libavformat/Makefile b/libavformat/Makefile
index 4495047e3a..f2d260fada 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -459,6 +459,7 @@ OBJS-$(CONFIG_RTP_MUXER) += rtp.o \
 rtpenc_h263_rfc2190.o \
 rtpenc_h264_hevc.o\
 rtpenc_jpeg.o \
+rtpenc_jpeg2000.o \
 rtpenc_mpv.o \
 rtpenc.o  \
 rtpenc_vc2hq.o  \
diff --git a/libavformat/rtpenc.c b/libavformat/rtpenc.c
index 9ef7e9094d..1af9e3f455 100644
--- a/libavformat/rtpenc.c
+++ b/libavformat/rtpenc.c
@@ -84,6 +84,7 @@ static int is_supported(enum AVCodecID id)
 case AV_CODEC_ID_MJPEG:
 case AV_CODEC_ID_SPEEX:
 case AV_CODEC_ID_OPUS:
+case AV_CODEC_ID_JPEG2000:
 return 1;
 default:
 return 0;
@@ -619,6 +620,9 @@ static int rtp_write_packet(AVFormatContext *s1, AVPacket 
*pkt)
 case AV_CODEC_ID_MJPEG:
 ff_rtp_send_jpeg(s1, pkt->data, size);
 break;
+case AV_CODEC_ID_JPEG2000:
+ff_rtp_send_jpeg2000(s1, pkt->data, size);
+break;
 case AV_CODEC_ID_OPUS:
 if (size > s->max_payload_size) {
 av_log(s1, AV_LOG_ERROR,
diff --git a/libavformat/rtpenc.h b/libavformat/rtpenc.h
index 62dc9ab10a..0db339f2ee 100644
--- a/libavformat/rtpenc.h
+++ b/libavformat/rtpenc.h
@@ -95,6 +95,7 @@ void ff_rtp_send_vc2hq(AVFormatContext *s1, const uint8_t 
*buf, int size, int in
 void ff_rtp_send_vp8(AVFormatContext *s1, const uint8_t *buff, int size);
 void ff_rtp_send_vp9(AVFormatContext *s1, const uint8_t *buff, int size);
 void ff_rtp_send_jpeg(AVFormatContext *s1, const uint8_t *buff, int size);
+void ff_rtp_send_jpeg2000(AVFormatContext *s1, const uint8_t *buff, int size);
 
 const uint8_t *ff_h263_find_resync_marker_reverse(const uint8_t *av_restrict 
start,
   const uint8_t *av_restrict 
end);
diff --git a/libavformat/rtpenc_jpeg2000.c b/libavformat/rtpenc_jpeg2000.c
new file mode 100644
index 00..699bc2e1b9
--- /dev/null
+++ b/libavformat/rtpenc_jpeg2000.c
@@ -0,0 +1,121 @@
+/*
+ * RTP JPEG2000 video Packetizer, RFC 5371
+ * Copyright (c) 2020 Gautam Ramakrishnan
+ *
+ * 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 "libavcodec/bytestream.h"
+#include "libavutil/intreadwrite.h"
+#include "rtpenc.h"
+
+#define PAYLOAD_HDR_SIZ 8
+
+static void send_packet(AVFormatContext *s1, const uint8_t *buf, int start, 
int end,
+   int header, int tileno, int cstream_start, int last)
+{
+RTPMuxContext *s = s1->priv_data;
+int unit_len = end - start;
+int send_left = end - start;
+while (send_left > 0) {
+int len = FFMIN(send_left, s->max_payload_size - PAYLOAD_HDR_SIZ);
+uint8_t flags = 0;
+if (unit_len <= s->max_payload_size - PAYLOAD_HDR_SIZ)
+flags |= 3 << 3;
+else if (header && (send_left - len))
+flags |= 1 << 3;
+else if (header && !(send_left - len))
+flags |= 2 << 3;
+if (header)
+flags |= 1;
+bytestream_put_byte(&s->buf_ptr, flags);
+bytestream_put_byte(&s->buf_ptr, 255);
+bytestream_put_be16(&s->buf_ptr, tileno);
+bytestream_put_byte(&s->buf_ptr, 0);
+bytestream_put_be24(&s->buf_ptr, start - cstream_start);
+memcpy(s->buf_ptr, buf + start, len);
+ff_rtp_send_data(s1, s->buf, len + PAYLOAD_HDR_SIZ, last && send_left 
<= len);
+send_left -= len;
+s->buf_ptr = s->buf;
+start += len;
+}
+}
+
+void ff_rtp_send_jpeg2000

Re: [FFmpeg-devel] [RFC Patch 2/2] libavformat/rtpenc_jpeg2000 JPEG2000 RTP Muxer

2020-07-22 Thread Gautam Ramakrishnan
On Thu, Jul 23, 2020 at 12:56 AM  wrote:
>
> From: Gautam Ramakrishnan 
>
> This patch adds support to mux JPEG2000 streams over
> RTP.
> ---
>  libavformat/Makefile  |   1 +
>  libavformat/rtpenc.c  |   4 ++
>  libavformat/rtpenc.h  |   1 +
>  libavformat/rtpenc_jpeg2000.c | 121 ++
>  libavformat/sdp.c |  32 +
>  5 files changed, 159 insertions(+)
>  create mode 100644 libavformat/rtpenc_jpeg2000.c
>
> diff --git a/libavformat/Makefile b/libavformat/Makefile
> index 4495047e3a..f2d260fada 100644
> --- a/libavformat/Makefile
> +++ b/libavformat/Makefile
> @@ -459,6 +459,7 @@ OBJS-$(CONFIG_RTP_MUXER) += rtp.o 
> \
>  rtpenc_h263_rfc2190.o \
>  rtpenc_h264_hevc.o\
>  rtpenc_jpeg.o \
> +rtpenc_jpeg2000.o \
>  rtpenc_mpv.o \
>  rtpenc.o  \
>  rtpenc_vc2hq.o  \
> diff --git a/libavformat/rtpenc.c b/libavformat/rtpenc.c
> index 9ef7e9094d..1af9e3f455 100644
> --- a/libavformat/rtpenc.c
> +++ b/libavformat/rtpenc.c
> @@ -84,6 +84,7 @@ static int is_supported(enum AVCodecID id)
>  case AV_CODEC_ID_MJPEG:
>  case AV_CODEC_ID_SPEEX:
>  case AV_CODEC_ID_OPUS:
> +case AV_CODEC_ID_JPEG2000:
>  return 1;
>  default:
>  return 0;
> @@ -619,6 +620,9 @@ static int rtp_write_packet(AVFormatContext *s1, AVPacket 
> *pkt)
>  case AV_CODEC_ID_MJPEG:
>  ff_rtp_send_jpeg(s1, pkt->data, size);
>  break;
> +case AV_CODEC_ID_JPEG2000:
> +ff_rtp_send_jpeg2000(s1, pkt->data, size);
> +break;
>  case AV_CODEC_ID_OPUS:
>  if (size > s->max_payload_size) {
>  av_log(s1, AV_LOG_ERROR,
> diff --git a/libavformat/rtpenc.h b/libavformat/rtpenc.h
> index 62dc9ab10a..0db339f2ee 100644
> --- a/libavformat/rtpenc.h
> +++ b/libavformat/rtpenc.h
> @@ -95,6 +95,7 @@ void ff_rtp_send_vc2hq(AVFormatContext *s1, const uint8_t 
> *buf, int size, int in
>  void ff_rtp_send_vp8(AVFormatContext *s1, const uint8_t *buff, int size);
>  void ff_rtp_send_vp9(AVFormatContext *s1, const uint8_t *buff, int size);
>  void ff_rtp_send_jpeg(AVFormatContext *s1, const uint8_t *buff, int size);
> +void ff_rtp_send_jpeg2000(AVFormatContext *s1, const uint8_t *buff, int 
> size);
>
>  const uint8_t *ff_h263_find_resync_marker_reverse(const uint8_t *av_restrict 
> start,
>const uint8_t *av_restrict 
> end);
> diff --git a/libavformat/rtpenc_jpeg2000.c b/libavformat/rtpenc_jpeg2000.c
> new file mode 100644
> index 00..699bc2e1b9
> --- /dev/null
> +++ b/libavformat/rtpenc_jpeg2000.c
> @@ -0,0 +1,121 @@
> +/*
> + * RTP JPEG2000 video Packetizer, RFC 5371
> + * Copyright (c) 2020 Gautam Ramakrishnan
> + *
> + * 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 "libavcodec/bytestream.h"
> +#include "libavutil/intreadwrite.h"
> +#include "rtpenc.h"
> +
> +#define PAYLOAD_HDR_SIZ 8
> +
> +static void send_packet(AVFormatContext *s1, const uint8_t *buf, int start, 
> int end,
> +   int header, int tileno, int cstream_start, int last)
> +{
> +RTPMuxContext *s = s1->priv_data;
> +int unit_len = end - start;
> +int send_left = end - start;
> +while (send_left > 0) {
> +int len = FFMIN(send_left, s->max_payload_size - PAYLOAD_HDR_SIZ);
> +uint8_t flags = 0;
> +if (unit_len <= s->max_payload_size - PAYLOAD_HDR_SIZ)
> +flags |= 3 << 3;
> +else if (header && (send_left - len))
> +flags |= 1 << 3;
> +else if (header && !(send_left - len))
> +flags |= 2 << 3;
> +if (header)
> +flags |= 1;
> +bytestream_put_byte(&s->buf_ptr, flags);
> +bytestream_put_byte(&s->buf_ptr, 255);
> +bytestream_put_be16(&s->buf_ptr, tileno);
> +bytestream_put_byte(&s->buf_ptr, 0);
> +bytestream_put_be24(&s->b

[FFmpeg-devel] An idea to Mix re-encoding with copy to get a fast and precise cut

2020-07-22 Thread Mohammed Hamdy
Hi,

I posted an idea to make ffmpeg do a fast and precise cut, by re-ncoding just 
shorts parts around the cut points, and copy the rest of the desired segment  
without re-encoding. I wish it can be done. Details in here:



https://superuser.com/questions/1570180/can-i-mix-copy-and-encode-in-one-operation-to-have-an-accurate-and-fast-cut

___
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 v2 2/2] libavcodec/libaomenc.c: Add command-line options for inter-coding tools

2020-07-22 Thread Wang Cao
From: Wang Cao 

Signed-off-by: Wang Cao 
---
 doc/encoders.texi  | 36 +
 libavcodec/libaomenc.c | 60 ++
 libavcodec/version.h   |  2 +-
 3 files changed, 97 insertions(+), 1 deletion(-)

diff --git a/doc/encoders.texi b/doc/encoders.texi
index ecdfacbd69..ed8ef63784 100644
--- a/doc/encoders.texi
+++ b/doc/encoders.texi
@@ -1649,6 +1649,42 @@ Use DCT only for INTER modes. Default is false.
 @item use-intra-default-tx-only (@emph{boolean}) (Requires libaom >= v2.0.0)
 Use Default-transform only for INTRA modes. Default is false.
 
+@item enable-ref-frame-mvs (@emph{boolean}) (Requires libaom >= v2.0.0)
+Enable temporal mv prediction. Default is true.
+
+@item enable-reduced-reference-set (@emph{boolean}) (Requires libaom >= v2.0.0)
+Use reduced set of single and compound references. Default is false.
+
+@item enable-obmc (@emph{boolean}) (Requires libaom >= v2.0.0)
+Enable obmc. Default is true.
+
+@item enable-dual-filter (@emph{boolean}) (Requires libaom >= v2.0.0)
+Enable dual filter. Default is true.
+
+@item enable-diff-wtd-comp (@emph{boolean}) (Requires libaom >= v2.0.0)
+Enable difference-weighted compound. Default is true.
+
+@item enable-dist-wtd-comp (@emph{boolean}) (Requires libaom >= v2.0.0)
+Enable distance-weighted compound. Default is true.
+
+@item enable-onesided-comp (@emph{boolean}) (Requires libaom >= v2.0.0)
+Enable one sided compound. Default is true.
+
+@item enable-interinter-wedge (@emph{boolean}) (Requires libaom >= v2.0.0)
+Enable interinter wedge compound. Default is true.
+
+@item enable-interintra-wedge (@emph{boolean}) (Requires libaom >= v2.0.0)
+Enable interintra wedge compound. Default is true.
+
+@item enable-masked-comp (@emph{boolean}) (Requires libaom >= v2.0.0)
+Enable masked compound. Default is true.
+
+@item enable-interintra-comp (@emph{boolean}) (Requires libaom >= v2.0.0)
+Enable interintra compound. Default is true.
+
+@item enable-smooth-interintra (@emph{boolean}) (Requires libaom >= v2.0.0)
+Enable smooth interintra mode. Default is true.
+
 @end table
 
 @section libkvazaar
diff --git a/libavcodec/libaomenc.c b/libavcodec/libaomenc.c
index d731f566d2..18afa20a2e 100644
--- a/libavcodec/libaomenc.c
+++ b/libavcodec/libaomenc.c
@@ -112,6 +112,18 @@ typedef struct AOMEncoderContext {
 int use_intra_dct_only;
 int use_inter_dct_only;
 int use_intra_default_tx_only;
+int enable_ref_frame_mvs;
+int enable_interinter_wedge;
+int enable_interintra_wedge;
+int enable_interintra_comp;
+int enable_masked_comp;
+int enable_obmc;
+int enable_onesided_comp;
+int enable_reduced_reference_set;
+int enable_smooth_interintra;
+int enable_diff_wtd_comp;
+int enable_dist_wtd_comp;
+int enable_dual_filter;
 } AOMContext;
 
 static const char *const ctlidstr[] = {
@@ -168,6 +180,18 @@ static const char *const ctlidstr[] = {
 [AV1E_SET_INTER_DCT_ONLY]= "AV1E_SET_INTER_DCT_ONLY",
 [AV1E_SET_INTRA_DEFAULT_TX_ONLY] = "AV1E_SET_INTRA_DEFAULT_TX_ONLY",
 [AV1E_SET_REDUCED_TX_TYPE_SET]   = "AV1E_SET_REDUCED_TX_TYPE_SET",
+[AV1E_SET_ENABLE_DIFF_WTD_COMP] = "AV1E_SET_ENABLE_DIFF_WTD_COMP",
+[AV1E_SET_ENABLE_DIST_WTD_COMP] = "AV1E_SET_ENABLE_DIST_WTD_COMP",
+[AV1E_SET_ENABLE_DUAL_FILTER]   = "AV1E_SET_ENABLE_DUAL_FILTER",
+[AV1E_SET_ENABLE_INTERINTER_WEDGE]  = "AV1E_SET_ENABLE_INTERINTER_WEDGE",
+[AV1E_SET_ENABLE_INTERINTRA_WEDGE]  = "AV1E_SET_ENABLE_INTERINTRA_WEDGE",
+[AV1E_SET_ENABLE_MASKED_COMP]   = "AV1E_SET_ENABLE_MASKED_COMP",
+[AV1E_SET_ENABLE_INTERINTRA_COMP]   = "AV1E_SET_ENABLE_INTERINTRA_COMP",
+[AV1E_SET_ENABLE_OBMC]  = "AV1E_SET_ENABLE_OBMC",
+[AV1E_SET_ENABLE_ONESIDED_COMP] = "AV1E_SET_ENABLE_ONESIDED_COMP",
+[AV1E_SET_REDUCED_REFERENCE_SET]= "AV1E_SET_REDUCED_REFERENCE_SET",
+[AV1E_SET_ENABLE_SMOOTH_INTERINTRA] = "AV1E_SET_ENABLE_SMOOTH_INTERINTRA",
+[AV1E_SET_ENABLE_REF_FRAME_MVS] = "AV1E_SET_ENABLE_REF_FRAME_MVS",
 #endif
 };
 
@@ -764,6 +788,30 @@ static av_cold int aom_init(AVCodecContext *avctx,
 codecctl_int(avctx, AV1E_SET_INTRA_DEFAULT_TX_ONLY, 
ctx->use_intra_default_tx_only);
 if (ctx->reduced_tx_type_set >= 0)
 codecctl_int(avctx, AV1E_SET_REDUCED_TX_TYPE_SET, 
ctx->reduced_tx_type_set);
+if (ctx->enable_ref_frame_mvs >= 0)
+codecctl_int(avctx, AV1E_SET_ENABLE_REF_FRAME_MVS, 
ctx->enable_ref_frame_mvs);
+if (ctx->enable_reduced_reference_set >= 0)
+codecctl_int(avctx, AV1E_SET_REDUCED_REFERENCE_SET, 
ctx->enable_reduced_reference_set);
+if (ctx->enable_diff_wtd_comp >= 0)
+codecctl_int(avctx, AV1E_SET_ENABLE_DIFF_WTD_COMP, 
ctx->enable_diff_wtd_comp);
+if (ctx->enable_dist_wtd_comp >= 0)
+codecctl_int(avctx, AV1E_SET_ENABLE_DIST_WTD_COMP, 
ctx->enable_dist_wtd_comp);
+if (ctx->enable_dual_filter >= 0)
+codecctl_int(avctx, AV1E_SET_ENABLE_DUAL_FILTER, 

[FFmpeg-devel] [PATCH v2 1/2] libavcodec/libaomenc.c: Add command-line options for tx tools.

2020-07-22 Thread Wang Cao
From: Wang Cao 

Signed-off-by: Wang Cao 
---
 doc/encoders.texi  | 20 
 libavcodec/libaomenc.c | 30 ++
 libavcodec/version.h   |  2 +-
 3 files changed, 51 insertions(+), 1 deletion(-)

diff --git a/doc/encoders.texi b/doc/encoders.texi
index 23542c8a62..ecdfacbd69 100644
--- a/doc/encoders.texi
+++ b/doc/encoders.texi
@@ -1629,6 +1629,26 @@ Enable paeth predictor in intra prediction. Default is 
true.
 @item enable-palette (@emph{boolean}) (Requires libaom >= v2.0.0)
 Enable palette prediction mode. Default is true.
 
+@item enable-flip-idtx (@emph{boolean}) (Requires libaom >= v2.0.0)
+Enable extended transform type, including FLIPADST_DCT, DCT_FLIPADST,
+FLIPADST_FLIPADST, ADST_FLIPADST, FLIPADST_ADST, IDTX, V_DCT, H_DCT,
+V_ADST, H_ADST, V_FLIPADST, H_FLIPADST. Default is true.
+
+@item enable-tx64 (@emph{boolean}) (Requires libaom >= v2.0.0)
+Enable 64-pt transform. Default is true.
+
+@item reduced-tx-type-set (@emph{boolean}) (Requires libaom >= v2.0.0)
+Use reduced set of transform types. Default is false.
+
+@item use-intra-dct-only (@emph{boolean}) (Requires libaom >= v2.0.0)
+Use DCT only for INTRA modes. Default is false.
+
+@item use-inter-dct-only (@emph{boolean}) (Requires libaom >= v2.0.0)
+Use DCT only for INTER modes. Default is false.
+
+@item use-intra-default-tx-only (@emph{boolean}) (Requires libaom >= v2.0.0)
+Use Default-transform only for INTRA modes. Default is false.
+
 @end table
 
 @section libkvazaar
diff --git a/libavcodec/libaomenc.c b/libavcodec/libaomenc.c
index b65e491824..d731f566d2 100644
--- a/libavcodec/libaomenc.c
+++ b/libavcodec/libaomenc.c
@@ -106,6 +106,12 @@ typedef struct AOMEncoderContext {
 int enable_intra_edge_filter;
 int enable_palette;
 int enable_filter_intra;
+int enable_flip_idtx;
+int enable_tx64;
+int reduced_tx_type_set;
+int use_intra_dct_only;
+int use_inter_dct_only;
+int use_intra_default_tx_only;
 } AOMContext;
 
 static const char *const ctlidstr[] = {
@@ -156,6 +162,12 @@ static const char *const ctlidstr[] = {
 [AV1E_SET_ENABLE_PAETH_INTRA]   = "AV1E_SET_ENABLE_PAETH_INTRA",
 [AV1E_SET_ENABLE_SMOOTH_INTRA]  = "AV1E_SET_ENABLE_SMOOTH_INTRA",
 [AV1E_SET_ENABLE_PALETTE]   = "AV1E_SET_ENABLE_PALETTE",
+[AV1E_SET_ENABLE_FLIP_IDTX]  = "AV1E_SET_ENABLE_FLIP_IDTX",
+[AV1E_SET_ENABLE_TX64]   = "AV1E_SET_ENABLE_TX64",
+[AV1E_SET_INTRA_DCT_ONLY]= "AV1E_SET_INTRA_DCT_ONLY",
+[AV1E_SET_INTER_DCT_ONLY]= "AV1E_SET_INTER_DCT_ONLY",
+[AV1E_SET_INTRA_DEFAULT_TX_ONLY] = "AV1E_SET_INTRA_DEFAULT_TX_ONLY",
+[AV1E_SET_REDUCED_TX_TYPE_SET]   = "AV1E_SET_REDUCED_TX_TYPE_SET",
 #endif
 };
 
@@ -740,6 +752,18 @@ static av_cold int aom_init(AVCodecContext *avctx,
 codecctl_int(avctx, AV1E_SET_ENABLE_SMOOTH_INTRA, 
ctx->enable_smooth_intra);
 if (ctx->enable_palette >= 0)
 codecctl_int(avctx, AV1E_SET_ENABLE_PALETTE, ctx->enable_palette);
+if (ctx->enable_tx64 >= 0)
+codecctl_int(avctx, AV1E_SET_ENABLE_TX64, ctx->enable_tx64);
+if (ctx->enable_flip_idtx >= 0)
+codecctl_int(avctx, AV1E_SET_ENABLE_FLIP_IDTX, ctx->enable_flip_idtx);
+if (ctx->use_intra_dct_only >= 0)
+codecctl_int(avctx, AV1E_SET_INTRA_DCT_ONLY, ctx->use_intra_dct_only);
+if (ctx->use_inter_dct_only >= 0)
+codecctl_int(avctx, AV1E_SET_INTER_DCT_ONLY, ctx->use_inter_dct_only);
+if (ctx->use_intra_default_tx_only >= 0)
+codecctl_int(avctx, AV1E_SET_INTRA_DEFAULT_TX_ONLY, 
ctx->use_intra_default_tx_only);
+if (ctx->reduced_tx_type_set >= 0)
+codecctl_int(avctx, AV1E_SET_REDUCED_TX_TYPE_SET, 
ctx->reduced_tx_type_set);
 #endif
 
 codecctl_int(avctx, AOME_SET_STATIC_THRESHOLD, ctx->static_thresh);
@@ -1171,6 +1195,12 @@ static const AVOption options[] = {
 { "enable-smooth-intra",  "Enable smooth intra prediction mode",   
 OFFSET(enable_smooth_intra),  AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 
1, VE},
 { "enable-paeth-intra",   "Enable paeth predictor in intra 
prediction", OFFSET(enable_paeth_intra),   AV_OPT_TYPE_BOOL, {.i64 
= -1}, -1, 1, VE},
 { "enable-palette",   "Enable palette prediction mode",
 OFFSET(enable_palette),   AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 
1, VE},
+{ "enable-flip-idtx",  "Enable extended transform type",   
  OFFSET(enable_flip_idtx),  AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
+{ "enable-tx64",   "Enable 64-pt transform",   
  OFFSET(enable_tx64),   AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
+{ "reduced-tx-type-set",   "Use reduced set of transform types.",  
  OFFSET(reduced_tx_type_set),   AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
+{ "use-intra-dct-only","Use DCT only for INTRA modes", 
  OFFSET(use_intra_dct_only),AV_OPT_TYPE

Re: [FFmpeg-devel] [PATCH 1/8] avformat/mpegts: add dvb ac3 descriptor metadata

2020-07-22 Thread lance . lmwang
On Wed, Jul 22, 2020 at 07:44:06PM +0200, Marton Balint wrote:
> 
> 
> On Wed, 22 Jul 2020, lance.lmw...@gmail.com wrote:
> 
> > From: Limin Wang 
> > 
> > Below is one metadata information for the ts with dvb ac3 descriptor audio:
> > ./ffmpeg -i ac3_desc.ts
> >...
> >Stream #0:1[0x294]: Audio: ac3 ([6][0][0][0] / 0x0006), 48000 Hz, 
> > 5.1(side), fltp, 448 kb/s
> >Metadata:
> >  dvb.ac3_desc.component_type: 68
> >  dvb.ac3_desc.bsid: 6
> >  dvb.ac3_desc.mainid: 0
> 
> I don't think it is a good idea to use metadata for this. See how dolby
> vision stores the descripor data, it is using side data and not metadata.
> Also it might make sense to create a generic mpegts descriptor side data
> type?

Thanks for the comments, I'll try to use side data for the descriptor instead. 
The descriptor is
codec related also, so I have no idea how to make it generic if need to export 
the field. EAC3
and AC3 may share same type, as it's use reserved bits to extend it. 

> 
> Regards.
> Marton
> 
> > 
> > Signed-off-by: Limin Wang 
> > ---
> > libavformat/mpegts.c | 22 --
> > 1 file changed, 20 insertions(+), 2 deletions(-)
> > 
> > diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
> > index c6fd3e1..1ed7eaf 100644
> > --- a/libavformat/mpegts.c
> > +++ b/libavformat/mpegts.c
> > @@ -2073,15 +2073,33 @@ int ff_parse_mpeg2_descriptor(AVFormatContext *fc, 
> > AVStream *st, int stream_type
> > break;
> > case 0x6a: /* ac-3_descriptor */
> > {
> > -int component_type_flag = get8(pp, desc_end) & (1 << 7);
> > +uint8_t flags = get8(pp, desc_end);
> > +uint8_t component_type_flag = flags & (1 << 7);
> > +uint8_t bsid_flag   = flags & (1 << 6);
> > +uint8_t mainid_flag = flags & (1 << 5);
> > +uint8_t asvc_flag   = flags & (1 << 4);
> > +
> > if (component_type_flag) {
> > -int component_type = get8(pp, desc_end);
> > +uint8_t component_type = get8(pp, desc_end);
> > int service_type_mask = 0x38;  // 0b00111000
> > int service_type = ((component_type & service_type_mask) >> 
> > 3);
> > if (service_type == 0x02 /* 0b010 */) {
> > st->disposition |= AV_DISPOSITION_DESCRIPTIONS;
> > av_log(ts ? ts->stream : fc, AV_LOG_DEBUG, "New track 
> > disposition for id %u: %u\n", st->id, st->disposition);
> > }
> > +av_dict_set_int(&st->metadata, 
> > "dvb.ac3_desc.component_type", component_type, 0);
> > +}
> > +if (bsid_flag) {
> > +uint8_t bsid = get8(pp, desc_end);
> > +av_dict_set_int(&st->metadata, "dvb.ac3_desc.bsid", bsid, 
> > 0);
> > +}
> > +if (mainid_flag) {
> > +uint8_t mainid = get8(pp, desc_end);
> > +av_dict_set_int(&st->metadata, "dvb.ac3_desc.mainid", 
> > mainid, 0);
> > +}
> > +if (asvc_flag) {
> > +uint8_t asvc = get8(pp, desc_end);
> > +av_dict_set_int(&st->metadata, "dvb.ac3_desc.asvc", asvc, 
> > 0);
> > }
> > }
> > break;
> > -- 
> > 1.8.3.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".

-- 
Thanks,
Limin Wang
___
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] Support HDR10+ metadata for HEVC

2020-07-22 Thread Mohammad Izadi
Please see my answers inline:


On Thu, Jul 16, 2020 at 1:30 PM Carl Eugen Hoyos  wrote:

> Am Do., 16. Juli 2020 um 21:24 Uhr schrieb Mohammad Izadi
> :
>
> > -user_identifier = get_bits_long(gb, 32);
> > -
> > -switch (user_identifier) {
> > -case MKBETAG('G', 'A', '9', '4'):
>
> Why did you have to change this existing code?
>
> We need to read the metadata (A/341 Amendment – 2094-40
)
from the ITU-T T.35. Here is the point we need to read ITU-T T.35 and
decode it. I will update the commit message to explain it.

> Could you elaborate a little on the use-cases this patch supports (and
> does not support) in the commit message?
>
> Sure, I'll do.

> A micro version bump should be sufficient.
>
> Carl Eugen
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
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".