Re: [FFmpeg-devel] [PATCH 1/6] avcodec/libvpxenc: fix alpha stride

2019-11-05 Thread James Zern
On Fri, Nov 1, 2019 at 11:47 AM James Zern  wrote:
>
> On Sun, Oct 27, 2019 at 10:10 AM Marton Balint  wrote:
> >
> > Signed-off-by: Marton Balint 
> > ---
> >  libavcodec/libvpxenc.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
>
> lgtm.

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

Re: [FFmpeg-devel] [PATCH 3/6] avcodec/libvpxdec: make sure BlockAdditional side data size >= 8

2019-11-05 Thread James Zern
On Fri, Nov 1, 2019 at 11:52 AM James Zern  wrote:
>
> On Sun, Oct 27, 2019 at 10:11 AM Marton Balint  wrote:
> >
> > Signed-off-by: Marton Balint 
> > ---
> >  libavcodec/libvpxdec.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
>
> lgtm. good catch.

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

Re: [FFmpeg-devel] [PATCH 6/6] avcodec/libvpxdec: reject video and alpha dimension mismatches

2019-11-05 Thread James Zern
On Fri, Nov 1, 2019 at 1:01 PM James Zern  wrote:
>
> On Sun, Oct 27, 2019 at 10:11 AM Marton Balint  wrote:
> >
> > Signed-off-by: Marton Balint 
> > ---
> >  libavcodec/libvpxdec.c | 11 +++
> >  1 file changed, 11 insertions(+)
> >
>
> lgtm.

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

Re: [FFmpeg-devel] [PATCH] avcodec/extract_extradata_bsf: fix typo in comments

2019-11-05 Thread Gyan



On 06-11-2019 12:30 pm, leozhang wrote:

Signed-off-by: leozhang 
---
  libavcodec/extract_extradata_bsf.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/extract_extradata_bsf.c 
b/libavcodec/extract_extradata_bsf.c
index 17e5deb..ff111de 100644
--- a/libavcodec/extract_extradata_bsf.c
+++ b/libavcodec/extract_extradata_bsf.c
@@ -38,10 +38,10 @@ typedef struct ExtractExtradataContext {
  int (*extract)(AVBSFContext *ctx, AVPacket *pkt,
 uint8_t **data, int *size);
  
-/* AV1 specifc fields */

+/* AV1 specific fields */
  AV1Packet av1_pkt;
  
-/* H264/HEVC specifc fields */

+/* H264/HEVC specific fields */
  H2645Packet h2645_pkt;
  
  /* AVOptions */


LGTM.

Gyan
___
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/6] avcodec/libvpxdec: decode to custom framebuffers for vp9

2019-11-05 Thread James Zern
On Fri, Nov 1, 2019 at 1:01 PM James Zern  wrote:
>
> On Sun, Oct 27, 2019 at 10:11 AM Marton Balint  wrote:
> >
> > This avoids copying the full frame after decoding.
> >
> > Signed-off-by: Marton Balint 
> > ---
> >  libavcodec/libvpxdec.c | 73 
> > ++
> >  1 file changed, 68 insertions(+), 5 deletions(-)
> >
>
> lgtm.
>

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

Re: [FFmpeg-devel] [PATCH 4/6] avcodec/libvpxdec: pass decoder instances to vpx_init directly

2019-11-05 Thread James Zern
On Fri, Nov 1, 2019 at 11:55 AM James Zern  wrote:
>
> On Sun, Oct 27, 2019 at 10:11 AM Marton Balint  wrote:
> >
> > If the alpha decoder init failed we presented the error message from the 
> > normal
> > decoder. This change should prevent such mistakes.
> >
> > Signed-off-by: Marton Balint 
> > ---
> >  libavcodec/libvpxdec.c | 26 +-
> >  1 file changed, 13 insertions(+), 13 deletions(-)
> >
>
> lgtm.

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

Re: [FFmpeg-devel] [PATCHv2 2/6] avcodec/libvpxenc: only allocate alpha U/V planes on size changes

2019-11-05 Thread James Zern
On Mon, Nov 4, 2019 at 4:55 PM James Zern  wrote:
>
> On Sat, Nov 2, 2019 at 9:20 AM Marton Balint  wrote:
> >
> > Signed-off-by: Marton Balint 
> > ---
> >  libavcodec/libvpxenc.c | 60 
> > ++
> >  1 file changed, 36 insertions(+), 24 deletions(-)
> >
>
> lgtm. I'll apply this set of patches soon if there aren't any further 
> comments.
>

applied, 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] lavc/vaapi_decode: Set surfaces reference pool size according to SPS for H.264/HEVC

2019-11-05 Thread Linjie Fu
Set surfaces pool used for storing reference frames dynamically
according to SPS.(reference framecount, reordered frame number, etc)

Compared to a fixed pool size for H.264 and HEVC, the usage of
GPU memory could be improved.

CMD:
ffmpeg -hwaccel vaapi -vaapi_device /dev/dri/renderD128
-i bbb_sunflower_1080p_30fps_normal.mp4 -f null -
Source:
https://download.blender.org/demo/movies/BBB/

GEM Object memory usage:
watch cat /sys/kernel/debug/dri/0/i915_gem_objects
Before:
~112M
After:
~80M

Signed-off-by: Linjie Fu 
---
 libavcodec/vaapi_decode.c | 39 ++-
 libavcodec/vaapi_decode.h |  3 +++
 libavcodec/vaapi_h264.c   | 11 ++-
 libavcodec/vaapi_hevc.c   | 11 ++-
 libavcodec/vaapi_vp8.c|  8 +++-
 libavcodec/vaapi_vp9.c|  8 +++-
 6 files changed, 55 insertions(+), 25 deletions(-)

diff --git a/libavcodec/vaapi_decode.c b/libavcodec/vaapi_decode.c
index 69512e1d45..5fc9767802 100644
--- a/libavcodec/vaapi_decode.c
+++ b/libavcodec/vaapi_decode.c
@@ -408,7 +408,8 @@ static const struct {
 static int vaapi_decode_make_config(AVCodecContext *avctx,
 AVBufferRef *device_ref,
 VAConfigID *va_config,
-AVBufferRef *frames_ref)
+AVBufferRef *frames_ref,
+int dpb_size)
 {
 AVVAAPIHWConfig   *hwconfig= NULL;
 AVHWFramesConstraints *constraints = NULL;
@@ -549,22 +550,8 @@ static int vaapi_decode_make_config(AVCodecContext *avctx,
 if (err < 0)
 goto fail;
 
-frames->initial_pool_size = 1;
-// Add per-codec number of surfaces used for storing reference frames.
-switch (avctx->codec_id) {
-case AV_CODEC_ID_H264:
-case AV_CODEC_ID_HEVC:
-frames->initial_pool_size += 16;
-break;
-case AV_CODEC_ID_VP9:
-frames->initial_pool_size += 8;
-break;
-case AV_CODEC_ID_VP8:
-frames->initial_pool_size += 3;
-break;
-default:
-frames->initial_pool_size += 2;
-}
+if (dpb_size > 0)
+frames->initial_pool_size = dpb_size + 1;
 }
 
 av_hwframe_constraints_free(&constraints);
@@ -583,8 +570,9 @@ fail:
 return err;
 }
 
-int ff_vaapi_common_frame_params(AVCodecContext *avctx,
- AVBufferRef *hw_frames_ctx)
+int ff_vaapi_frame_params_with_dpb_size(AVCodecContext *avctx,
+AVBufferRef *hw_frames_ctx,
+int dpb_size)
 {
 AVHWFramesContext *hw_frames = (AVHWFramesContext *)hw_frames_ctx->data;
 AVHWDeviceContext *device_ctx = hw_frames->device_ctx;
@@ -597,7 +585,7 @@ int ff_vaapi_common_frame_params(AVCodecContext *avctx,
 hwctx = device_ctx->hwctx;
 
 err = vaapi_decode_make_config(avctx, hw_frames->device_ref, &va_config,
-   hw_frames_ctx);
+   hw_frames_ctx, dpb_size);
 if (err)
 return err;
 
@@ -607,6 +595,13 @@ int ff_vaapi_common_frame_params(AVCodecContext *avctx,
 return 0;
 }
 
+int ff_vaapi_common_frame_params(AVCodecContext *avctx,
+ AVBufferRef *hw_frames_ctx)
+{
+// Set common dpb_size for vc1/mjpeg/mpeg2/mpeg4.
+return ff_vaapi_frame_params_with_dpb_size(avctx, hw_frames_ctx, 2);
+}
+
 int ff_vaapi_decode_init(AVCodecContext *avctx)
 {
 VAAPIDecodeContext *ctx = avctx->internal->hwaccel_priv_data;
@@ -666,7 +661,9 @@ int ff_vaapi_decode_init(AVCodecContext *avctx)
 ctx->hwctx  = ctx->device->hwctx;
 
 err = vaapi_decode_make_config(avctx, ctx->frames->device_ref,
-   &ctx->va_config, avctx->hw_frames_ctx);
+   &ctx->va_config, avctx->hw_frames_ctx,
+   0);
+
 if (err)
 goto fail;
 
diff --git a/libavcodec/vaapi_decode.h b/libavcodec/vaapi_decode.h
index 6b415dd1d3..c3e74bf9c7 100644
--- a/libavcodec/vaapi_decode.h
+++ b/libavcodec/vaapi_decode.h
@@ -98,6 +98,9 @@ int ff_vaapi_decode_cancel(AVCodecContext *avctx,
 int ff_vaapi_decode_init(AVCodecContext *avctx);
 int ff_vaapi_decode_uninit(AVCodecContext *avctx);
 
+int ff_vaapi_frame_params_with_dpb_size(AVCodecContext *avctx,
+AVBufferRef *hw_frames_ctx,
+int dpb_size);
 int ff_vaapi_common_frame_params(AVCodecContext *avctx,
  AVBufferRef *hw_frames_ctx);
 
diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
index dd2a657160..8d7f5c2004 100644
--- a/libavcodec/vaapi_h264.c
+++ b/libavcodec/vaapi_h264.c
@@ -385,6 +385,15 @@ static int vaapi_h264_decode_slice(AVCodecContext *avctx,
 return 0;
 }
 
+static int 

[FFmpeg-devel] [PATCH 21/23] avformat/matroskaenc: Only write tracks if there is a track

2019-11-05 Thread Andreas Rheinhardt
The Matroska muxer does not write every stream as a Matroska track; some
streams are written as attachments. But should no stream be written as a
Matroska track, the Matroska muxer would nevertheless write a Tracks
element without a TrackEntry. This is against the spec. This commit
changes this and only writes a Tracks if there is a Matroska track.

Signed-off-by: Andreas Rheinhardt 
---
 libavformat/matroskaenc.c | 19 ---
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index 1effe209b4..df13d05dab 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -134,7 +134,7 @@ typedef struct MatroskaMuxContext {
 
 AVPacketcur_audio_pkt;
 
-int have_attachments;
+int nb_attachments;
 int have_video;
 
 int reserve_cues_space;
@@ -1112,7 +1112,6 @@ static int mkv_write_track(AVFormatContext *s, 
MatroskaMuxContext *mkv,
 AVDictionaryEntry *tag;
 
 if (par->codec_type == AVMEDIA_TYPE_ATTACHMENT) {
-mkv->have_attachments = 1;
 return 0;
 }
 
@@ -1374,6 +1373,9 @@ static int mkv_write_tracks(AVFormatContext *s)
 AVIOContext *pb = s->pb;
 int i, ret, default_stream_exists = 0;
 
+if (mkv->nb_attachments == s->nb_streams)
+return 0;
+
 mkv_add_seekhead_entry(mkv, MATROSKA_ID_TRACKS, avio_tell(pb));
 
 ret = start_ebml_master_crc32(pb, &mkv->tracks_bc, mkv, 
MATROSKA_ID_TRACKS);
@@ -1631,7 +1633,7 @@ static int mkv_write_tags(AVFormatContext *s)
 }
 }
 
-if (mkv->have_attachments && mkv->mode != MODE_WEBM) {
+if (mkv->nb_attachments && mkv->mode != MODE_WEBM) {
 for (i = 0; i < s->nb_streams; i++) {
 mkv_track *track = &mkv->tracks[i];
 AVStream *st = s->streams[i];
@@ -1678,7 +1680,7 @@ static int mkv_write_attachments(AVFormatContext *s)
 AVIOContext *dyn_cp, *pb = s->pb;
 int i, ret;
 
-if (!mkv->have_attachments)
+if (!mkv->nb_attachments)
 return 0;
 
 mkv_add_seekhead_entry(mkv, MATROSKA_ID_ATTACHMENTS, avio_tell(pb));
@@ -2487,9 +2489,11 @@ static int mkv_write_trailer(AVFormatContext *s)
 avio_seek(pb, mkv->info_pos, SEEK_SET);
 end_ebml_master_crc32(pb, &mkv->info_bc, mkv);
 
-// write tracks master
-avio_seek(pb, mkv->tracks_pos, SEEK_SET);
-end_ebml_master_crc32(pb, &mkv->tracks_bc, mkv);
+if (mkv->tracks_bc) {
+// write tracks master
+avio_seek(pb, mkv->tracks_pos, SEEK_SET);
+end_ebml_master_crc32(pb, &mkv->tracks_bc, mkv);
+}
 
 // update stream durations
 if (mkv->tags_bc) {
@@ -2650,6 +2654,7 @@ static int mkv_init(struct AVFormatContext *s)
 "it cannot be deduced from the codec 
id.\n", i);
 return AVERROR(EINVAL);
 }
+mkv->nb_attachments++;
 continue;
 }
 
-- 
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 10/23] avformat/matroskaenc: Automatically use right TrackNumber in cues

2019-11-05 Thread Andreas Rheinhardt
mkv_cuepoint (the structure used to store the index entries in our
Matroska muxer) currently contains fields for both the index of the
packet's stream in the AVFormatContext->streams array and for the
Matroska TrackNumber; correspondingly, mkv_add_cuepoint() has arguments
for both. But these two numbers can't be chosen independently, so get
rid of the TrackNumber.

Signed-off-by: Andreas Rheinhardt 
---
One could make mkv_cuepoint smaller if one switched relative_pos to an
int, but this is similar to the last rejected patch.

 libavformat/matroskaenc.c | 12 +---
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index 0c3796f924..1377891e96 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -80,7 +80,6 @@ typedef struct mkv_seekhead {
 typedef struct mkv_cuepoint {
 uint64_tpts;
 int stream_idx;
-int tracknum;
 int64_t cluster_pos;///< offset of the cluster containing 
the block relative to the segment
 int64_t relative_pos;   ///< relative offset from the position 
of the cluster containing the block
 int64_t duration;   ///< duration of the block according 
to time base
@@ -481,7 +480,7 @@ static mkv_cues *mkv_start_cues(int64_t segment_offset)
 return cues;
 }
 
-static int mkv_add_cuepoint(mkv_cues *cues, int stream, int tracknum, int64_t 
ts,
+static int mkv_add_cuepoint(mkv_cues *cues, int stream, int64_t ts,
 int64_t cluster_pos, int64_t relative_pos, int64_t 
duration)
 {
 mkv_cuepoint *entries = cues->entries;
@@ -496,7 +495,6 @@ static int mkv_add_cuepoint(mkv_cues *cues, int stream, int 
tracknum, int64_t ts
 
 cues->entries[cues->num_entries].pts   = ts;
 cues->entries[cues->num_entries].stream_idx= stream;
-cues->entries[cues->num_entries].tracknum  = tracknum;
 cues->entries[cues->num_entries].cluster_pos   = cluster_pos - 
cues->segment_offset;
 cues->entries[cues->num_entries].relative_pos  = relative_pos;
 cues->entries[cues->num_entries++].duration= duration;
@@ -549,7 +547,7 @@ static int64_t mkv_write_cues(AVFormatContext *s, mkv_cues 
*cues, mkv_track *tra
 continue;
 tracks[idx].has_cue = 1;
 track_positions = start_ebml_master(dyn_cp, 
MATROSKA_ID_CUETRACKPOSITION, MAX_CUETRACKPOS_SIZE);
-put_ebml_uint(dyn_cp, MATROSKA_ID_CUETRACK   , 
entry[j].tracknum   );
+put_ebml_uint(dyn_cp, MATROSKA_ID_CUETRACK   , 
tracks[idx].track_num);
 put_ebml_uint(dyn_cp, MATROSKA_ID_CUECLUSTERPOSITION , 
entry[j].cluster_pos);
 put_ebml_uint(dyn_cp, MATROSKA_ID_CUERELATIVEPOSITION, 
entry[j].relative_pos);
 if (entry[j].duration != -1)
@@ -2263,7 +2261,6 @@ static int mkv_write_packet_internal(AVFormatContext *s, 
AVPacket *pkt, int add_
 int ret;
 int64_t ts = track->write_dts ? pkt->dts : pkt->pts;
 int64_t relative_packet_pos;
-int tracknum = track->track_num;
 
 if (ts == AV_NOPTS_VALUE) {
 av_log(s, AV_LOG_ERROR, "Can't write packet with unknown timestamp\n");
@@ -2298,7 +2295,8 @@ static int mkv_write_packet_internal(AVFormatContext *s, 
AVPacket *pkt, int add_
 if (par->codec_type != AVMEDIA_TYPE_SUBTITLE) {
 mkv_write_block(s, pb, MATROSKA_ID_SIMPLEBLOCK, pkt, keyframe);
 if ((s->pb->seekable & AVIO_SEEKABLE_NORMAL) && (par->codec_type == 
AVMEDIA_TYPE_VIDEO && keyframe || add_cue)) {
-ret = mkv_add_cuepoint(mkv->cues, pkt->stream_index, tracknum, ts, 
mkv->cluster_pos, relative_packet_pos, -1);
+ret = mkv_add_cuepoint(mkv->cues, pkt->stream_index, ts,
+   mkv->cluster_pos, relative_packet_pos, -1);
 if (ret < 0) return ret;
 }
 } else {
@@ -2323,7 +2321,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
 }
 
 if (s->pb->seekable & AVIO_SEEKABLE_NORMAL) {
-ret = mkv_add_cuepoint(mkv->cues, pkt->stream_index, tracknum, ts,
+ret = mkv_add_cuepoint(mkv->cues, pkt->stream_index, ts,
mkv->cluster_pos, relative_packet_pos, 
duration);
 if (ret < 0)
 return ret;
-- 
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 08/23] avformat/matroskaenc: Remove useless AVIOContext

2019-11-05 Thread Andreas Rheinhardt
Write a few numbers directly via AV_WB32 instead of using an AVIOContext
(that is initialized only for this very purpose) to write these numbers
at known offsets into a fixed buffer.

Signed-off-by: Andreas Rheinhardt 
---
 libavformat/matroskaenc.c | 23 ++-
 1 file changed, 10 insertions(+), 13 deletions(-)

diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index fb9c38bf4b..15b5ec833f 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -894,7 +894,6 @@ static int mkv_write_video_color(AVIOContext *pb, 
AVCodecParameters *par, AVStre
 static int mkv_write_video_projection(AVFormatContext *s, AVIOContext *pb,
   AVStream *st)
 {
-AVIOContext b;
 ebml_master projection;
 int side_data_size = 0;
 uint8_t private[20];
@@ -924,26 +923,24 @@ static int mkv_write_video_projection(AVFormatContext *s, 
AVIOContext *pb,
   MATROSKA_VIDEO_PROJECTION_TYPE_EQUIRECTANGULAR);
 break;
 case AV_SPHERICAL_EQUIRECTANGULAR_TILE:
-ffio_init_context(&b, private, 20, 1, NULL, NULL, NULL, NULL);
 put_ebml_uint(pb, MATROSKA_ID_VIDEOPROJECTIONTYPE,
   MATROSKA_VIDEO_PROJECTION_TYPE_EQUIRECTANGULAR);
-avio_wb32(&b, 0); // version + flags
-avio_wb32(&b, spherical->bound_top);
-avio_wb32(&b, spherical->bound_bottom);
-avio_wb32(&b, spherical->bound_left);
-avio_wb32(&b, spherical->bound_right);
+AV_WB32(private , 0); // version + flags
+AV_WB32(private +  4, spherical->bound_top);
+AV_WB32(private +  8, spherical->bound_bottom);
+AV_WB32(private + 12, spherical->bound_left);
+AV_WB32(private + 16, spherical->bound_right);
 put_ebml_binary(pb, MATROSKA_ID_VIDEOPROJECTIONPRIVATE,
-private, avio_tell(&b));
+private, 20);
 break;
 case AV_SPHERICAL_CUBEMAP:
-ffio_init_context(&b, private, 12, 1, NULL, NULL, NULL, NULL);
 put_ebml_uint(pb, MATROSKA_ID_VIDEOPROJECTIONTYPE,
   MATROSKA_VIDEO_PROJECTION_TYPE_CUBEMAP);
-avio_wb32(&b, 0); // version + flags
-avio_wb32(&b, 0); // layout
-avio_wb32(&b, spherical->padding);
+AV_WB32(private, 0); // version + flags
+AV_WB32(private + 4, 0); // layout
+AV_WB32(private + 8, spherical->padding);
 put_ebml_binary(pb, MATROSKA_ID_VIDEOPROJECTIONPRIVATE,
-private, avio_tell(&b));
+private, 12);
 break;
 }
 
-- 
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 18/23] avformat/matroskaenc: Warn that WebM doesn't support attachments

2019-11-05 Thread Andreas Rheinhardt
As WebM doesn't support attachments, the Matroska muxer drops them when
in WebM mode. This happened silently until this commit which adds a
warning for this.

Signed-off-by: Andreas Rheinhardt 
---
 libavformat/matroskaenc.c | 19 ---
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index e64e1e1036..19d9b0bc66 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -1755,12 +1755,6 @@ static int mkv_write_header(AVFormatContext *s)
 int ret, i, version = 2;
 int64_t creation_time;
 
-if (!strcmp(s->oformat->name, "webm")) {
-mkv->mode  = MODE_WEBM;
-mkv->write_crc = 0;
-} else
-mkv->mode = MODE_MATROSKAv2;
-
 if (mkv->mode != MODE_WEBM ||
 av_dict_get(s->metadata, "stereo_mode", NULL, 0) ||
 av_dict_get(s->metadata, "alpha_mode", NULL, 0))
@@ -2623,6 +2617,12 @@ static int mkv_init(struct AVFormatContext *s)
 s->internal->avoid_negative_ts_use_pts = 1;
 }
 
+if (!strcmp(s->oformat->name, "webm")) {
+mkv->mode  = MODE_WEBM;
+mkv->write_crc = 0;
+} else
+mkv->mode = MODE_MATROSKAv2;
+
 mkv->tracks = av_mallocz_array(s->nb_streams, sizeof(*mkv->tracks));
 if (!mkv->tracks) {
 return AVERROR(ENOMEM);
@@ -2644,8 +2644,13 @@ static int mkv_init(struct AVFormatContext *s)
 // ms precision is the de-facto standard timescale for mkv files
 avpriv_set_pts_info(s->streams[i], 64, 1, 1000);
 
-if (st->codecpar->codec_type == AVMEDIA_TYPE_ATTACHMENT)
+if (st->codecpar->codec_type == AVMEDIA_TYPE_ATTACHMENT) {
+if (mkv->mode == MODE_WEBM) {
+av_log(s, AV_LOG_WARNING, "Stream %d will be ignored "
+   "as WebM doesn't support attachments.\n", i);
+}
 continue;
+}
 
 nb_tracks++;
 track->track_num = mkv->is_dash ? mkv->dash_track_number : nb_tracks;
-- 
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 03/23] avformat/matroskaenc: Use random TrackUID

2019-11-05 Thread Andreas Rheinhardt
Up until now, the TrackUID of a Matroska track which is supposed to be
random was not random at all: It always coincided with the TrackNumber
which is usually the 1-based index of the corresponding stream in the
array of AVStreams. This has been changed: It is now set via an AVLFG
if AVFMT_FLAG_BITEXACT is not set. Otherwise it is set like it is set
now (the only change happens if an explicit track number has been
choosen via dash_track_number, because the system used in the normal
situation is now used, too). In particular, no FATE tests need to be
updated.

This also fixes a bug in case the dash_track_number option was used:
In this case the TrackUID was set to the track number, but the tags were
written with a TagTrackUID simply based upon the index, so that the tags
didn't apply to the track they ought to apply to.

Signed-off-by: Andreas Rheinhardt 
---
mkv_get_uid() might be overkill, but I simply wanted to be sure that
there are no collisions.

 libavformat/matroskaenc.c | 65 ++-
 1 file changed, 57 insertions(+), 8 deletions(-)

diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index de57e474be..b87d15b7ff 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -94,6 +94,7 @@ typedef struct mkv_cues {
 typedef struct mkv_track {
 int write_dts;
 int has_cue;
+uint32_tuid;
 int sample_rate;
 int64_t sample_rate_offset;
 int64_t last_timestamp;
@@ -1199,8 +1200,7 @@ static int mkv_write_track(AVFormatContext *s, 
MatroskaMuxContext *mkv,
 track = start_ebml_master(pb, MATROSKA_ID_TRACKENTRY, 0);
 put_ebml_uint (pb, MATROSKA_ID_TRACKNUMBER,
mkv->is_dash ? mkv->dash_track_number : i + 1);
-put_ebml_uint (pb, MATROSKA_ID_TRACKUID,
-   mkv->is_dash ? mkv->dash_track_number : i + 1);
+put_ebml_uint (pb, MATROSKA_ID_TRACKUID, mkv->tracks[i].uid);
 put_ebml_uint (pb, MATROSKA_ID_TRACKFLAGLACING , 0);// no lacing (yet)
 
 if ((tag = av_dict_get(st->metadata, "title", NULL, 0)))
@@ -1650,7 +1650,8 @@ static int mkv_write_tags(AVFormatContext *s)
 if (!mkv_check_tag(st->metadata, MATROSKA_ID_TAGTARGETS_TRACKUID))
 continue;
 
-ret = mkv_write_tag(s, st->metadata, MATROSKA_ID_TAGTARGETS_TRACKUID, 
i + 1);
+ret = mkv_write_tag(s, st->metadata, MATROSKA_ID_TAGTARGETS_TRACKUID,
+mkv->tracks[i].uid);
 if (ret < 0) return ret;
 }
 
@@ -1658,13 +1659,15 @@ static int mkv_write_tags(AVFormatContext *s)
 for (i = 0; i < s->nb_streams; i++) {
 AVIOContext *pb;
 AVStream *st = s->streams[i];
+mkv_track *track = &mkv->tracks[i];
 ebml_master tag_target;
 ebml_master tag;
 
 if (st->codecpar->codec_type == AVMEDIA_TYPE_ATTACHMENT)
 continue;
 
-mkv_write_tag_targets(s, MATROSKA_ID_TAGTARGETS_TRACKUID, i + 1, 
&tag_target);
+mkv_write_tag_targets(s, MATROSKA_ID_TAGTARGETS_TRACKUID,
+  track->uid, &tag_target);
 pb = mkv->tags_bc;
 
 tag = start_ebml_master(pb, MATROSKA_ID_SIMPLETAG, 0);
@@ -1863,10 +1866,6 @@ static int mkv_write_header(AVFormatContext *s)
 version = 4;
 }
 
-mkv->tracks = av_mallocz_array(s->nb_streams, sizeof(*mkv->tracks));
-if (!mkv->tracks) {
-return AVERROR(ENOMEM);
-}
 ebml_header = start_ebml_master(pb, EBML_ID_HEADER, MAX_EBML_HEADER_SIZE);
 put_ebml_uint  (pb, EBML_ID_EBMLVERSION   ,   1);
 put_ebml_uint  (pb, EBML_ID_EBMLREADVERSION   ,   1);
@@ -2667,8 +2666,42 @@ static int webm_query_codec(enum AVCodecID codec_id, int 
std_compliance)
 return 0;
 }
 
+static uint32_t mkv_get_uid(const mkv_track *tracks, int i, AVLFG *c)
+{
+uint32_t uid;
+
+for (int j = 0, k; j < 5; j++) {
+uid = av_lfg_get(c);
+if (!uid)
+continue;
+for (k = 0; k < i; k++) {
+if (tracks[k].uid == uid) {
+/* Was something wrong with our random seed? */
+av_lfg_init(c, av_get_random_seed());
+break;
+}
+}
+if (k == i)
+return uid;
+}
+
+/* Test the numbers from 1 to i. */
+for (int j = 1, k; j < i + 1; j++) {
+for (k = 0; k < i; k++) {
+if (tracks[k].uid == j)
+break;
+}
+if (k == i)
+return j;
+}
+/* Return i + 1. It can't coincide with another uid. */
+return i + 1;
+}
+
 static int mkv_init(struct AVFormatContext *s)
 {
+MatroskaMuxContext *mkv = s->priv_data;
+AVLFG c;
 int i;
 
 if (s->nb_streams > MAX_TRACKS) {
@@ -2697,7 +2730,23 @@ static int mkv_init(struct AVFormatContext *s)
 s->internal->avoid_negative_ts_use_pts = 1;
 }
 
+

[FFmpeg-devel] [PATCH 04/23] avformat/matroskaenc: Remove allocations for attachments

2019-11-05 Thread Andreas Rheinhardt
If there are attachments to write, the Matroska muxer currently
allocates two objects: An array that contains an entry for each
attachment containing just the stream index of the corresponding
stream and the uid used for this attachment; and a structure with
a pointer to said array and a counter for said array. These uids are
generated via code special to attachments: It uses an AVLFG in the
normal and a sha of the attachment data in the bitexact case. (Said sha
requires an allocation, too.)

But now that an uid is generated for each stream in mkv_init(), there is
no need any more to use special code for generating the uids of
attachments: One can simply use the uid already generated for the
attachment stream. And this makes the whole allocations of the structures
for attachments as well as the structures itself superfluous. They have
been removed.

In case AVFMT_FLAG_BITEXACT is set, the uids will be different from the
old ones which is the reason why the FATE-test lavf-mkv_attachment
needed to be updated. The old method had the drawback that muxing the
same attachment twice in the same file would create a file where two
attachments have the same uid. The new one doesn't.

Also notice that the dynamic buffer used to write the attachments leaks
if an error happens when writing the buffer. By removing the
allocations potential sources of errors have been removed.

Signed-off-by: Andreas Rheinhardt 
---
 libavformat/matroskaenc.c | 63 +--
 tests/ref/lavf/mkv_attachment |  4 +--
 2 files changed, 11 insertions(+), 56 deletions(-)

diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index b87d15b7ff..179349690d 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -50,7 +50,6 @@
 #include "libavutil/random_seed.h"
 #include "libavutil/rational.h"
 #include "libavutil/samplefmt.h"
-#include "libavutil/sha.h"
 #include "libavutil/stereo3d.h"
 
 #include "libavcodec/xiph.h"
@@ -104,16 +103,6 @@ typedef struct mkv_track {
 int64_t ts_offset;
 } mkv_track;
 
-typedef struct mkv_attachment {
-int stream_idx;
-uint32_tfileuid;
-} mkv_attachment;
-
-typedef struct mkv_attachments {
-mkv_attachment  *entries;
-int num_entries;
-} mkv_attachments;
-
 #define MODE_MATROSKAv2 0x01
 #define MODE_WEBM   0x02
 
@@ -140,7 +129,6 @@ typedef struct MatroskaMuxContext {
 mkv_seekhead*seekhead;
 mkv_cues*cues;
 mkv_track   *tracks;
-mkv_attachments *attachments;
 
 AVPacketcur_audio_pkt;
 
@@ -406,10 +394,6 @@ static void mkv_deinit(AVFormatContext *s)
 av_freep(&mkv->cues->entries);
 av_freep(&mkv->cues);
 }
-if (mkv->attachments) {
-av_freep(&mkv->attachments->entries);
-av_freep(&mkv->attachments);
-}
 av_freep(&mkv->tracks);
 }
 
@@ -1696,14 +1680,17 @@ static int mkv_write_tags(AVFormatContext *s)
 }
 
 if (mkv->have_attachments && mkv->mode != MODE_WEBM) {
-for (i = 0; i < mkv->attachments->num_entries; i++) {
-mkv_attachment *attachment = &mkv->attachments->entries[i];
-AVStream *st = s->streams[attachment->stream_idx];
+for (i = 0; i < s->nb_streams; i++) {
+mkv_track *track = &mkv->tracks[i];
+AVStream *st = s->streams[i];
+
+if (st->codecpar->codec_type != AVMEDIA_TYPE_ATTACHMENT)
+continue;
 
 if (!mkv_check_tag(st->metadata, MATROSKA_ID_TAGTARGETS_ATTACHUID))
 continue;
 
-ret = mkv_write_tag(s, st->metadata, 
MATROSKA_ID_TAGTARGETS_ATTACHUID, attachment->fileuid);
+ret = mkv_write_tag(s, st->metadata, 
MATROSKA_ID_TAGTARGETS_ATTACHUID, track->uid);
 if (ret < 0)
 return ret;
 }
@@ -1722,18 +1709,11 @@ static int mkv_write_attachments(AVFormatContext *s)
 {
 MatroskaMuxContext *mkv = s->priv_data;
 AVIOContext *dyn_cp, *pb = s->pb;
-AVLFG c;
 int i, ret;
 
 if (!mkv->have_attachments)
 return 0;
 
-mkv->attachments = av_mallocz(sizeof(*mkv->attachments));
-if (!mkv->attachments)
-return AVERROR(ENOMEM);
-
-av_lfg_init(&c, av_get_random_seed());
-
 ret = mkv_add_seekhead_entry(mkv->seekhead, MATROSKA_ID_ATTACHMENTS, 
avio_tell(pb));
 if (ret < 0) return ret;
 
@@ -1742,20 +1722,14 @@ static int mkv_write_attachments(AVFormatContext *s)
 
 for (i = 0; i < s->nb_streams; i++) {
 AVStream *st = s->streams[i];
+mkv_track *track = &mkv->tracks[i];
 ebml_master attached_file;
-mkv_attachment *attachment = mkv->attachments->entries;
 AVDictionaryEntry *t;
 const char *mimetype = NULL;
-uint32_t fileuid;
 
 if (st->codecpar->codec_type != AVMEDIA_TYPE_ATTACHMENT)
 continue;
 
-attachment = av_realloc_array(attachment, 
mkv->attachments->num_entries + 1, sizeof(mkv_attachment));

[FFmpeg-devel] [PATCH 01/23] avformat/matroskaenc: Fix ReferenceBlock timestamp

2019-11-05 Thread Andreas Rheinhardt
In order to indicate that the frames in a BlockGroup are not keyframes,
one has to add a ReferenceBlock element containing the timestamp of a
reference block that has already been written. The timestamp ought to be
relative to the timestamp of the block it is attached to. Yet the
Matroska muxer used the relative timestamp of the preceding block of the
track, i.e. the timestamp of the preceding block relative to the
timestamp of the cluster containing said block (that need not be the
cluster containing the current block). This has been fixed.

Signed-off-by: Andreas Rheinhardt 
---
Unchanged since last time.

 libavformat/matroskaenc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index ba48aae454..90400de191 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -2165,9 +2165,9 @@ static void mkv_write_block(AVFormatContext *s, 
AVIOContext *pb,
 av_free(data);
 
 if (blockid == MATROSKA_ID_BLOCK && !keyframe) {
-put_ebml_sint(pb, MATROSKA_ID_BLOCKREFERENCE, track->last_timestamp);
+put_ebml_sint(pb, MATROSKA_ID_BLOCKREFERENCE, track->last_timestamp - 
ts);
 }
-track->last_timestamp = ts - mkv->cluster_pts;
+track->last_timestamp = ts;
 
 if (discard_padding) {
 put_ebml_sint(pb, MATROSKA_ID_DISCARDPADDING, discard_padding);
-- 
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 16/23] avformat/matroskadec: Don't forward empty attachment filename

2019-11-05 Thread Andreas Rheinhardt
While the Matroska specification allows the filename string to be empty,
forwarding an empty string as tag is useless.

Signed-off-by: Andreas Rheinhardt 
---
 libavformat/matroskadec.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index c224c3447a..0d15c634ee 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -2881,7 +2881,10 @@ static int matroska_read_header(AVFormatContext *s)
 AVStream *st = avformat_new_stream(s, NULL);
 if (!st)
 break;
-av_dict_set(&st->metadata, "filename", attachments[j].filename, 0);
+
+// Empty filenames are legal and accepted, but useless.
+if (attachments[j].filename[0])
+av_dict_set(&st->metadata, "filename", 
attachments[j].filename, 0);
 av_dict_set(&st->metadata, "mimetype", attachments[j].mime, 0);
 st->codecpar->codec_id   = AV_CODEC_ID_NONE;
 
-- 
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 19/23] avformat/matroskaenc: Improve mimetype search

2019-11-05 Thread Andreas Rheinhardt
Use the mime_types of the corresponding AVCodecDescriptor instead of own
arrays. The former are more encompassing.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/codec_desc.c   |  1 +
 libavformat/matroskaenc.c | 14 +++---
 2 files changed, 4 insertions(+), 11 deletions(-)

diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
index 0602ecb1b5..837b09e7f4 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -3020,6 +3020,7 @@ static const AVCodecDescriptor codec_descriptors[] = {
 .name  = "text",
 .long_name = NULL_IF_CONFIG_SMALL("raw UTF-8 text"),
 .props = AV_CODEC_PROP_TEXT_SUB,
+.mime_types= MT("text/plain"),
 },
 {
 .id= AV_CODEC_ID_XSUB,
diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index 19d9b0bc66..f2c8a66a03 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -1694,17 +1694,9 @@ static int mkv_write_attachments(AVFormatContext *s)
 if (t = av_dict_get(st->metadata, "mimetype", NULL, 0))
 mimetype = t->value;
 else if (st->codecpar->codec_id != AV_CODEC_ID_NONE ) {
-int i;
-for (i = 0; ff_mkv_mime_tags[i].id != AV_CODEC_ID_NONE; i++)
-if (ff_mkv_mime_tags[i].id == st->codecpar->codec_id) {
-mimetype = ff_mkv_mime_tags[i].str;
-break;
-}
-for (i = 0; ff_mkv_image_mime_tags[i].id != AV_CODEC_ID_NONE; i++)
-if (ff_mkv_image_mime_tags[i].id == st->codecpar->codec_id) {
-mimetype = ff_mkv_image_mime_tags[i].str;
-break;
-}
+const AVCodecDescriptor *desc = 
avcodec_descriptor_get(st->codecpar->codec_id);
+if (desc && desc->mime_types)
+mimetype = desc->mime_types[0];
 }
 if (!mimetype) {
 av_log(s, AV_LOG_ERROR, "Attachment stream %d has no mimetype tag 
and "
-- 
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 22/23] avformat/matroskaenc: Don't waste bytes on length fields

2019-11-05 Thread Andreas Rheinhardt
Several EBML master elements for which a good upper bound of the final
length was available were nevertheless written as unknown-length
EBML-elements, so that their length field was eight bytes long. This has
been changed.

Signed-off-by: Andreas Rheinhardt 
---
 libavformat/matroskaenc.c|  8 ++---
 tests/fate/wavpack.mak   |  4 +--
 tests/ref/fate/aac-autobsf-adtstoasc |  4 +--
 tests/ref/fate/rgb24-mkv |  4 +--
 tests/ref/lavf/mka   |  4 +--
 tests/ref/lavf/mkv   |  4 +--
 tests/ref/lavf/mkv_attachment|  4 +--
 tests/ref/seek/lavf-mkv  | 44 ++--
 8 files changed, 38 insertions(+), 38 deletions(-)

diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index df13d05dab..776911e517 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -850,7 +850,7 @@ static int mkv_write_video_color(AVIOContext *pb, 
AVCodecParameters *par, AVStre
 &side_data_size);
 if (side_data_size == sizeof(AVMasteringDisplayMetadata)) {
 ebml_master meta_element = start_ebml_master(
-dyn_cp, MATROSKA_ID_VIDEOCOLORMASTERINGMETA, 0);
+dyn_cp, MATROSKA_ID_VIDEOCOLORMASTERINGMETA, 10 * (2 + 1 + 8));
 const AVMasteringDisplayMetadata *metadata =
 (const AVMasteringDisplayMetadata*)side_data;
 if (metadata->has_primaries) {
@@ -1327,7 +1327,7 @@ static int mkv_write_track(AVFormatContext *s, 
MatroskaMuxContext *mkv,
 // no mkv-specific ID, use ACM mode
 put_ebml_string(pb, MATROSKA_ID_CODECID, "A_MS/ACM");
 
-subinfo = start_ebml_master(pb, MATROSKA_ID_TRACKAUDIO, 0);
+subinfo = start_ebml_master(pb, MATROSKA_ID_TRACKAUDIO, 6 + 4 * 9);
 put_ebml_uint  (pb, MATROSKA_ID_AUDIOCHANNELS, par->channels);
 
 mkv->tracks[i].sample_rate_offset = avio_tell(pb);
@@ -1509,7 +1509,7 @@ static int mkv_write_tag_targets(AVFormatContext *s, 
uint32_t elementid,
 pb = mkv->tags_bc;
 
 *tag= start_ebml_master(pb, MATROSKA_ID_TAG,0);
-targets = start_ebml_master(pb, MATROSKA_ID_TAGTARGETS, 0);
+targets = start_ebml_master(pb, MATROSKA_ID_TAGTARGETS, 4 + 1 + 8);
 if (elementid)
 put_ebml_uint(pb, elementid, uid);
 end_ebml_master(pb, targets);
@@ -1608,7 +1608,7 @@ static int mkv_write_tags(AVFormatContext *s)
 return ret;
 pb = mkv->tags_bc;
 
-tag = start_ebml_master(pb, MATROSKA_ID_SIMPLETAG, 0);
+tag = start_ebml_master(pb, MATROSKA_ID_SIMPLETAG, 2 + 1 + 8 + 23);
 put_ebml_string(pb, MATROSKA_ID_TAGNAME, "DURATION");
 mkv->tracks[i].duration_offset = avio_tell(pb);
 
diff --git a/tests/fate/wavpack.mak b/tests/fate/wavpack.mak
index 387cfda380..67b036d2fd 100644
--- a/tests/fate/wavpack.mak
+++ b/tests/fate/wavpack.mak
@@ -91,12 +91,12 @@ fate-wavpack-matroskamode: CMD = md5 -i 
$(TARGET_SAMPLES)/wavpack/special/matros
 FATE_WAVPACK-$(call DEMMUX, WV, MATROSKA) += fate-wavpack-matroska_mux-mono
 fate-wavpack-matroska_mux-mono: CMD = md5pipe -i 
$(TARGET_SAMPLES)/wavpack/num_channels/mono_16bit_int.wv -c copy -fflags 
+bitexact -f matroska
 fate-wavpack-matroska_mux-mono: CMP = oneline
-fate-wavpack-matroska_mux-mono: REF = 931afa765eec5c49372b9fdae0feaf23
+fate-wavpack-matroska_mux-mono: REF = 0928fed1c1c56bab7307ec4a9940a7aa
 
 FATE_WAVPACK-$(call DEMMUX, WV, MATROSKA) += fate-wavpack-matroska_mux-61
 fate-wavpack-matroska_mux-61: CMD = md5pipe -i 
$(TARGET_SAMPLES)/wavpack/num_channels/eva_2.22_6.1_16bit-partial.wv -c copy 
-fflags +bitexact -f matroska
 fate-wavpack-matroska_mux-61: CMP = oneline
-fate-wavpack-matroska_mux-61: REF = cc11fe2ff9b1887b8a51330d28adbb8e
+fate-wavpack-matroska_mux-61: REF = 88d55eb0cdcbba5dd187808fba4e4cd2
 
 FATE_SAMPLES_AVCONV += $(FATE_WAVPACK-yes)
 fate-wavpack: $(FATE_WAVPACK-yes)
diff --git a/tests/ref/fate/aac-autobsf-adtstoasc 
b/tests/ref/fate/aac-autobsf-adtstoasc
index adc47bfeb6..7615edd079 100644
--- a/tests/ref/fate/aac-autobsf-adtstoasc
+++ b/tests/ref/fate/aac-autobsf-adtstoasc
@@ -1,5 +1,5 @@
-8a02d889ba2d238cdd7fe1092c6b82ba 
*tests/data/fate/aac-autobsf-adtstoasc.matroska
-6639 tests/data/fate/aac-autobsf-adtstoasc.matroska
+ea4b7a9ebf1e3b8a47c08b1f6b8af5a9 
*tests/data/fate/aac-autobsf-adtstoasc.matroska
+6618 tests/data/fate/aac-autobsf-adtstoasc.matroska
 #extradata 0:2, 0x0030001c
 #tb 0: 1/1000
 #media_type 0: audio
diff --git a/tests/ref/fate/rgb24-mkv b/tests/ref/fate/rgb24-mkv
index 37cd21c48a..86b45a2032 100644
--- a/tests/ref/fate/rgb24-mkv
+++ b/tests/ref/fate/rgb24-mkv
@@ -1,5 +1,5 @@
-0e20df482bba3820a4179ea7273a65a1 *tests/data/fate/rgb24-mkv.matroska
-58221 tests/data/fate/rgb24-mkv.matroska
+9d4c8540bf4d06ebff9a24b31f0f3b85 *tests/data/fate/rgb24-mkv.matroska
+58200 tests/data/fate/rgb24-mkv.matroska
 #tb 0: 1/10
 #media_type 0: video
 #codec_id 0: rawvideo
dif

[FFmpeg-devel] [PATCH 23/23] avformat/matroskaenc: Cosmetics

2019-11-05 Thread Andreas Rheinhardt
Mainly reindentation.

Signed-off-by: Andreas Rheinhardt 
---
 libavformat/matroskaenc.c | 88 +++
 1 file changed, 44 insertions(+), 44 deletions(-)

diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index 776911e517..5e3f9144a0 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -403,9 +403,9 @@ static void mkv_deinit(AVFormatContext *s)
 static void mkv_start_seekhead(MatroskaMuxContext *mkv, AVIOContext *pb)
 {
 mkv->seekhead.filepos = avio_tell(pb);
-// 21 bytes max for a seek entry, 10 bytes max for the SeekHead ID
-// and size, 6 bytes for a CRC32 element, and 3 bytes to guarantee
-// that an EBML void element will fit afterwards
+// 21 bytes max for a seek entry, 10 bytes max for the SeekHead ID
+// and size, 6 bytes for a CRC32 element, and 3 bytes to guarantee
+// that an EBML void element will fit afterwards
 mkv->seekhead.reserved_size = MAX_SEEKHEAD_ENTRIES * MAX_SEEKENTRY_SIZE + 
19;
 put_ebml_void(pb, mkv->seekhead.reserved_size);
 }
@@ -436,10 +436,10 @@ static int64_t mkv_write_seekhead(AVIOContext *pb, 
MatroskaMuxContext *mkv)
 
 currentpos = avio_tell(pb);
 
-if (avio_seek(pb, seekhead->filepos, SEEK_SET) < 0) {
-currentpos = -1;
-goto fail;
-}
+if (avio_seek(pb, seekhead->filepos, SEEK_SET) < 0) {
+currentpos = -1;
+goto fail;
+}
 
 if (start_ebml_master_crc32(pb, &dyn_cp, mkv, MATROSKA_ID_SEEKHEAD) < 0) {
 currentpos = -1;
@@ -461,10 +461,10 @@ static int64_t mkv_write_seekhead(AVIOContext *pb, 
MatroskaMuxContext *mkv)
 end_ebml_master_crc32(pb, &dyn_cp, mkv);
 
 remaining = seekhead->filepos + seekhead->reserved_size - avio_tell(pb);
-put_ebml_void(pb, remaining);
-avio_seek(pb, currentpos, SEEK_SET);
+put_ebml_void(pb, remaining);
+avio_seek(pb, currentpos, SEEK_SET);
 
-currentpos = seekhead->filepos;
+currentpos = seekhead->filepos;
 
 fail:
 return currentpos;
@@ -1610,7 +1610,7 @@ static int mkv_write_tags(AVFormatContext *s)
 
 tag = start_ebml_master(pb, MATROSKA_ID_SIMPLETAG, 2 + 1 + 8 + 23);
 put_ebml_string(pb, MATROSKA_ID_TAGNAME, "DURATION");
-mkv->tracks[i].duration_offset = avio_tell(pb);
+track->duration_offset = avio_tell(pb);
 
 // Reserve space to write duration as a 20-byte string.
 // 2 (ebml id) + 1 (data size) + 20 (data)
@@ -2349,36 +2349,36 @@ static int mkv_write_packet(AVFormatContext *s, 
AVPacket *pkt)
 return ret;
 
 if (mkv->cluster_pos != -1) {
-if (mkv->tracks[pkt->stream_index].write_dts)
-cluster_time = pkt->dts - mkv->cluster_pts;
-else
-cluster_time = pkt->pts - mkv->cluster_pts;
-cluster_time += mkv->tracks[pkt->stream_index].ts_offset;
-
-cluster_size = avio_tell(mkv->cluster_bc);
-
-if (mkv->is_dash && codec_type == AVMEDIA_TYPE_VIDEO) {
-// WebM DASH specification states that the first block of every cluster
-// has to be a key frame. So for DASH video, we only create a cluster
-// on seeing key frames.
-start_new_cluster = keyframe;
-} else if (mkv->is_dash && codec_type == AVMEDIA_TYPE_AUDIO &&
-   cluster_time > mkv->cluster_time_limit) {
-// For DASH audio, we create a Cluster based on cluster_time_limit
-start_new_cluster = 1;
-} else if (!mkv->is_dash &&
-   (cluster_size > mkv->cluster_size_limit ||
-cluster_time > mkv->cluster_time_limit ||
-(codec_type == AVMEDIA_TYPE_VIDEO && keyframe &&
- cluster_size > 4 * 1024))) {
-start_new_cluster = 1;
-} else {
-start_new_cluster = 0;
-}
+if (mkv->tracks[pkt->stream_index].write_dts)
+cluster_time = pkt->dts - mkv->cluster_pts;
+else
+cluster_time = pkt->pts - mkv->cluster_pts;
+cluster_time += mkv->tracks[pkt->stream_index].ts_offset;
+
+cluster_size  = avio_tell(mkv->cluster_bc);
+
+if (mkv->is_dash && codec_type == AVMEDIA_TYPE_VIDEO) {
+// WebM DASH specification states that the first block of
+// every cluster has to be a key frame. So for DASH video,
+// we only create a cluster on seeing key frames.
+start_new_cluster = keyframe;
+} else if (mkv->is_dash && codec_type == AVMEDIA_TYPE_AUDIO &&
+   cluster_time > mkv->cluster_time_limit) {
+// For DASH audio, we create a Cluster based on cluster_time_limit.
+start_new_cluster = 1;
+} else if (!mkv->is_dash &&
+   (cluster_size > mkv->cluster_size_limit ||
+cluster_time > mkv->cluster_time_limit ||
+(codec_type == AVMEDIA_TYPE_VIDEO && keyframe &&
+ cluster_size > 4 * 1024))) {
+ 

[FFmpeg-devel] [PATCH 09/23] avformat/matroskaenc: Ignore attachments for track limit

2019-11-05 Thread Andreas Rheinhardt
Attachments are streams in FFmpeg, but they are not tracks in Matroska.
Yet they were counted when checking a limit for the number of tracks that
the Matroska muxer imposes. This is unnecessary and has been changed.

(The Matroska file format actually has practically no limit on the
number of tracks and this is purely what our muxer supports. But even if
this limit were removed/relaxed in the future, it still makes sense to
use small track numbers as this patch does, because greater numbers need
more bytes to encode.)

Signed-off-by: Andreas Rheinhardt 
---
 libavformat/matroskaenc.c | 34 +-
 1 file changed, 21 insertions(+), 13 deletions(-)

diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index 15b5ec833f..0c3796f924 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -95,6 +95,7 @@ typedef struct mkv_cues {
 typedef struct mkv_track {
 int write_dts;
 int has_cue;
+int track_num;
 uint32_tuid;
 int sample_rate;
 int64_t sample_rate_offset;
@@ -1136,8 +1137,7 @@ static int mkv_write_track(AVFormatContext *s, 
MatroskaMuxContext *mkv,
 }
 
 track = start_ebml_master(pb, MATROSKA_ID_TRACKENTRY, 0);
-put_ebml_uint (pb, MATROSKA_ID_TRACKNUMBER,
-   mkv->is_dash ? mkv->dash_track_number : i + 1);
+put_ebml_uint (pb, MATROSKA_ID_TRACKNUMBER, mkv->tracks[i].track_num);
 put_ebml_uint (pb, MATROSKA_ID_TRACKUID, mkv->tracks[i].uid);
 put_ebml_uint (pb, MATROSKA_ID_TRACKFLAGLACING , 0);// no lacing (yet)
 
@@ -1995,7 +1995,7 @@ static void mkv_write_block(AVFormatContext *s, 
AVIOContext *pb,
 int64_t ts = track->write_dts ? pkt->dts : pkt->pts;
 uint64_t additional_id = 0;
 int64_t discard_padding = 0;
-uint8_t track_number = (mkv->is_dash ? mkv->dash_track_number : 
(pkt->stream_index + 1));
+int track_number = track->track_num;
 ebml_master block_group, block_additions, block_more;
 
 ts += track->ts_offset;
@@ -2094,6 +2094,7 @@ static void mkv_write_block(AVFormatContext *s, 
AVIOContext *pb,
 static int mkv_write_vtt_blocks(AVFormatContext *s, AVIOContext *pb, AVPacket 
*pkt)
 {
 MatroskaMuxContext *mkv = s->priv_data;
+mkv_track *track = &mkv->tracks[pkt->stream_index];
 ebml_master blockgroup;
 int id_size, settings_size, size;
 uint8_t *id, *settings;
@@ -2123,7 +2124,7 @@ static int mkv_write_vtt_blocks(AVFormatContext *s, 
AVIOContext *pb, AVPacket *p
 
 put_ebml_id(pb, MATROSKA_ID_BLOCK);
 put_ebml_num(pb, size + 4, 0);
-avio_w8(pb, 0x80 | (pkt->stream_index + 1)); // this assumes 
stream_index is less than 126
+avio_w8(pb, 0x80 | track->track_num); // this assumes track_num is 
less than 126
 avio_wb16(pb, ts - mkv->cluster_pts);
 avio_w8(pb, flags);
 avio_printf(pb, "%.*s\n%.*s\n%.*s", id_size, id, settings_size, settings, 
pkt->size, pkt->data);
@@ -2262,7 +2263,7 @@ static int mkv_write_packet_internal(AVFormatContext *s, 
AVPacket *pkt, int add_
 int ret;
 int64_t ts = track->write_dts ? pkt->dts : pkt->pts;
 int64_t relative_packet_pos;
-int tracknum = mkv->is_dash ? mkv->dash_track_number : pkt->stream_index + 
1;
+int tracknum = track->track_num;
 
 if (ts == AV_NOPTS_VALUE) {
 av_log(s, AV_LOG_ERROR, "Can't write packet with unknown timestamp\n");
@@ -2601,14 +2602,7 @@ static int mkv_init(struct AVFormatContext *s)
 {
 MatroskaMuxContext *mkv = s->priv_data;
 AVLFG c;
-int i;
-
-if (s->nb_streams > MAX_TRACKS) {
-av_log(s, AV_LOG_ERROR,
-   "At most %d streams are supported for muxing in Matroska\n",
-   MAX_TRACKS);
-return AVERROR(EINVAL);
-}
+int i, nb_tracks = 0;
 
 for (i = 0; i < s->nb_streams; i++) {
 if (s->streams[i]->codecpar->codec_id == AV_CODEC_ID_ATRAC3 ||
@@ -2638,6 +2632,7 @@ static int mkv_init(struct AVFormatContext *s)
 av_lfg_init(&c, av_get_random_seed());
 
 for (i = 0; i < s->nb_streams; i++) {
+AVStream *st = s->streams[i];
 mkv_track *track = &mkv->tracks[i];
 
 if (s->flags & AVFMT_FLAG_BITEXACT) {
@@ -2648,6 +2643,19 @@ static int mkv_init(struct AVFormatContext *s)
 
 // ms precision is the de-facto standard timescale for mkv files
 avpriv_set_pts_info(s->streams[i], 64, 1, 1000);
+
+if (st->codecpar->codec_type == AVMEDIA_TYPE_ATTACHMENT)
+continue;
+
+nb_tracks++;
+track->track_num = mkv->is_dash ? mkv->dash_track_number : nb_tracks;
+}
+
+if (nb_tracks > MAX_TRACKS) {
+av_log(s, AV_LOG_ERROR,
+   "%d > "AV_STRINGIFY(MAX_TRACKS)" tracks (excluding attachments)"
+   " not supported for muxing in Matroska\n", nb_tracks);
+return AVERROR(EINVAL);
 }
 
 return 0;
-- 
2.20.1

___
ffmpeg-deve

[FFmpeg-devel] [PATCH 15/23] avformat/matroskaenc: Don't use size of inexistent cluster

2019-11-05 Thread Andreas Rheinhardt
In order to determine whether the current cluster needs to be closed
because of the limits on cluster-size and cluster-time,
mkv_write_packet() would first get the size of the current cluster via
applying avio_tell() on the dynamic buffer holding the current cluster.
It did this without checking whether there is an open cluster right now,
so that avio_tell() returned AVERROR(EINVAL) which worked as expected
because the return value was put into a signed type (the call was
unchecked).

This is not good as it relied on avio_tell() (or actually, avio_seek())
to handle the case of an inexistent AVIOContext gracefully.

Fixing this is easy: Only check if a cluster needs to be closed if a
cluster is in fact open.

Essentially the same happened with the tags in mkv_write_trailer(). It
has been fixed, too.

Signed-off-by: Andreas Rheinhardt 
---
I wonder whether we should rather check mkv->cluster_bc instead of
mkv->cluster_pos != -1. I would have made a commit to do so if I
understood this avio_write_marker stuff that seems be broken better (the
check below should probably be mkv->cluster_pos != -1 instead of != 0).

If opening a cluster fails, mkv->cluster_pos is still set; such problems
would be automatically fixed by such a switch. 

 libavformat/matroskaenc.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index 39ad5d1ccf..f84e50f94e 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -2354,6 +2354,7 @@ static int mkv_write_packet(AVFormatContext *s, AVPacket 
*pkt)
 if (ret < 0)
 return ret;
 
+if (mkv->cluster_pos != -1) {
 if (mkv->tracks[pkt->stream_index].write_dts)
 cluster_time = pkt->dts - mkv->cluster_pts;
 else
@@ -2381,9 +2382,10 @@ static int mkv_write_packet(AVFormatContext *s, AVPacket 
*pkt)
 start_new_cluster = 0;
 }
 
-if (mkv->cluster_pos != -1 && start_new_cluster) {
+if (start_new_cluster) {
 mkv_end_cluster(s);
 }
+}
 
 if (!mkv->cluster_pos)
 avio_write_marker(s->pb,
@@ -2498,7 +2500,7 @@ static int mkv_write_trailer(AVFormatContext *s)
 end_ebml_master_crc32(pb, &mkv->tracks_bc, mkv);
 
 // update stream durations
-if (!mkv->is_live) {
+if (mkv->tags_bc) {
 int i;
 int64_t curr = avio_tell(mkv->tags_bc);
 for (i = 0; i < s->nb_streams; ++i) {
@@ -2522,8 +2524,6 @@ static int mkv_write_trailer(AVFormatContext *s)
 }
 }
 avio_seek(mkv->tags_bc, curr, SEEK_SET);
-}
-if (mkv->tags_bc && !mkv->is_live) {
 avio_seek(pb, mkv->tags_pos, SEEK_SET);
 end_ebml_master_crc32(pb, &mkv->tags_bc, mkv);
 }
-- 
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 20/23] avformat/matroskaenc: Check mimetypes earlier

2019-11-05 Thread Andreas Rheinhardt
This avoids errors lateron after the file header has already been
partially written.

Signed-off-by: Andreas Rheinhardt 
---
 libavformat/matroskaenc.c | 35 ++-
 1 file changed, 22 insertions(+), 13 deletions(-)

diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index f2c8a66a03..1effe209b4 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -1657,6 +1657,21 @@ static int mkv_write_tags(AVFormatContext *s)
 return 0;
 }
 
+static const char *get_mimetype(AVStream *st)
+{
+AVDictionaryEntry *t;
+
+if (t = av_dict_get(st->metadata, "mimetype", NULL, 0))
+return t->value;
+if (st->codecpar->codec_id != AV_CODEC_ID_NONE) {
+const AVCodecDescriptor *desc = 
avcodec_descriptor_get(st->codecpar->codec_id);
+if (desc && desc->mime_types)
+return desc->mime_types[0];
+}
+
+return NULL;
+}
+
 static int mkv_write_attachments(AVFormatContext *s)
 {
 MatroskaMuxContext *mkv = s->priv_data;
@@ -1676,7 +1691,7 @@ static int mkv_write_attachments(AVFormatContext *s)
 mkv_track *track = &mkv->tracks[i];
 ebml_master attached_file;
 AVDictionaryEntry *t;
-const char *mimetype = NULL;
+const char *mimetype;
 const char *filename;
 
 if (st->codecpar->codec_type != AVMEDIA_TYPE_ATTACHMENT)
@@ -1691,18 +1706,8 @@ static int mkv_write_attachments(AVFormatContext *s)
 } else
 filename = "";
 put_ebml_string(dyn_cp, MATROSKA_ID_FILENAME, filename);
-if (t = av_dict_get(st->metadata, "mimetype", NULL, 0))
-mimetype = t->value;
-else if (st->codecpar->codec_id != AV_CODEC_ID_NONE ) {
-const AVCodecDescriptor *desc = 
avcodec_descriptor_get(st->codecpar->codec_id);
-if (desc && desc->mime_types)
-mimetype = desc->mime_types[0];
-}
-if (!mimetype) {
-av_log(s, AV_LOG_ERROR, "Attachment stream %d has no mimetype tag 
and "
-"it cannot be deduced from the codec 
id.\n", i);
-return AVERROR(EINVAL);
-}
+mimetype = get_mimetype(st);
+av_assert0(mimetype);
 
 put_ebml_string(dyn_cp, MATROSKA_ID_FILEMIMETYPE, mimetype);
 put_ebml_binary(dyn_cp, MATROSKA_ID_FILEDATA, st->codecpar->extradata, 
st->codecpar->extradata_size);
@@ -2640,6 +2645,10 @@ static int mkv_init(struct AVFormatContext *s)
 if (mkv->mode == MODE_WEBM) {
 av_log(s, AV_LOG_WARNING, "Stream %d will be ignored "
"as WebM doesn't support attachments.\n", i);
+} else if (!get_mimetype(st)) {
+av_log(s, AV_LOG_ERROR, "Attachment stream %d has no mimetype tag 
and "
+"it cannot be deduced from the codec 
id.\n", i);
+return AVERROR(EINVAL);
 }
 continue;
 }
-- 
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 17/23] avformat/matroskaenc: Allow empty filename for attachments

2019-11-05 Thread Andreas Rheinhardt
The EBML as well as the Matroska specifications allow empty strings, yet
the Matroska muxer enforced the requirement that a filename tag exists
for attachments and errored out if it didn't. This has been changed: In
the absence of a filename, an empty string is used.

Signed-off-by: Andreas Rheinhardt 
---
 libavformat/matroskaenc.c | 11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index f84e50f94e..e64e1e1036 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -1677,6 +1677,7 @@ static int mkv_write_attachments(AVFormatContext *s)
 ebml_master attached_file;
 AVDictionaryEntry *t;
 const char *mimetype = NULL;
+const char *filename;
 
 if (st->codecpar->codec_type != AVMEDIA_TYPE_ATTACHMENT)
 continue;
@@ -1685,11 +1686,11 @@ static int mkv_write_attachments(AVFormatContext *s)
 
 if (t = av_dict_get(st->metadata, "title", NULL, 0))
 put_ebml_string(dyn_cp, MATROSKA_ID_FILEDESC, t->value);
-if (!(t = av_dict_get(st->metadata, "filename", NULL, 0))) {
-av_log(s, AV_LOG_ERROR, "Attachment stream %d has no filename 
tag.\n", i);
-return AVERROR(EINVAL);
-}
-put_ebml_string(dyn_cp, MATROSKA_ID_FILENAME, t->value);
+if (t = av_dict_get(st->metadata, "filename", NULL, 0)) {
+filename = t->value;
+} else
+filename = "";
+put_ebml_string(dyn_cp, MATROSKA_ID_FILENAME, filename);
 if (t = av_dict_get(st->metadata, "mimetype", NULL, 0))
 mimetype = t->value;
 else if (st->codecpar->codec_id != AV_CODEC_ID_NONE ) {
-- 
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 06/23] avformat/matroskaenc: Avoid allocations for seekheads

2019-11-05 Thread Andreas Rheinhardt
Up until e7ddafd5, the Matroska muxer wrote two seekheads: One at the
beginning referencing the main level 1 elements (i.e. not the clusters)
and one at the end, referencing the clusters. This second seekhead was
useless and has therefore been removed. Yet the seekhead-related
functions and structures are still geared towards this usecase: They
are built around an allocated array of variable size that gets
reallocated every time an element is added to it although the maximum
number of seekheads is a small compile-time constant, so that one should
rather include the array in the seekhead structure itself; and said
structure should be contained in the MatroskaMuxContext instead of being
allocated separately.

The earlier code reserved space for a SeekHead with 10 entries, although
we currently write at most 6. Reducing said number implied that every
Matroska/Webm file will be 84 bytes smaller and required to adapt
several FATE tests.

Signed-off-by: Andreas Rheinhardt 
---
 libavformat/matroskaenc.c| 113 ---
 tests/fate/matroska.mak  |   2 +-
 tests/fate/wavpack.mak   |   4 +-
 tests/ref/fate/aac-autobsf-adtstoasc |   4 +-
 tests/ref/fate/binsub-mksenc |   2 +-
 tests/ref/fate/rgb24-mkv |   4 +-
 tests/ref/lavf/mka   |   4 +-
 tests/ref/lavf/mkv   |   4 +-
 tests/ref/lavf/mkv_attachment|   4 +-
 tests/ref/seek/lavf-mkv  |  44 +--
 10 files changed, 67 insertions(+), 118 deletions(-)

diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index 274f62dd78..104a119acf 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -56,6 +56,10 @@
 #include "libavcodec/mpeg4audio.h"
 #include "libavcodec/internal.h"
 
+/* Level 1 elements we create a SeekHead entry for:
+ * Info, Tracks, Chapters, Attachments, Tags and Cues */
+#define MAX_SEEKHEAD_ENTRIES 6
+
 typedef struct ebml_master {
 int64_t pos;///< absolute offset in the containing 
AVIOContext where the master's elements start
 int sizebytes;  ///< how many bytes were reserved for 
the size
@@ -68,11 +72,9 @@ typedef struct mkv_seekhead_entry {
 
 typedef struct mkv_seekhead {
 int64_t filepos;
-int64_t segment_offset; ///< the file offset to the 
beginning of the segment
-int reserved_size;  ///< -1 if appending to file
-int max_entries;
-mkv_seekhead_entry  *entries;
+mkv_seekhead_entry  entries[MAX_SEEKHEAD_ENTRIES];
 int num_entries;
+int reserved_size;
 } mkv_seekhead;
 
 typedef struct mkv_cuepoint {
@@ -126,7 +128,7 @@ typedef struct MatroskaMuxContext {
 int64_t cluster_pts;
 int64_t duration_offset;
 int64_t duration;
-mkv_seekhead*seekhead;
+mkv_seekheadseekhead;
 mkv_cues*cues;
 mkv_track   *tracks;
 
@@ -386,10 +388,6 @@ static void mkv_deinit(AVFormatContext *s)
 ffio_free_dyn_buf(&mkv->tracks_bc);
 ffio_free_dyn_buf(&mkv->tags_bc);
 
-if (mkv->seekhead) {
-av_freep(&mkv->seekhead->entries);
-av_freep(&mkv->seekhead);
-}
 if (mkv->cues) {
 av_freep(&mkv->cues->entries);
 av_freep(&mkv->cues);
@@ -398,61 +396,32 @@ static void mkv_deinit(AVFormatContext *s)
 }
 
 /**
- * Initialize a mkv_seekhead element to be ready to index level 1 Matroska
- * elements. If a maximum number of elements is specified, enough space
- * will be reserved at the current file location to write a seek head of
- * that size.
- *
- * @param segment_offset The absolute offset to the position in the file
- *   where the segment begins.
- * @param numelements The maximum number of elements that will be indexed
- *by this seek head, 0 if unlimited.
+ * Initialize the seekhead element to be ready to index level 1 Matroska
+ * elements. Enough space to write MAX_SEEKHEAD_ENTRIES seekhead entries
+ * will be reserved at the current file location.
  */
-static mkv_seekhead *mkv_start_seekhead(AVIOContext *pb, int64_t 
segment_offset,
-int numelements)
+static void mkv_start_seekhead(MatroskaMuxContext *mkv, AVIOContext *pb)
 {
-mkv_seekhead *new_seekhead = av_mallocz(sizeof(mkv_seekhead));
-if (!new_seekhead)
-return NULL;
-
-new_seekhead->segment_offset = segment_offset;
-
-if (numelements > 0) {
-new_seekhead->filepos = avio_tell(pb);
+mkv->seekhead.filepos = avio_tell(pb);
 // 21 bytes max for a seek entry, 10 bytes max for the SeekHead ID
 // and size, 6 bytes for a CRC32 element, and 3 bytes to guarantee
 // that an EBML void element will fit afterwards
-new_seekhead->reserved_size = numelements * MAX_SEEKENTRY_SIZE + 19;
-new

[FFmpeg-devel] [PATCH 13/23] avformat/matroskaenc: Improve cues in case of no-video

2019-11-05 Thread Andreas Rheinhardt
The Matroska muxer currently only adds CuePoints in three cases:
a) For video keyframes. b) For the first audio frame in a new cluster if
in dash-mode. c) For subtitles. This means that ordinary Matroska audio
files won't have any cues which impedes seeking.

This commit changes this. For every track in a file without video track
it is checked and tracked whether a cue entry has already been added
for said track for the current cluster. This is used to add a cue entry
for each first packet of each track in each cluster.

Implements #3149.

Signed-off-by: Andreas Rheinhardt 
---
 libavformat/matroskaenc.c| 21 -
 tests/ref/fate/aac-autobsf-adtstoasc |  4 ++--
 tests/ref/lavf/mka   |  4 ++--
 3 files changed, 16 insertions(+), 13 deletions(-)

diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index dd25172eeb..bc94ed53ae 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -2138,6 +2138,10 @@ static void mkv_end_cluster(AVFormatContext *s)
 MatroskaMuxContext *mkv = s->priv_data;
 
 end_ebml_master_crc32(s->pb, &mkv->cluster_bc, mkv);
+if (!mkv->have_video) {
+for (int i = 0; i < s->nb_streams; i++)
+mkv->tracks[i].has_cue = 0;
+}
 mkv->cluster_pos = -1;
 avio_flush(s->pb);
 }
@@ -2250,7 +2254,7 @@ static int mkv_check_new_extra_data(AVFormatContext *s, 
AVPacket *pkt)
 return 0;
 }
 
-static int mkv_write_packet_internal(AVFormatContext *s, AVPacket *pkt, int 
add_cue)
+static int mkv_write_packet_internal(AVFormatContext *s, AVPacket *pkt)
 {
 MatroskaMuxContext *mkv = s->priv_data;
 AVIOContext *pb;
@@ -2294,10 +2298,12 @@ static int mkv_write_packet_internal(AVFormatContext 
*s, AVPacket *pkt, int add_
 
 if (par->codec_type != AVMEDIA_TYPE_SUBTITLE) {
 mkv_write_block(s, pb, MATROSKA_ID_SIMPLEBLOCK, pkt, keyframe);
-if ((s->pb->seekable & AVIO_SEEKABLE_NORMAL) && (par->codec_type == 
AVMEDIA_TYPE_VIDEO && keyframe || add_cue)) {
+if ((s->pb->seekable & AVIO_SEEKABLE_NORMAL) && keyframe &&
+(par->codec_type == AVMEDIA_TYPE_VIDEO || !mkv->have_video && 
!track->has_cue)) {
 ret = mkv_add_cuepoint(mkv->cues, pkt->stream_index, ts,
mkv->cluster_pos, relative_packet_pos, -1);
 if (ret < 0) return ret;
+track->has_cue = 1;
 }
 } else {
 if (par->codec_id == AV_CODEC_ID_WEBVTT) {
@@ -2364,8 +2370,7 @@ static int mkv_write_packet(AVFormatContext *s, AVPacket 
*pkt)
 // on seeing key frames.
 start_new_cluster = keyframe;
 } else if (mkv->is_dash && codec_type == AVMEDIA_TYPE_AUDIO &&
-   (mkv->cluster_pos == -1 ||
-cluster_time > mkv->cluster_time_limit)) {
+   cluster_time > mkv->cluster_time_limit) {
 // For DASH audio, we create a Cluster based on cluster_time_limit
 start_new_cluster = 1;
 } else if (!mkv->is_dash &&
@@ -2389,9 +2394,7 @@ static int mkv_write_packet(AVFormatContext *s, AVPacket 
*pkt)
 
 // check if we have an audio packet cached
 if (mkv->cur_audio_pkt.size > 0) {
-// for DASH audio, a CuePoint has to be added when there is a new 
cluster.
-ret = mkv_write_packet_internal(s, &mkv->cur_audio_pkt,
-mkv->is_dash ? start_new_cluster : 0);
+ret = mkv_write_packet_internal(s, &mkv->cur_audio_pkt);
 av_packet_unref(&mkv->cur_audio_pkt);
 if (ret < 0) {
 av_log(s, AV_LOG_ERROR,
@@ -2406,7 +2409,7 @@ static int mkv_write_packet(AVFormatContext *s, AVPacket 
*pkt)
 if (pkt->size > 0)
 ret = av_packet_ref(&mkv->cur_audio_pkt, pkt);
 } else
-ret = mkv_write_packet_internal(s, pkt, 0);
+ret = mkv_write_packet_internal(s, pkt);
 return ret;
 }
 
@@ -2435,7 +2438,7 @@ static int mkv_write_trailer(AVFormatContext *s)
 
 // check if we have an audio packet cached
 if (mkv->cur_audio_pkt.size > 0) {
-ret = mkv_write_packet_internal(s, &mkv->cur_audio_pkt, 0);
+ret = mkv_write_packet_internal(s, &mkv->cur_audio_pkt);
 if (ret < 0) {
 av_log(s, AV_LOG_ERROR,
"Could not write cached audio packet ret:%d\n", ret);
diff --git a/tests/ref/fate/aac-autobsf-adtstoasc 
b/tests/ref/fate/aac-autobsf-adtstoasc
index 2f361d678c..adc47bfeb6 100644
--- a/tests/ref/fate/aac-autobsf-adtstoasc
+++ b/tests/ref/fate/aac-autobsf-adtstoasc
@@ -1,5 +1,5 @@
-3bb278ab6ca22a00c3f14bd00f887332 
*tests/data/fate/aac-autobsf-adtstoasc.matroska
-6611 tests/data/fate/aac-autobsf-adtstoasc.matroska
+8a02d889ba2d238cdd7fe1092c6b82ba 
*tests/data/fate/aac-autobsf-adtstoasc.matroska
+6639 tests/data/fate/aac-autobsf-adtstoasc.matroska
 #extradata 0:2, 0x0030001c
 #tb 0: 1/1000
 #media_type 0: audio
diff --git a/tests/ref/lavf/mka b/tests/ref/lavf/mka
index ede6398ca8..496dc74be6 10064

[FFmpeg-devel] [PATCH 07/23] avformat/matroskaenc: Improve writing video-projection

2019-11-05 Thread Andreas Rheinhardt
The Matroska video-projection master element has such a small maximum
length that it can always be written with a length field of length one.
So it is unnecessary to first write the element into a dynamic buffer to
get the accurate length in order not to waste bytes on the length field.

Signed-off-by: Andreas Rheinhardt 
---
 libavformat/matroskaenc.c | 48 +--
 1 file changed, 21 insertions(+), 27 deletions(-)

diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index 104a119acf..fb9c38bf4b 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -895,10 +895,8 @@ static int mkv_write_video_projection(AVFormatContext *s, 
AVIOContext *pb,
   AVStream *st)
 {
 AVIOContext b;
-AVIOContext *dyn_cp;
+ebml_master projection;
 int side_data_size = 0;
-int ret, projection_size;
-uint8_t *projection_ptr;
 uint8_t private[20];
 
 const AVSphericalMapping *spherical =
@@ -908,62 +906,58 @@ static int mkv_write_video_projection(AVFormatContext *s, 
AVIOContext *pb,
 if (!side_data_size)
 return 0;
 
-ret = avio_open_dyn_buf(&dyn_cp);
-if (ret < 0)
-return ret;
+if (spherical->projection != AV_SPHERICAL_EQUIRECTANGULAR  &&
+spherical->projection != AV_SPHERICAL_EQUIRECTANGULAR_TILE &&
+spherical->projection != AV_SPHERICAL_CUBEMAP) {
+av_log(s, AV_LOG_WARNING, "Unknown projection type\n");
+return 0;
+}
+
+// Maximally 4 8-byte elements with id-length 2 + 1 byte length field
+// and the private data of the AV_SPHERICAL_EQUIRECTANGULAR_TILE case
+projection = start_ebml_master(pb, MATROSKA_ID_VIDEOPROJECTION,
+   4 * (2 + 1 + 8) + (2 + 1 + 20));
 
 switch (spherical->projection) {
 case AV_SPHERICAL_EQUIRECTANGULAR:
-put_ebml_uint(dyn_cp, MATROSKA_ID_VIDEOPROJECTIONTYPE,
+put_ebml_uint(pb, MATROSKA_ID_VIDEOPROJECTIONTYPE,
   MATROSKA_VIDEO_PROJECTION_TYPE_EQUIRECTANGULAR);
 break;
 case AV_SPHERICAL_EQUIRECTANGULAR_TILE:
 ffio_init_context(&b, private, 20, 1, NULL, NULL, NULL, NULL);
-put_ebml_uint(dyn_cp, MATROSKA_ID_VIDEOPROJECTIONTYPE,
+put_ebml_uint(pb, MATROSKA_ID_VIDEOPROJECTIONTYPE,
   MATROSKA_VIDEO_PROJECTION_TYPE_EQUIRECTANGULAR);
 avio_wb32(&b, 0); // version + flags
 avio_wb32(&b, spherical->bound_top);
 avio_wb32(&b, spherical->bound_bottom);
 avio_wb32(&b, spherical->bound_left);
 avio_wb32(&b, spherical->bound_right);
-put_ebml_binary(dyn_cp, MATROSKA_ID_VIDEOPROJECTIONPRIVATE,
+put_ebml_binary(pb, MATROSKA_ID_VIDEOPROJECTIONPRIVATE,
 private, avio_tell(&b));
 break;
 case AV_SPHERICAL_CUBEMAP:
 ffio_init_context(&b, private, 12, 1, NULL, NULL, NULL, NULL);
-put_ebml_uint(dyn_cp, MATROSKA_ID_VIDEOPROJECTIONTYPE,
+put_ebml_uint(pb, MATROSKA_ID_VIDEOPROJECTIONTYPE,
   MATROSKA_VIDEO_PROJECTION_TYPE_CUBEMAP);
 avio_wb32(&b, 0); // version + flags
 avio_wb32(&b, 0); // layout
 avio_wb32(&b, spherical->padding);
-put_ebml_binary(dyn_cp, MATROSKA_ID_VIDEOPROJECTIONPRIVATE,
+put_ebml_binary(pb, MATROSKA_ID_VIDEOPROJECTIONPRIVATE,
 private, avio_tell(&b));
 break;
-default:
-av_log(s, AV_LOG_WARNING, "Unknown projection type\n");
-goto end;
 }
 
 if (spherical->yaw)
-put_ebml_float(dyn_cp, MATROSKA_ID_VIDEOPROJECTIONPOSEYAW,
+put_ebml_float(pb, MATROSKA_ID_VIDEOPROJECTIONPOSEYAW,
(double) spherical->yaw   / (1 << 16));
 if (spherical->pitch)
-put_ebml_float(dyn_cp, MATROSKA_ID_VIDEOPROJECTIONPOSEPITCH,
+put_ebml_float(pb, MATROSKA_ID_VIDEOPROJECTIONPOSEPITCH,
(double) spherical->pitch / (1 << 16));
 if (spherical->roll)
-put_ebml_float(dyn_cp, MATROSKA_ID_VIDEOPROJECTIONPOSEROLL,
+put_ebml_float(pb, MATROSKA_ID_VIDEOPROJECTIONPOSEROLL,
(double) spherical->roll  / (1 << 16));
 
-end:
-projection_size = avio_close_dyn_buf(dyn_cp, &projection_ptr);
-if (projection_size) {
-ebml_master projection = start_ebml_master(pb,
-   MATROSKA_ID_VIDEOPROJECTION,
-   projection_size);
-avio_write(pb, projection_ptr, projection_size);
-end_ebml_master(pb, projection);
-}
-av_freep(&projection_ptr);
+end_ebml_master(pb, projection);
 
 return 0;
 }
-- 
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 

[FFmpeg-devel] [PATCH 14/23] avformat/matroskaenc: Remove outdated comment

2019-11-05 Thread Andreas Rheinhardt
This comment does not account for the fact that the limits on cluster
size and duration are configurable by the user since 98308bd4.

Signed-off-by: Andreas Rheinhardt 
---
 libavformat/matroskaenc.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index bc94ed53ae..39ad5d1ccf 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -2360,8 +2360,6 @@ static int mkv_write_packet(AVFormatContext *s, AVPacket 
*pkt)
 cluster_time = pkt->pts - mkv->cluster_pts;
 cluster_time += mkv->tracks[pkt->stream_index].ts_offset;
 
-// start a new cluster every 5 MB or 5 sec, or 32k / 1 sec for streaming or
-// after 4k and on a keyframe
 cluster_size = avio_tell(mkv->cluster_bc);
 
 if (mkv->is_dash && codec_type == AVMEDIA_TYPE_VIDEO) {
-- 
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 05/23] avformat/matroskaenc: Check functions that can fail

2019-11-05 Thread Andreas Rheinhardt
Sometimes it has not been checked whether opening the dynamic buffer for
writing tags fails; this might have led to segfaults.

Signed-off-by: Andreas Rheinhardt 
---
 libavformat/matroskaenc.c | 10 +++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index 179349690d..274f62dd78 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -1552,7 +1552,9 @@ static int mkv_write_tag_targets(AVFormatContext *s, 
uint32_t elementid,
 ret = mkv_add_seekhead_entry(mkv->seekhead, MATROSKA_ID_TAGS, 
avio_tell(s->pb));
 if (ret < 0) return ret;
 
-start_ebml_master_crc32(s->pb, &mkv->tags_bc, mkv, MATROSKA_ID_TAGS);
+ret = start_ebml_master_crc32(s->pb, &mkv->tags_bc, mkv, 
MATROSKA_ID_TAGS);
+if (ret < 0)
+return ret;
 }
 pb = mkv->tags_bc;
 
@@ -1650,8 +1652,10 @@ static int mkv_write_tags(AVFormatContext *s)
 if (st->codecpar->codec_type == AVMEDIA_TYPE_ATTACHMENT)
 continue;
 
-mkv_write_tag_targets(s, MATROSKA_ID_TAGTARGETS_TRACKUID,
-  track->uid, &tag_target);
+ret = mkv_write_tag_targets(s, MATROSKA_ID_TAGTARGETS_TRACKUID,
+track->uid, &tag_target);
+if (ret < 0)
+return ret;
 pb = mkv->tags_bc;
 
 tag = start_ebml_master(pb, MATROSKA_ID_SIMPLETAG, 0);
-- 
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 12/23] avformat/matroskaenc: Add check for using explicit track number

2019-11-05 Thread Andreas Rheinhardt
When creating dash streams, the track number is externally prescribed
and not derived from the number of streams in the AVFormatContext. Up
until now, a track number of zero was allowed, although this is an
illegal track number.
Furthermore, it was not checked whether the number of tracks for a file
using an explicit track number was more than one, as such a file would
be invalid (it would be impossible to tell to which track a block belongs
if different tracks share the same track number).
Besides that, use the macro MAX_TRACKS macro for the maximum of
dash_track_number.

Signed-off-by: Andreas Rheinhardt 
---
 libavformat/matroskaenc.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index aacd602221..dd25172eeb 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -2649,6 +2649,9 @@ static int mkv_init(struct AVFormatContext *s)
 track->track_num = mkv->is_dash ? mkv->dash_track_number : nb_tracks;
 }
 
+if (mkv->is_dash && nb_tracks != 1)
+return AVERROR(EINVAL);
+
 if (nb_tracks > MAX_TRACKS) {
 av_log(s, AV_LOG_ERROR,
"%d > "AV_STRINGIFY(MAX_TRACKS)" tracks (excluding attachments)"
@@ -2711,7 +2714,7 @@ static const AVOption options[] = {
 { "cluster_size_limit",  "Store at most the provided amount of bytes in a 
cluster. ", OFFSET(cluster_size_limit), 
AV_OPT_TYPE_INT  , { .i64 = -1 }, -1, INT_MAX,   FLAGS },
 { "cluster_time_limit",  "Store at most the provided number of 
milliseconds in a cluster.",   
OFFSET(cluster_time_limit), AV_OPT_TYPE_INT64, { .i64 = -1 }, -1, INT64_MAX, 
FLAGS },
 { "dash", "Create a WebM file conforming to WebM DASH specification", 
OFFSET(is_dash), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, FLAGS },
-{ "dash_track_number", "Track number for the DASH stream", 
OFFSET(dash_track_number), AV_OPT_TYPE_INT, { .i64 = 1 }, 0, 127, FLAGS },
+{ "dash_track_number", "Track number for the DASH stream", 
OFFSET(dash_track_number), AV_OPT_TYPE_INT, { .i64 = 1 }, 1, MAX_TRACKS, FLAGS 
},
 { "live", "Write files assuming it is a live stream.", OFFSET(is_live), 
AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, FLAGS },
 { "allow_raw_vfw", "allow RAW VFW mode", OFFSET(allow_raw_vfw), 
AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, FLAGS },
 { "write_crc32", "write a CRC32 element inside every Level 1 element", 
OFFSET(write_crc), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, FLAGS },
-- 
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 02/23] avformat/matroskaenc: Fix potential leak of cached packet

2019-11-05 Thread Andreas Rheinhardt
If mkv_write_trailer() is not called, the cached audio packet might
leak; so unref it in mkv_deinit().

Signed-off-by: Andreas Rheinhardt 
---
When I initially wrote the deinit function, I was under the impression
that the user always has to call av_write_trailer(). Therefore this has
been forgotten.

 libavformat/matroskaenc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index 90400de191..de57e474be 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -390,6 +390,8 @@ static void mkv_deinit(AVFormatContext *s)
 {
 MatroskaMuxContext *mkv = s->priv_data;
 
+av_packet_unref(&mkv->cur_audio_pkt);
+
 ffio_free_dyn_buf(&mkv->cluster_bc);
 ffio_free_dyn_buf(&mkv->info_bc);
 ffio_free_dyn_buf(&mkv->tracks_bc);
@@ -2534,7 +2536,6 @@ static int mkv_write_trailer(AVFormatContext *s)
 // check if we have an audio packet cached
 if (mkv->cur_audio_pkt.size > 0) {
 ret = mkv_write_packet_internal(s, &mkv->cur_audio_pkt, 0);
-av_packet_unref(&mkv->cur_audio_pkt);
 if (ret < 0) {
 av_log(s, AV_LOG_ERROR,
"Could not write cached audio packet ret:%d\n", ret);
-- 
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 11/23] avformat/matroskaenc: Increase max supported tracks

2019-11-05 Thread Andreas Rheinhardt
Our code can actually write tracks with a TrackNum in the range of
1..127 without problems. Variable length integers that only have '1'
bits after the marker bit are not reserved when being used to encode
the TrackNumber in a block (there is no equivalent of unknown length
elements here).

Signed-off-by: Andreas Rheinhardt 
---
 libavformat/matroskaenc.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index 1377891e96..aacd602221 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -108,9 +108,9 @@ typedef struct mkv_track {
 #define MODE_MATROSKAv2 0x01
 #define MODE_WEBM   0x02
 
-/** Maximum number of tracks allowed in a Matroska file (with track numbers in
- * range 1 to 126 (inclusive) */
-#define MAX_TRACKS 126
+/** Maximum number of tracks supported by this muxer (with track numbers
+ *  in the range 1 to 127 (inclusive)) */
+#define MAX_TRACKS 127
 
 typedef struct MatroskaMuxContext {
 const AVClass   *class;
@@ -2057,7 +2057,7 @@ static void mkv_write_block(AVFormatContext *s, 
AVIOContext *pb,
 
 put_ebml_id(pb, blockid);
 put_ebml_num(pb, size + 4, 0);
-// this assumes stream_index is less than 126
+// this assumes track_number is <= 127
 avio_w8(pb, 0x80 | track_number);
 avio_wb16(pb, ts - mkv->cluster_pts);
 avio_w8(pb, (blockid == MATROSKA_ID_SIMPLEBLOCK && keyframe) ? (1 << 7) : 
0);
@@ -2122,7 +2122,7 @@ static int mkv_write_vtt_blocks(AVFormatContext *s, 
AVIOContext *pb, AVPacket *p
 
 put_ebml_id(pb, MATROSKA_ID_BLOCK);
 put_ebml_num(pb, size + 4, 0);
-avio_w8(pb, 0x80 | track->track_num); // this assumes track_num is 
less than 126
+avio_w8(pb, 0x80 | track->track_num); // this assumes track_num <= 127
 avio_wb16(pb, ts - mkv->cluster_pts);
 avio_w8(pb, flags);
 avio_printf(pb, "%.*s\n%.*s\n%.*s", id_size, id, settings_size, settings, 
pkt->size, pkt->data);
-- 
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] lavf/movenc: Replace dts by pts to calculate duration

2019-11-05 Thread manuelyuan
From: Mengyang Yuan 

In this case, the input video is of dynamic frame rate and we don't want to
duplicate or drop frames, but the output video duration calculated by DTS is
incorrect, I solved it by using PTS.
There are many UGC videos with dynamic frame rates, which are represented by
PTS jumps. After transcoding with ffmpeg -vsync 0 or -vsync 2, the output
video duration becomes longer.By reading the code of x264/encoder/encoder.c,
I found that in order to predict the B frame, x264 needs to ensure that there
are enough reference frames when DTS = 0, so the DTS of these reference frames
will subtract the cache time. However, the cache time includes the part of PTS
jumps, which results in the abnormal small DTS.

Signed-off-by: Mengyang Yuan 
---
 libavformat/movenc.c | 23 ++-
 libavformat/movenc.h |  2 ++
 2 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 715bec1c2f..206aa48d8c 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -1015,7 +1015,7 @@ static int get_cluster_duration(MOVTrack *track, int 
cluster_idx)
 return 0;
 
 if (cluster_idx + 1 == track->entry)
-next_dts = track->track_duration + track->start_dts;
+next_dts = track->end_dts;
 else
 next_dts = track->cluster[cluster_idx + 1].dts;
 
@@ -5149,8 +5149,7 @@ static int mov_flush_fragment(AVFormatContext *s, int 
force)
 mov->mdat_size = 0;
 for (i = 0; i < mov->nb_streams; i++) {
 if (mov->tracks[i].entry)
-mov->tracks[i].frag_start += mov->tracks[i].start_dts +
- mov->tracks[i].track_duration -
+mov->tracks[i].frag_start += mov->tracks[i].end_dts -
  mov->tracks[i].cluster[0].dts;
 mov->tracks[i].entry = 0;
 mov->tracks[i].end_reliable = 0;
@@ -5208,7 +5207,7 @@ static int mov_flush_fragment(AVFormatContext *s, int 
force)
 int64_t duration = 0;
 
 if (track->entry)
-duration = track->start_dts + track->track_duration -
+duration = track->end_dts -
track->cluster[0].dts;
 if (mov->flags & FF_MOV_FLAG_SEPARATE_MOOF) {
 if (!track->mdat_buf)
@@ -5281,7 +5280,7 @@ static int check_pkt(AVFormatContext *s, AVPacket *pkt)
 ref = trk->cluster[trk->entry - 1].dts;
 } else if (   trk->start_dts != AV_NOPTS_VALUE
&& !trk->frag_discont) {
-ref = trk->start_dts + trk->track_duration;
+ref = trk->end_dts;
 } else
 ref = pkt->dts; // Skip tests for the first packet
 
@@ -5494,7 +5493,7 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt)
  * of the last packet of the previous fragment based on 
track_duration,
  * which might not exactly match our dts. Therefore adjust the dts
  * of this packet to be what the previous packets duration 
implies. */
-trk->cluster[trk->entry].dts = trk->start_dts + 
trk->track_duration;
+trk->cluster[trk->entry].dts = trk->end_dts;
 /* We also may have written the pts and the corresponding duration
  * in sidx/tfrf/tfxd tags; make sure the sidx pts and duration 
match up with
  * the next fragment. This means the cts of the first sample must
@@ -5546,13 +5545,17 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket 
*pkt)
"this case.\n",
pkt->stream_index, pkt->dts);
 }
-trk->track_duration = pkt->dts - trk->start_dts + pkt->duration;
-trk->last_sample_is_subtitle_end = 0;
-
 if (pkt->pts == AV_NOPTS_VALUE) {
 av_log(s, AV_LOG_WARNING, "pts has no value\n");
 pkt->pts = pkt->dts;
 }
+if (trk->start_pts == AV_NOPTS_VALUE) {
+trk->start_pts = pkt->pts;
+}
+trk->track_duration = FFMAX(pkt->pts - trk->start_pts + pkt->duration, 
trk->track_duration);
+trk->end_dts = pkt->dts + pkt->duration;
+trk->last_sample_is_subtitle_end = 0;
+
 if (pkt->dts != pkt->pts)
 trk->flags |= MOV_TRACK_CTTS;
 trk->cluster[trk->entry].cts   = pkt->pts - pkt->dts;
@@ -6295,7 +6298,9 @@ static int mov_init(AVFormatContext *s)
  * this is updated. */
 track->hint_track = -1;
 track->start_dts  = AV_NOPTS_VALUE;
+track->start_pts  = AV_NOPTS_VALUE;
 track->start_cts  = AV_NOPTS_VALUE;
+track->end_dts= AV_NOPTS_VALUE;
 track->end_pts= AV_NOPTS_VALUE;
 track->dts_shift  = AV_NOPTS_VALUE;
 if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
diff --git a/libavformat/movenc.h b/libavformat/movenc.h
index 68d6f23a5a..ddad2631d7 100644
--- a/libavformat/movenc.h
+++ b/libavformat/movenc.h
@@ -116,7 +116,9 @@ typedef struct MOVTrack {
 uint32_ttref_tag;
 int tref_id; ///< trackID of the reference

Re: [FFmpeg-devel] [PATCH 2/5] avcodec/nuv: Move comptype check up

2019-11-05 Thread Carl Eugen Hoyos
Am Sa., 2. Nov. 2019 um 17:08 Uhr schrieb Michael Niedermayer
:
>
> Fixes: Timeout (23sec -> 5ms)
> Fixes: 
> 18517/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_NUV_fuzzer-5753135536013312
>
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/nuv.c | 8 +---
>  1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/libavcodec/nuv.c b/libavcodec/nuv.c
> index bb80e3e884..0fa61a239d 100644
> --- a/libavcodec/nuv.c
> +++ b/libavcodec/nuv.c
> @@ -219,6 +219,11 @@ static int decode_frame(AVCodecContext *avctx, void 
> *data, int *got_frame,
>  case NUV_RTJPEG:
>  minsize = c->width/16 * (c->height/16) * 6;
>  break;

> +case NUV_BLACK: case NUV_COPY_LAST: case NUV_LZO: case NUV_RTJPEG_IN_LZO:

This style is ugly and different from the rest of the file.

> +break;
> +default:
> +av_log(avctx, AV_LOG_ERROR, "unknown compression\n");
> +return AVERROR_INVALIDDATA;
>  }
>  if (buf_size < minsize / 4)
>  return AVERROR_INVALIDDATA;
> @@ -307,9 +312,6 @@ retry:
>  case NUV_COPY_LAST:
>  /* nothing more to do here */
>  break;
> -default:
> -av_log(avctx, AV_LOG_ERROR, "unknown compression\n");
> -return AVERROR_INVALIDDATA;

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

Re: [FFmpeg-devel] [PATCH v2 0/2] lavf/isom: support for demuxing MPEG-H 3D Audio in MP4

2019-11-05 Thread Carl Eugen Hoyos
Am Mi., 30. Okt. 2019 um 03:52 Uhr schrieb Yuki.Tsuchiya
:

> Here is the sample content of the MPEG-H 3D Audio.
> https://www.filehosting.org/file/details/829625/mpeg-h_3d_audio_mhm1_sample.mp4

Does not work here, please use any other filehoster.

Thank you, 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".

Re: [FFmpeg-devel] [PATCH v3 1/2] lavf/isom: support for demuxing MPEG-H 3D Audio in MP4

2019-11-05 Thread Carl Eugen Hoyos
Am Fr., 1. Nov. 2019 um 06:24 Uhr schrieb Yuki Tsuchiya
:
>
> Implemented according to the specification at 
> https://www.iso.org/standard/69561.html
> The "mhm1" sample entry is registered with MP4RA, which is defined as MHAS 
> encapsulated single stream MPEG-H 3D Audio.
> "MHAS" stands for MPEG-H audio stream, which contains encoded audio data and 
> corresponds metadata for decoding.
> This patch enables extracting the MHAS bitstream from MP4.

I will push this if there are no objections.

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

Re: [FFmpeg-devel] [PATCH 5/5] avcodec/g729dec: Use 64bit and clip in scalar product

2019-11-05 Thread Carl Eugen Hoyos
Am Mi., 6. Nov. 2019 um 00:31 Uhr schrieb Michael Niedermayer
:
>
> The G729 reference clips after each individual operation and keeps
> track if overflow occurred (in the fixed point implementation)

I believe this is missing the word "decoder".

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] [PATCH 2/5] avformat/vividas: Error out on audio packets in the absence of audio streams

2019-11-05 Thread Michael Niedermayer
Signed-off-by: Michael Niedermayer 
---
 libavformat/vividas.c | 14 +-
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/libavformat/vividas.c b/libavformat/vividas.c
index e4255fd5cc..b804260b5d 100644
--- a/libavformat/vividas.c
+++ b/libavformat/vividas.c
@@ -52,6 +52,7 @@ typedef struct VIV_AudioSubpacket {
 typedef struct VividasDemuxContext {
 int n_sb_blocks;
 VIV_SB_block *sb_blocks;
+int num_audio;
 
 uint32_t sb_key;
 int64_t sb_offset;
@@ -280,7 +281,7 @@ static int track_header(VividasDemuxContext *viv, 
AVFormatContext *s,  uint8_t *
 int i,j;
 int64_t off;
 int val_1;
-int num_video, num_audio;
+int num_video;
 AVIOContext *pb;
 
 pb = avio_alloc_context(buf, size, 0, NULL, NULL, NULL, NULL);
@@ -340,13 +341,13 @@ static int track_header(VividasDemuxContext *viv, 
AVFormatContext *s,  uint8_t *
 off = avio_tell(pb);
 off += ffio_read_varlen(pb); // val_10
 avio_r8(pb); // '4'
-num_audio = avio_r8(pb);
+viv->num_audio = avio_r8(pb);
 avio_seek(pb, off, SEEK_SET);
 
-if (num_audio != 1)
-av_log(s, AV_LOG_WARNING, "number of audio tracks %d is not 1\n", 
num_audio);
+if (viv->num_audio != 1)
+av_log(s, AV_LOG_WARNING, "number of audio tracks %d is not 1\n", 
viv->num_audio);
 
-for(i=0;inum_audio;i++) {
 int q;
 AVStream *st = avformat_new_stream(s, NULL);
 
@@ -676,6 +677,9 @@ static int viv_read_packet(AVFormatContext *s,
 if (viv->sb_entries[viv->current_sb_entry].flag == 0) {
 uint64_t v_size = ffio_read_varlen(pb);
 
+if (!viv->num_audio)
+return AVERROR_INVALIDDATA;
+
 ffio_read_varlen(pb);
 if (v_size > INT_MAX)
 return AVERROR_INVALIDDATA;
-- 
2.23.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 5/5] avcodec/g729dec: Use 64bit and clip in scalar product

2019-11-05 Thread Michael Niedermayer
The G729 reference clips after each individual operation and keeps track if 
overflow
occurred (in the fixed point implementation), this here is
simpler and faster but not 1:1 the same what the reference does.

Non fuzzed samples which trigger any such overflow are welcome, so
the need and impact of different clipping solutions can be evaluated.

Fixes: signed integer overflow: 1271483721 + 1073676289 cannot be represented 
in type 'int'
Fixes: 
18617/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ACELP_KELVIN_fuzzer-5137705679978496

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
---
 libavcodec/g729dec.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/libavcodec/g729dec.c b/libavcodec/g729dec.c
index 67054b71df..16869e0df8 100644
--- a/libavcodec/g729dec.c
+++ b/libavcodec/g729dec.c
@@ -332,11 +332,14 @@ static int16_t g729d_voice_decision(int onset, int 
prev_voice_decision, const in
 
 static int32_t scalarproduct_int16_c(const int16_t * v1, const int16_t * v2, 
int order)
 {
-int res = 0;
+int64_t res = 0;
 
 while (order--)
 res += *v1++ * *v2++;
 
+if  (res > INT32_MAX) return INT32_MAX;
+else if (res < INT32_MIN) return INT32_MIN;
+
 return res;
 }
 
-- 
2.23.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 3/5] avcodec/ffwavesynth: Fix integer overflow with pink_ts_cur/next

2019-11-05 Thread Michael Niedermayer
Fixes: signed integer overflow: 6175076100092079360 - -5034989061050195840 
cannot be represented in type 'long'
Fixes: 
18614/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FFWAVESYNTH_fuzzer-5704508847423488

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
---
 libavcodec/ffwavesynth.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/ffwavesynth.c b/libavcodec/ffwavesynth.c
index 3a6a057964..349b45534d 100644
--- a/libavcodec/ffwavesynth.c
+++ b/libavcodec/ffwavesynth.c
@@ -217,8 +217,8 @@ static void wavesynth_seek(struct wavesynth_context *ws, 
int64_t ts)
 *last = -1;
 lcg_seek(&ws->dither_state, (uint32_t)ts - (uint32_t)ws->cur_ts);
 if (ws->pink_need) {
-int64_t pink_ts_cur  = (ws->cur_ts + PINK_UNIT - 1) & ~(PINK_UNIT - 1);
-int64_t pink_ts_next = ts & ~(PINK_UNIT - 1);
+uint64_t pink_ts_cur  = (ws->cur_ts + PINK_UNIT - 1) & ~(PINK_UNIT - 
1);
+uint64_t pink_ts_next = ts & ~(PINK_UNIT - 1);
 int pos = ts & (PINK_UNIT - 1);
 lcg_seek(&ws->pink_state, (uint32_t)(pink_ts_next - pink_ts_cur) * 2);
 if (pos) {
-- 
2.23.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 4/5] avcodec/ralf: Fix integer overflows with the filter coefficient in decode_channel()

2019-11-05 Thread Michael Niedermayer
Fixes: signed integer overflow: 1145975808 - -1146173210 cannot be represented 
in type 'int'
Fixes: 
18616/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_RALF_fuzzer-5121296757424128

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
---
 libavcodec/ralf.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/ralf.c b/libavcodec/ralf.c
index 1d881cf7ae..90220279a3 100644
--- a/libavcodec/ralf.c
+++ b/libavcodec/ralf.c
@@ -264,8 +264,8 @@ static int decode_channel(RALFContext *ctx, GetBitContext 
*gb, int ch,
 t = get_vlc2(gb, vlc[cmode].table, vlc[cmode].bits, 2);
 t = extend_code(gb, t, 21, add_bits);
 if (!cmode)
-coeff -= 12 << add_bits;
-coeff = t - coeff;
+coeff -= 12U << add_bits;
+coeff = (unsigned)t - coeff;
 ctx->filter[i] = coeff;
 
 cmode = coeff >> add_bits;
-- 
2.23.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 1/5] avformat/vividas: Check and require 1 video stream

2019-11-05 Thread Michael Niedermayer
The decoder hardcodes that audio is stream_id = 1 so it does not
currently work with more or less than 1 video stream at st=0

Fixes: assertion failure
Fixes: 
18602/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-6259277199310848

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
---
 libavformat/vividas.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/libavformat/vividas.c b/libavformat/vividas.c
index efe1b8deff..e4255fd5cc 100644
--- a/libavformat/vividas.c
+++ b/libavformat/vividas.c
@@ -309,8 +309,10 @@ static int track_header(VividasDemuxContext *viv, 
AVFormatContext *s,  uint8_t *
 num_video = avio_r8(pb);
 
 avio_seek(pb, off, SEEK_SET);
-if (num_video != 1)
-av_log(s, AV_LOG_WARNING, "number of video tracks %d is not 1\n", 
num_video);
+if (num_video != 1) {
+av_log(s, AV_LOG_ERROR, "number of video tracks %d is not 1\n", 
num_video);
+return AVERROR_PATCHWELCOME;
+}
 
 for (i = 0; i < num_video; i++) {
 AVStream *st = avformat_new_stream(s, NULL);
-- 
2.23.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 1/4] configure: select mdct for dca encoder

2019-11-05 Thread Carl Eugen Hoyos
Am Di., 5. Nov. 2019 um 20:36 Uhr schrieb Lou Logan :

[...]

Set lgtm.

Thank you, 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".

Re: [FFmpeg-devel] [PATCH v1 1/4] doc/bitstream_filters: Fix copy an paste typo

2019-11-05 Thread Michael Niedermayer
On Mon, Nov 04, 2019 at 07:09:59PM +0800, lance.lmw...@gmail.com wrote:
> From: Limin Wang 
> 
> Signed-off-by: Limin Wang 
> ---
>  doc/bitstream_filters.texi | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/doc/bitstream_filters.texi b/doc/bitstream_filters.texi
> index 50a1679fc7..8fe5b3ad75 100644
> --- a/doc/bitstream_filters.texi
> +++ b/doc/bitstream_filters.texi
> @@ -598,7 +598,7 @@ Available values are:
>  
>  @table @samp
>  @item auto
> -Keep the same transfer characteristics property (default).
> +Keep the same colorspace property (default).

will apply

thx

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

The educated differ from the uneducated as much as the living from the
dead. -- Aristotle 


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] avformat/nutenc: Do not pass NULL to memcmp() in get_needed_flags()

2019-11-05 Thread Michael Niedermayer
On Fri, Nov 01, 2019 at 01:33:43PM +0100, Michael Niedermayer wrote:
> This compared to the other suggestions is cleaner and easier to understand
> keeping the condition in the if() simple.
> 
> This affects alot of fate tests.
> 
> See: [FFmpeg-devel] [PATCH 05/11] avformat/nutenc: Don't pass NULL to memcmp
> See: [FFmpeg-devel] [PATCH]lavf/nutenc: Do not call memcmp() with NULL 
> argument
> 
> Fixes: Ticket 7980
> 
> Signed-off-by: Michael Niedermayer 
> ---
>  libavformat/nutenc.c | 11 ++-
>  1 file changed, 6 insertions(+), 5 deletions(-)

will apply

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

I do not agree with what you have to say, but I'll defend to the death your
right to say it. -- Voltaire


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

[FFmpeg-devel] Add support to a PCM audio codec (Win)

2019-11-05 Thread cumdacon

Hi to all dev!

FFmpeg on Windows32;
request of full audio codec support
pcm_s16be
into a container MP4.

LOG:
[mp4 @ 00a5f840] Could not find tag for codec pcm_s16be in stream #1, codec 
not currently supported in container
Could not write header for output file #0 (incorrect codec parameters ?): 
Invalid argument


Sample AUDIO for verify:
drive.google.com/open?id=1UpxoCLp-N0jEC4pm6u-YTq-ULHz6B0Ho

thanks a lot if you want to add this codec, it were very useful at least for 
me ;)

please let me know about your decision about my purpose.

Best,

___
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/4] avcodec/Makefile: add missing h263data dependency to snow encoder

2019-11-05 Thread Lou Logan
Signed-off-by: Lou Logan 
---
Fixes:
--disable-everything --enable-encoder=snow
/usr/bin/ld: libavcodec/libavcodec.a(ituh263enc.o): in function 
`h263_get_motion_length':
ituh263enc.c:(.text+0x487): undefined reference to `ff_mvtab'
/usr/bin/ld: ituh263enc.c:(.text+0x4db): undefined reference to `ff_mvtab'
/usr/bin/ld: libavcodec/libavcodec.a(ituh263enc.o): in function `get_p_cbp':
ituh263enc.c:(.text+0x63c): undefined reference to `ff_h263_inter_MCBPC_bits'
/usr/bin/ld: ituh263enc.c:(.text+0x6b5): undefined reference to 
`ff_h263_cbpy_tab'
/usr/bin/ld: libavcodec/libavcodec.a(ituh263enc.o): in function 
`ff_h263_aspect_to_info':
ituh263enc.c:(.text+0x8a1): undefined reference to `ff_h263_pixel_aspect'
/usr/bin/ld: libavcodec/libavcodec.a(ituh263enc.o): in function 
`ff_h263_encode_picture_header':
ituh263enc.c:(.text+0xc34): undefined reference to `ff_h263_format'
/usr/bin/ld: libavcodec/libavcodec.a(ituh263enc.o): in function 
`h263_encode_block':
ituh263enc.c:(.text+0x1733): undefined reference to `ff_h263_rl_inter'
/usr/bin/ld: ituh263enc.c:(.text+0x180b): undefined reference to 
`ff_rl_intra_aic'
/usr/bin/ld: ituh263enc.c:(.text+0x18f1): undefined reference to 
`ff_rl_intra_aic'
/usr/bin/ld: ituh263enc.c:(.text+0x1925): undefined reference to 
`ff_rl_intra_aic'
/usr/bin/ld: ituh263enc.c:(.text+0x1959): undefined reference to 
`ff_rl_intra_aic'
/usr/bin/ld: ituh263enc.c:(.text+0x19b7): undefined reference to 
`ff_rl_intra_aic'
/usr/bin/ld: libavcodec/libavcodec.a(ituh263enc.o): in function 
`ff_h263_encode_mb':
ituh263enc.c:(.text+0x1e80): undefined reference to `ff_h263_inter_MCBPC_code'
/usr/bin/ld: ituh263enc.c:(.text+0x1e93): undefined reference to 
`ff_h263_inter_MCBPC_bits'
/usr/bin/ld: ituh263enc.c:(.text+0x1ebb): undefined reference to 
`ff_h263_cbpy_tab'
/usr/bin/ld: ituh263enc.c:(.text+0x1ecf): undefined reference to 
`ff_h263_cbpy_tab'
/usr/bin/ld: ituh263enc.c:(.text+0x205a): undefined reference to 
`ff_h263_inter_MCBPC_code'
/usr/bin/ld: ituh263enc.c:(.text+0x2070): undefined reference to 
`ff_h263_inter_MCBPC_bits'
/usr/bin/ld: ituh263enc.c:(.text+0x2095): undefined reference to 
`ff_h263_cbpy_tab'
/usr/bin/ld: ituh263enc.c:(.text+0x20a9): undefined reference to 
`ff_h263_cbpy_tab'
/usr/bin/ld: ituh263enc.c:(.text+0x2519): undefined reference to 
`ff_h263_intra_MCBPC_code'
/usr/bin/ld: ituh263enc.c:(.text+0x252c): undefined reference to 
`ff_h263_intra_MCBPC_bits'
/usr/bin/ld: ituh263enc.c:(.text+0x258a): undefined reference to 
`ff_h263_inter_MCBPC_code'
/usr/bin/ld: ituh263enc.c:(.text+0x25a0): undefined reference to 
`ff_h263_inter_MCBPC_bits'
/usr/bin/ld: ituh263enc.c:(.text+0x25f5): undefined reference to 
`ff_h263_cbpy_tab'
/usr/bin/ld: ituh263enc.c:(.text+0x2609): undefined reference to 
`ff_h263_cbpy_tab'
/usr/bin/ld: libavcodec/libavcodec.a(ituh263enc.o): in function 
`ff_h263_encode_motion':
ituh263enc.c:(.text+0x27d6): undefined reference to `ff_mvtab'
/usr/bin/ld: ituh263enc.c:(.text+0x27ea): undefined reference to `ff_mvtab'
/usr/bin/ld: ituh263enc.c:(.text+0x287e): undefined reference to `ff_mvtab'
/usr/bin/ld: ituh263enc.c:(.text+0x2899): undefined reference to `ff_mvtab'
/usr/bin/ld: libavcodec/libavcodec.a(ituh263enc.o): in function 
`init_mv_penalty_and_fcode':
ituh263enc.c:(.text+0x2904): undefined reference to `ff_mvtab'
/usr/bin/ld: libavcodec/libavcodec.a(ituh263enc.o):ituh263enc.c:(.text+0x294e): 
more undefined references to `ff_mvtab' follow
/usr/bin/ld: libavcodec/libavcodec.a(ituh263enc.o): in function 
`ff_h263_encode_init':
ituh263enc.c:(.text+0x2cd8): undefined reference to 
`ff_h263_static_rl_table_store'
/usr/bin/ld: ituh263enc.c:(.text+0x2ce2): undefined reference to 
`ff_h263_rl_inter'
/usr/bin/ld: ituh263enc.c:(.text+0x2cf1): undefined reference to 
`ff_h263_static_rl_table_store'
/usr/bin/ld: ituh263enc.c:(.text+0x2cff): undefined reference to 
`ff_rl_intra_aic'
/usr/bin/ld: ituh263enc.c:(.text+0x2d1a): undefined reference to 
`ff_rl_intra_aic'
/usr/bin/ld: ituh263enc.c:(.text+0x2d35): undefined reference to 
`ff_h263_rl_inter'
/usr/bin/ld: ituh263enc.c:(.text+0x2f14): undefined reference to 
`ff_aic_dc_scale_table'
/usr/bin/ld: libavcodec/libavcodec.a(ituh263enc.o): in function 
`ff_h263_encode_mba':
ituh263enc.c:(.text+0x2f87): undefined reference to `ff_mba_max'
/usr/bin/ld: ituh263enc.c:(.text+0x2fd5): undefined reference to `ff_mba_length'
---
 libavcodec/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 6f06e16419..04e94f3f30 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -587,7 +587,7 @@ OBJS-$(CONFIG_SMC_DECODER) += smc.o
 OBJS-$(CONFIG_SMVJPEG_DECODER) += smvjpegdec.o
 OBJS-$(CONFIG_SNOW_DECODER)+= snowdec.o snow.o snow_dwt.o
 OBJS-$(CONFIG_SNOW_ENCODER)+= snowenc.o snow.o snow_dwt.o  
   \
-  h263.o ituh263enc.o
+  h263.o h26

[FFmpeg-devel] [PATCH 4/4] avcodec/Makefile: add missing msmpeg4* dependencies to wmv1 encoder

2019-11-05 Thread Lou Logan
Signed-off-by: Lou Logan 

---

Fixes:
--disable-everything --enable-encoder=wmv1
/usr/bin/ld: libavcodec/libavcodec.a(msmpeg4enc.o): in function 
`ff_msmpeg4_encode_init':
msmpeg4enc.c:(.text+0x627): undefined reference to `ff_msmpeg4_common_init'
/usr/bin/ld: msmpeg4enc.c:(.text+0x671): undefined reference to `ff_mv_tables'
/usr/bin/ld: msmpeg4enc.c:(.text+0x691): undefined reference to `ff_mv_tables'
/usr/bin/ld: msmpeg4enc.c:(.text+0x6c7): undefined reference to 
`ff_static_rl_table_store'
/usr/bin/ld: msmpeg4enc.c:(.text+0x6ed): undefined reference to `ff_rl_table'
/usr/bin/ld: msmpeg4enc.c:(.text+0x757): undefined reference to `ff_rl_table'
/usr/bin/ld: libavcodec/libavcodec.a(msmpeg4enc.o): in function 
`ff_msmpeg4_encode_motion':
msmpeg4enc.c:(.text+0x1145): undefined reference to `ff_mv_tables'
/usr/bin/ld: libavcodec/libavcodec.a(msmpeg4enc.o): in function 
`ff_msmpeg4_encode_mb':
msmpeg4enc.c:(.text+0x1511): undefined reference to `ff_v2_mb_type'
/usr/bin/ld: msmpeg4enc.c:(.text+0x152a): undefined reference to `ff_v2_mb_type'
/usr/bin/ld: msmpeg4enc.c:(.text+0x1632): undefined reference to 
`ff_table_mb_non_intra'
/usr/bin/ld: msmpeg4enc.c:(.text+0x1645): undefined reference to 
`ff_table_mb_non_intra'
/usr/bin/ld: msmpeg4enc.c:(.text+0x17ac): undefined reference to 
`ff_msmpeg4_coded_block_pred'
/usr/bin/ld: msmpeg4enc.c:(.text+0x180d): undefined reference to 
`ff_v2_intra_cbpc'
/usr/bin/ld: msmpeg4enc.c:(.text+0x1826): undefined reference to 
`ff_v2_intra_cbpc'
/usr/bin/ld: msmpeg4enc.c:(.text+0x1882): undefined reference to `ff_v2_mb_type'
/usr/bin/ld: msmpeg4enc.c:(.text+0x189c): undefined reference to `ff_v2_mb_type'
/usr/bin/ld: msmpeg4enc.c:(.text+0x193b): undefined reference to 
`ff_msmp4_mb_i_table'
/usr/bin/ld: msmpeg4enc.c:(.text+0x194f): undefined reference to 
`ff_msmp4_mb_i_table'
/usr/bin/ld: msmpeg4enc.c:(.text+0x19a5): undefined reference to 
`ff_table_mb_non_intra'
/usr/bin/ld: msmpeg4enc.c:(.text+0x19b5): undefined reference to 
`ff_table_mb_non_intra'
/usr/bin/ld: msmpeg4enc.c:(.text+0x1a1f): undefined reference to 
`ff_table_inter_intra'
/usr/bin/ld: msmpeg4enc.c:(.text+0x1a3a): undefined reference to 
`ff_table_inter_intra'
/usr/bin/ld: libavcodec/libavcodec.a(msmpeg4enc.o): in function 
`msmpeg4_encode_dc':
msmpeg4enc.c:(.text+0x1b47): undefined reference to `ff_msmpeg4_pred_dc'
/usr/bin/ld: msmpeg4enc.c:(.text+0x1bad): undefined reference to 
`ff_v2_dc_lum_table'
/usr/bin/ld: msmpeg4enc.c:(.text+0x1bc3): undefined reference to 
`ff_v2_dc_lum_table'
/usr/bin/ld: msmpeg4enc.c:(.text+0x1bf6): undefined reference to 
`ff_v2_dc_chroma_table'
/usr/bin/ld: msmpeg4enc.c:(.text+0x1c0c): undefined reference to 
`ff_v2_dc_chroma_table'
/usr/bin/ld: msmpeg4enc.c:(.text+0x1cd4): undefined reference to 
`ff_table0_dc_lum'
/usr/bin/ld: msmpeg4enc.c:(.text+0x1ce4): undefined reference to 
`ff_table0_dc_lum'
/usr/bin/ld: msmpeg4enc.c:(.text+0x1d11): undefined reference to 
`ff_table0_dc_chroma'
/usr/bin/ld: msmpeg4enc.c:(.text+0x1d21): undefined reference to 
`ff_table0_dc_chroma'
/usr/bin/ld: msmpeg4enc.c:(.text+0x1d51): undefined reference to 
`ff_table1_dc_lum'
/usr/bin/ld: msmpeg4enc.c:(.text+0x1d61): undefined reference to 
`ff_table1_dc_lum'
/usr/bin/ld: msmpeg4enc.c:(.text+0x1d8b): undefined reference to 
`ff_table1_dc_chroma'
/usr/bin/ld: msmpeg4enc.c:(.text+0x1d9b): undefined reference to 
`ff_table1_dc_chroma'
/usr/bin/ld: libavcodec/libavcodec.a(msmpeg4enc.o): in function 
`ff_msmpeg4_encode_block':
msmpeg4enc.c:(.text+0x1ef8): undefined reference to `ff_rl_table'
/usr/bin/ld: msmpeg4enc.c:(.text+0x1f2d): undefined reference to `ff_rl_table'
/usr/bin/ld: msmpeg4enc.c:(.text+0x1f8d): undefined reference to `ff_rl_table'

---
 libavcodec/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 04e94f3f30..eee1e505f9 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -705,7 +705,7 @@ OBJS-$(CONFIG_WMAVOICE_DECODER)+= wmavoice.o \
   celp_filters.o \
   acelp_vectors.o acelp_filters.o
 OBJS-$(CONFIG_WMV1_DECODER)+= msmpeg4dec.o msmpeg4.o msmpeg4data.o
-OBJS-$(CONFIG_WMV1_ENCODER)+= msmpeg4enc.o
+OBJS-$(CONFIG_WMV1_ENCODER)+= msmpeg4enc.o msmpeg4.o msmpeg4data.o
 OBJS-$(CONFIG_WMV2_DECODER)+= wmv2dec.o wmv2.o wmv2data.o \
   msmpeg4dec.o msmpeg4.o msmpeg4data.o
 OBJS-$(CONFIG_WMV2_ENCODER)+= wmv2enc.o wmv2.o wmv2data.o \
-- 
2.23.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/4] avcodec/Makefile: add missing vorbis_data dependency to opus encoder

2019-11-05 Thread Lou Logan
Signed-off-by: Lou Logan 
---
Fixes:
--disable-everything --enable-encoder=opus
/usr/bin/ld: libavcodec/libavcodec.a(dcaenc.o): in function `encode_init':
dcaenc.c:(.text+0xeb9): undefined reference to `ff_mdct_init_fixed_32'
/usr/bin/ld: libavcodec/libavcodec.a(dcaenc.o): in function `encode_close':
dcaenc.c:(.text+0x159c): undefined reference to `ff_mdct_end_fixed_32'
---
 libavcodec/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 54862171f9..6f06e16419 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -503,7 +503,7 @@ OBJS-$(CONFIG_OPUS_DECODER)+= opusdec.o opus.o 
opus_celt.o opus_rc.o
   opus_pvq.o opus_silk.o opustab.o 
vorbis_data.o \
   opusdsp.o
 OBJS-$(CONFIG_OPUS_ENCODER)+= opusenc.o opus.o opus_rc.o opustab.o 
opus_pvq.o \
-  opusenc_psy.o
+  opusenc_psy.o vorbis_data.o
 OBJS-$(CONFIG_PAF_AUDIO_DECODER)   += pafaudio.o
 OBJS-$(CONFIG_PAF_VIDEO_DECODER)   += pafvideo.o
 OBJS-$(CONFIG_PAM_DECODER) += pnmdec.o pnm.o
-- 
2.23.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 1/4] configure: select mdct for dca encoder

2019-11-05 Thread Lou Logan
Signed-off-by: Lou Logan 

---

Fixes:
--disable-everything --enable-encoder=dca
/usr/bin/ld: libavcodec/libavcodec.a(dcaenc.o): in function `encode_init':
dcaenc.c:(.text+0xeb9): undefined reference to `ff_mdct_init_fixed_32'
/usr/bin/ld: libavcodec/libavcodec.a(dcaenc.o): in function `encode_close':
dcaenc.c:(.text+0x159c): undefined reference to `ff_mdct_end_fixed_32'

---
 configure | 1 +
 1 file changed, 1 insertion(+)

diff --git a/configure b/configure
index bec47d4ffe..f0be66ec8e 100755
--- a/configure
+++ b/configure
@@ -2675,6 +2675,7 @@ cook_decoder_select="audiodsp mdct sinewin"
 cscd_decoder_select="lzo"
 cscd_decoder_suggest="zlib"
 dca_decoder_select="mdct"
+dca_encoder_select="mdct"
 dds_decoder_select="texturedsp"
 dirac_decoder_select="dirac_parse dwt golomb videodsp mpegvideoenc"
 dnxhd_decoder_select="blockdsp idctdsp"
-- 
2.23.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 1/8] configure: select mdct & sinewin for atrac3pal decoder

2019-11-05 Thread Lou Logan
On Mon, Nov 4, 2019, at 3:42 PM, Carl Eugen Hoyos wrote:
> Am Di., 5. Nov. 2019 um 00:45 Uhr schrieb Lou Logan :
> 
> [...]
> 
> Set lgtm.

Set pushed.
___
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/mpegenc.c: vbvsize option

2019-11-05 Thread Hendrik Leppkes
On Tue, Nov 5, 2019 at 5:44 PM Gaullier Nicolas
 wrote:
>
> >>On Thu, Oct 31, 2019 at 06:04:58PM +0100, Nicolas Gaullier wrote:
> >> Allow the user to set or override the vbv size
> >> ---
> >>  libavformat/mpegenc.c | 6 +-
> >>  1 file changed, 5 insertions(+), 1 deletion(-)
> >
> >This is not the "correct" way to handle this, because one mpeg container
> >can contain many streams and this is just one parameter for the container.
> >while the vbvsize is a parameter per stream.
>
> FYI, my main concern/use case is to be able to rewrap an input mpg file to a 
> new mpg file while keeping its vbv size.
> This was working back in version 2.8.9, just before codecpar was introduced 
> (ie. regression)...
> My first proposal would be very straightforward : insert a new 
> "rc_buffer_size" field at the end of AVCodecParameters but that would break 
> the ABI?
> Another point is that rc_buffer_size may be carried by stream side_data when 
> encoding, so that would mean two representations for the same information, I 
> don't know if this sounds "correct".
> At the end, do you think amending AVCodecParameters would be acceptable ?
> The fact is, I have no other idea because I don't see anyway how to setup 
> stream side_data from within the codec of the input stream.

Amending codecpar with such specific fields is not acceptable. As you
noted, we already have stream sidedata to carry these particular
values, so you should figure out a way to fill that sidedata from the
origin container, its the only proper way.

- Hendrik
___
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] avformat/movenc: Support for variable timescale in mov containers

2019-11-05 Thread Michael Niedermayer
On Mon, Nov 04, 2019 at 06:42:10PM +, Kevin Wheatley wrote:
> This pair of patches work together to facilitate user specified timescales for
> the Movie Header Atom 'mvhd', which allows constant sample table durations for
> all frame rates.
> 
> Currently there is a fixed timescale of 1000, which is not an even multiple of
> all the typical video frame/field rates. This means when performing certain
> duration based operations it is possible to be inaccurate.
> 
> The default behaviour is left at the current default defined by MOV_TIMESCALE,
> but can be over ridden by using the -mov_timescale  option.
> 
> Typical values of 600 would work for 24, 25 and 30 FPS, for 23.976 and other
> fractional rates could use 2997 same as Avid (or 24000 though caution
> should be used when encoding long durations).
> 
> 
> Example usage that has better behaviour than the current:
> 
> # Encode 50 frames at 24FPS and concatenate 5 copies
> ffmpeg -f lavfi -i smptebars=duration=2.08:size=1920x1080:rate=24 \
> -codec dnxhd -pix_fmt yuv422p -b:v 115M smptebars_dnx_1000.mov
> cat < concat_1000.txt
> file smptebars_dnx_1000.mov
> file smptebars_dnx_1000.mov
> file smptebars_dnx_1000.mov
> file smptebars_dnx_1000.mov
> file smptebars_dnx_1000.mov
> EOF
> ffmpeg -f concat -i concat_1000.txt -c copy smpte_concat_1000.mov
> ffprobe smpte_concat_1000.mov
> 
> The output of ffprobe will show a frame rate of 23.99 due to the effect of the
> sample durations in the stts entries.
> 
> With the new option of -mov_timescale set to 600:
> 
> ffmpeg -f lavfi -i smptebars=duration=2.08:size=1920x1080:rate=24 \
> -codec dnxhd -pix_fmt yuv422p -b:v 115M -mov_timescale 600 
> smptebars_dnx_600.mov
> cat < concat_600.txt
> file smptebars_dnx_600.mov
> file smptebars_dnx_600.mov
> file smptebars_dnx_600.mov
> file smptebars_dnx_600.mov
> file smptebars_dnx_600.mov
> EOF
> ffmpeg -f concat -i concat_600.txt -c copy -mov_timescale 600
> smpte_concat_600.mov
> ffprobe smpte_concat_600.mov
> 
> The durations all line up, the stts table is smaller and no rounding
> issues occur.

Assuming this doesnt violate any specifications and assuming that
it works with all players.
Then it would make sense to select this value automatically based
on the stream timestamps or timebases.
maybe there could be still a -mov_timescale but with an option for
"auto" to autoselect a small one which allows accurate representation
of most streams

thx

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

Old school: Use the lowest level language in which you can solve the problem
conveniently.
New school: Use the highest level language in which the latest supercomputer
can solve the problem without the user falling asleep waiting.


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

[FFmpeg-devel] [PATCH 1/1] avformat/mpegenc.c: vbvsize option

2019-11-05 Thread Gaullier Nicolas
>>On Thu, Oct 31, 2019 at 06:04:58PM +0100, Nicolas Gaullier wrote:
>> Allow the user to set or override the vbv size
>> ---
>>  libavformat/mpegenc.c | 6 +-
>>  1 file changed, 5 insertions(+), 1 deletion(-)
>
>This is not the "correct" way to handle this, because one mpeg container
>can contain many streams and this is just one parameter for the container.
>while the vbvsize is a parameter per stream.

FYI, my main concern/use case is to be able to rewrap an input mpg file to a 
new mpg file while keeping its vbv size.
This was working back in version 2.8.9, just before codecpar was introduced 
(ie. regression)...
My first proposal would be very straightforward : insert a new "rc_buffer_size" 
field at the end of AVCodecParameters but that would break the ABI?
Another point is that rc_buffer_size may be carried by stream side_data when 
encoding, so that would mean two representations for the same information, I 
don't know if this sounds "correct".
At the end, do you think amending AVCodecParameters would be acceptable ?
The fact is, I have no other idea because I don't see anyway how to setup 
stream side_data from within the codec of the input stream.
Thank you for your review and ... help
Nicolas
___
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] avutil/eval: add function to track variable use

2019-11-05 Thread Gyan



On 05-11-2019 07:40 pm, Nicolas George wrote:

Gyan (12019-11-05):

An example of a cross-referenced expression would be 'y=x+rand(10)'.
Normally in filters, X would be evaluated first, then Y, then X again. The
2nd eval of X will overwrite the first and can generate a different value.
With this func, we can avoid the 2nd eval.

I'm in the process of modifying the scale filter to allow 'n', 't', 'pos'
variables in frame eval mode (it already supports dynamic output based on
incoming frame changes) and I would like to catch their presence in init
mode, since av_expr_eval will fail. Now, it can also fail due to circularly
referenced expressions e.g. 'x=y+10' and 'y=x+10' and there's no way to
detect whether it's this case or if inapplicable variables have been used.

Then I would prefer that we wait for that to be done and working to
commit this patch. After all, it is entirely possible that you realize
this is not exactly what you need to achieve your goal.


I've looked for workarounds using existing API and I haven't found one. 
In my scale patch, I've implemented this function locally and it 
fulfills the role. Thought I should insert it generically.

Also, you may consider if it would be worthwhile to globally improve the
expression system: maybe have a context with dedicated structure to
define the variables and custom functions instead of just arrays that
needs to have the same size

The scale filter is not the only one with multiple expression
evaluation, it would be a waste if the simplification was not applicable
to all cases easily.
I have come across the need for this helper in other filters like the 
various draw* filters but it was never a priority. But the changes to 
scale/scale2ref filter need it or its equivalent. This one does the 
trick and I can see how it would be helpful in animation support for 
drawbox where all vars can refer to each other, so each expression is 
evaluated 5 times. That work is half-way done and is my next focus.



(Also, the possibility to define user variables would be nice. But that
would require re-writing most of the parser. It needs doing anyway, but
it is a huge work.)
That sounds desirable but that needs careful design in terms of 
sanitation of user input. That looks to be a job for another day. 
Possibly, early next year.


Thanks,
Gyan
___
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 v6 1/3] hevc_mp4toannexb: Insert correct parameter sets before IRAP

2019-11-05 Thread Andriy Gelman
On Wed, 30. Oct 09:45, Andriy Gelman wrote:
> On Thu, 24. Oct 20:50, Andriy Gelman wrote:
> > On Tue, 15. Oct 22:50, Andriy Gelman wrote:
> > > From: Andriy Gelman 
> > > 
> > > Fixes #7799
> > > 
> > > Currently, the mp4toannexb filter always inserts the same extradata at
> > > the start of the first IRAP unit. As in ticket #7799, this can lead to
> > > decoding errors if modified parameter sets are signalled in-band.
> > > 
> > > Decoding errors/visual artifacts are also present in the following 
> > > fate-suite/hevc-conformance datasets for hevc->mp4->hevc conversion:
> > >  -RAP_B_Bossen_1.bit
> > >  -RPS_C_ericsson_5.bit
> > >  -SLIST_A_Sony_4.bit
> > >  -SLIST_B_Sony_8.bit
> > >  -SLIST_C_Sony_3.bit
> > >  -SLIST_D_Sony_9.bit
> > >  -TSKIP_A_MS_2.bit
> > > 
> > > This commit solves these errors by keeping track of VPS/SPS/PPS parameter 
> > > sets
> > > during the conversion. The correct combination is inserted at the start
> > > of the first IRAP. SEIs from extradata are inserted before each IRAP.
> > > 
> > > This commit also makes an update to the hevc-bsf-mp4toannexb fate test
> > > since the result before this patch contained duplicate parameter sets
> > > in-band.
> > > ---
> > >  libavcodec/hevc_mp4toannexb_bsf.c | 503 --
> > >  tests/fate/hevc.mak   |   2 +-
> > >  2 files changed, 472 insertions(+), 33 deletions(-)
> > > 
> > > diff --git a/libavcodec/hevc_mp4toannexb_bsf.c 
> > > b/libavcodec/hevc_mp4toannexb_bsf.c
> > > index 09bce5b34c..1ca5f13807 100644
> > > --- a/libavcodec/hevc_mp4toannexb_bsf.c
> > > +++ b/libavcodec/hevc_mp4toannexb_bsf.c
> > > @@ -23,19 +23,224 @@
> > >  
> > >  #include "libavutil/intreadwrite.h"
> > >  #include "libavutil/mem.h"
> > > +#include "libavutil/avassert.h"
> > >  
> > >  #include "avcodec.h"
> > >  #include "bsf.h"
> > >  #include "bytestream.h"
> > >  #include "hevc.h"
> > > +#include "h2645_parse.h"
> > > +#include "hevc_ps.h"
> > > +#include "golomb.h"
> > >  
> > >  #define MIN_HEVCC_LENGTH 23
> > > +#define PROFILE_WITHOUT_IDC_BITS88
> > > +#define IS_IRAP(s)  ((s)->type >= 16 && (s)->type <= 23)
> > > +#define IS_PARAMSET(s)  ((s)->type >= 32 && (s)->type <= 34)
> > > +
> > > +/*reserved VCLs not included*/
> > > +#define IS_VCL(s)   ((s)->type <= 9 || ((s)->type >= 16 
> > > && (s)->type <= 21))
> > > +#define HEVC_NAL_HEADER_BITS16
> > > +
> > > +/*
> > > + * Copies data from input buffer to output buffer. Appends annexb 
> > > startcode.
> > > + * out must be allocated at least out_len + in_len + write_startcode * 4.
> > > + */
> > > +#define WRITE_NAL(out, out_len, in, in_len, write_startcode) do {
> > > \
> > > +if ((write_startcode)) {\
> > > +AV_WB32((out) + (out_len), 1);  \
> > > +(out_len) += 4; \
> > > +}   \
> > > +memcpy((out) + (out_len), (in), (in_len));  \
> > > +(out_len) += (in_len);  \
> > > +} while (0)
> > > +
> > > +typedef struct Param {
> > > +uint8_t *raw_data;  /* raw data to store param set payload*/
> > > +int  raw_size;  /* size of raw_data*/
> > > +size_t   allocated_size;/* allocated size of raw_data*/
> > > +int  ref;   /* stores the ref of the higher level 
> > > parameter set*/
> > > +int  is_signalled;  /* indicates whether this param has 
> > > already been signalled in the cvs*/
> > > +} Param;
> > > +
> > > +/* modified version of HEVCParamSets to store bytestream and reference 
> > > to previous level*/
> > > +typedef struct ParamSets {
> > > +Param vps_list[HEVC_MAX_VPS_COUNT];
> > > +Param sps_list[HEVC_MAX_SPS_COUNT];
> > > +Param pps_list[HEVC_MAX_PPS_COUNT];
> > > +
> > > +Param sei; /* cached SEIs from extradatat*/
> > > +} ParamSets;
> > >  
> > >  typedef struct HEVCBSFContext {
> > >  uint8_t  length_size;
> > >  int  extradata_parsed;
> > > +ParamSets ps; /* cached VPS/SPS/PPS parameter sets + SEI from 
> > > extradata*/
> > >  } HEVCBSFContext;
> > >  
> > > +static int update_cached_paramset(AVBSFContext *ctx, Param *cached_param,
> > > +  H2645NAL *nal, int ref)
> > > +{
> > > +int ret;
> > > +
> > > +if (cached_param->raw_data && cached_param->raw_size == 
> > > nal->raw_size + 4 &&
> > > +!memcmp(cached_param->raw_data + 4, nal->raw_data, 
> > > nal->raw_size)) {
> > > +av_log(ctx, AV_LOG_DEBUG, "NAL unit: %d. Copy already exists in 
> > > parameter set.\n", nal->type);
> > > +} else {
> > > +if (nal->raw_size + 4 > cached_param->allocated_size) {
> > > +ret = av_reallocp(&cached_param->raw_data,

Re: [FFmpeg-devel] [PATCH] avutil/eval: add function to track variable use

2019-11-05 Thread Nicolas George
Gyan (12019-11-05):
> An example of a cross-referenced expression would be 'y=x+rand(10)'. 
> Normally in filters, X would be evaluated first, then Y, then X again. The
> 2nd eval of X will overwrite the first and can generate a different value.
> With this func, we can avoid the 2nd eval.
> 
> I'm in the process of modifying the scale filter to allow 'n', 't', 'pos'
> variables in frame eval mode (it already supports dynamic output based on
> incoming frame changes) and I would like to catch their presence in init
> mode, since av_expr_eval will fail. Now, it can also fail due to circularly
> referenced expressions e.g. 'x=y+10' and 'y=x+10' and there's no way to
> detect whether it's this case or if inapplicable variables have been used.

Then I would prefer that we wait for that to be done and working to
commit this patch. After all, it is entirely possible that you realize
this is not exactly what you need to achieve your goal.

Also, you may consider if it would be worthwhile to globally improve the
expression system: maybe have a context with dedicated structure to
define the variables and custom functions instead of just arrays that
needs to have the same size.

The scale filter is not the only one with multiple expression
evaluation, it would be a waste if the simplification was not applicable
to all cases easily.

(Also, the possibility to define user variables would be nice. But that
would require re-writing most of the parser. It needs doing anyway, but
it is a huge work.)

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 1/2] avcodec/get_bits: cosmetics

2019-11-05 Thread Michael Niedermayer
On Tue, Nov 05, 2019 at 11:13:49AM +0100, Ramiro Polla wrote:
> ---
>  libavcodec/get_bits.h | 8 
>  1 file changed, 4 insertions(+), 4 deletions(-)

LGTM

thx

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

Why not whip the teacher when the pupil misbehaves? -- Diogenes of Sinope


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 2/2] avcodec/wmadec: cosmetics

2019-11-05 Thread Michael Niedermayer
On Tue, Nov 05, 2019 at 11:13:50AM +0100, Ramiro Polla wrote:
> ---
>  libavcodec/wmadec.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

LGTM

thx

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

If you drop bombs on a foreign country and kill a hundred thousand
innocent people, expect your government to call the consequence
"unprovoked inhuman terrorist attacks" and use it to justify dropping
more bombs and killing more people. The technology changed, the idea is old.


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] avutil/eval: add function to track variable use

2019-11-05 Thread Gyan



On 05-11-2019 03:55 pm, Michael Niedermayer wrote:

On Tue, Nov 05, 2019 at 10:13:52AM +0530, Gyan wrote:


On 05-11-2019 04:35 am, Michael Niedermayer wrote:

On Sun, Nov 03, 2019 at 11:14:25AM +0530, Gyan wrote:

Helps better identification of expr eval failures.

Gyan
  eval.c|   21 +
  eval.h|   10 ++
  version.h |4 ++--
  3 files changed, 33 insertions(+), 2 deletions(-)
3dd142baa0144fd324eb9da8a9932cfd7ab2cd98  
0001-avutil-eval-add-function-to-track-variable-use.patch
 From 19bce329464676f071707b99575f80e5abe1cd4c Mon Sep 17 00:00:00 2001
From: Gyan Doshi 
Date: Sat, 2 Nov 2019 20:16:42 +0530
Subject: [PATCH] avutil/eval: add function to track variable use

Helps avoid multiple evals of cross-referenced expressions
and catch the use of non-applicable variables with respect
to eval or special mode in filters

Maybe you should provide more details of the use case of this, maybe
with an example. Because it seems not completely obvious

An example of a cross-referenced expression would be 'y=x+rand(10)'.
Normally in filters, X would be evaluated first, then Y, then X again. The
2nd eval of X will overwrite the first and can generate a different value.
With this func, we can avoid the 2nd eval.

I'm in the process of modifying the scale filter to allow 'n', 't', 'pos'
variables in frame eval mode (it already supports dynamic output based on
incoming frame changes) and I would like to catch their presence in init
mode, since av_expr_eval will fail. Now, it can also fail due to circularly
referenced expressions e.g. 'x=y+10' and 'y=x+10' and there's no way to
detect whether it's this case or if inapplicable variables have been used.

please add this (or similar information) to the commit message


Done.

Thanks,
Gyan
From 2931fa96b8e7f80581ded280907655753e54def0 Mon Sep 17 00:00:00 2001
From: Gyan Doshi 
Date: Sat, 2 Nov 2019 20:16:42 +0530
Subject: [PATCH v2 1/2] avutil/eval: add function to track variable use

1)Some filters allow cross-referenced expressions e.g. x=y+10. In
such cases, filters evaluate expressions multiple times for
successful evaluation of all expressions. If the expression for one or
more variables contains a RNG, the result may vary across evaluation
leading to inconsistent values across the cross-referenced expressions.

2)A related case is circular expressions e.g. x=y+10 and y=x+10 which
cannot be succesfully resolved.

3)Certain filter variables may only be applicable in specific eval modes
and lead to a failure of evaluation in other modes e.g. pts is only relevant
for frame eval mode.

At present, there is no reliable means to identify these occurrences and
thus the error messages provided are broad or inaccurate. The helper
function introduced - av_expr_count_var - allows developers to identify
the use of one or more variables in expressions and thus tailor the error
message or allow for a graceful fallback.
---
 libavutil/eval.c| 21 +
 libavutil/eval.h| 10 ++
 libavutil/version.h |  4 ++--
 3 files changed, 33 insertions(+), 2 deletions(-)

diff --git a/libavutil/eval.c b/libavutil/eval.c
index 48832979e2..ed0fe636f7 100644
--- a/libavutil/eval.c
+++ b/libavutil/eval.c
@@ -735,6 +735,27 @@ end:
 return ret;
 }
 
+int av_expr_count_var(AVExpr *e, int var_start, int var_end)
+{
+int i, count = 0;
+
+if (var_start >= var_end)
+return AVERROR(EINVAL);
+
+if (!e)
+return AVERROR(EINVAL);
+
+for (i = 0; e->type != e_const && i < 3 && e->param[i]; i++)
+count += av_expr_count_var(e->param[i], var_start, var_end);
+
+if (e->type == e_const &&
+e->a.const_index >= var_start &&
+e->a.const_index < var_end)
+count++;
+
+return count;
+}
+
 double av_expr_eval(AVExpr *e, const double *const_values, void *opaque)
 {
 Parser p = { 0 };
diff --git a/libavutil/eval.h b/libavutil/eval.h
index dacd22b96e..030e5617cc 100644
--- a/libavutil/eval.h
+++ b/libavutil/eval.h
@@ -86,6 +86,16 @@ int av_expr_parse(AVExpr **expr, const char *s,
  */
 double av_expr_eval(AVExpr *e, const double *const_values, void *opaque);
 
+/**
+ * Return the number of occurrences of variables within a range in a parsed 
expression
+ *
+ * @param var_start index of the start of the range of variables being seached 
for in the const_names identifiers
+ * @param var_end index of the first variable after the range of variables 
being seached for in the const_names identifiers
+ * @return the number of occurrences of the variables in the range, a negative 
value indicates that no expression was passed
+ * or the range wasn't strictly monotonic
+ */
+int av_expr_count_var(AVExpr *e, int var_start, int var_end);
+
 /**
  * Free a parsed expression previously created with av_expr_parse().
  */
diff --git a/libavutil/version.h b/libavutil/version.h
index 27d663baf1..af3abf7265 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -79,8 +79,8 @@
  */
 
 #define LI

Re: [FFmpeg-devel] [PATCH] avutil/eval: add function to track variable use

2019-11-05 Thread Michael Niedermayer
On Tue, Nov 05, 2019 at 10:13:52AM +0530, Gyan wrote:
> 
> 
> On 05-11-2019 04:35 am, Michael Niedermayer wrote:
> >On Sun, Nov 03, 2019 at 11:14:25AM +0530, Gyan wrote:
> >>Helps better identification of expr eval failures.
> >>
> >>Gyan
> >>  eval.c|   21 +
> >>  eval.h|   10 ++
> >>  version.h |4 ++--
> >>  3 files changed, 33 insertions(+), 2 deletions(-)
> >>3dd142baa0144fd324eb9da8a9932cfd7ab2cd98  
> >>0001-avutil-eval-add-function-to-track-variable-use.patch
> >> From 19bce329464676f071707b99575f80e5abe1cd4c Mon Sep 17 00:00:00 2001
> >>From: Gyan Doshi 
> >>Date: Sat, 2 Nov 2019 20:16:42 +0530
> >>Subject: [PATCH] avutil/eval: add function to track variable use
> >>
> >>Helps avoid multiple evals of cross-referenced expressions
> >>and catch the use of non-applicable variables with respect
> >>to eval or special mode in filters
> >Maybe you should provide more details of the use case of this, maybe
> >with an example. Because it seems not completely obvious
> 
> An example of a cross-referenced expression would be 'y=x+rand(10)'. 
> Normally in filters, X would be evaluated first, then Y, then X again. The
> 2nd eval of X will overwrite the first and can generate a different value.
> With this func, we can avoid the 2nd eval.
> 
> I'm in the process of modifying the scale filter to allow 'n', 't', 'pos'
> variables in frame eval mode (it already supports dynamic output based on
> incoming frame changes) and I would like to catch their presence in init
> mode, since av_expr_eval will fail. Now, it can also fail due to circularly
> referenced expressions e.g. 'x=y+10' and 'y=x+10' and there's no way to
> detect whether it's this case or if inapplicable variables have been used.

please add this (or similar information) to the commit message

thx

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

Opposition brings concord. Out of discord comes the fairest harmony.
-- Heraclitus


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

[FFmpeg-devel] [PATCH 1/2] avcodec/get_bits: cosmetics

2019-11-05 Thread Ramiro Polla
---
 libavcodec/get_bits.h | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavcodec/get_bits.h b/libavcodec/get_bits.h
index c4ab607744..66fb877599 100644
--- a/libavcodec/get_bits.h
+++ b/libavcodec/get_bits.h
@@ -234,9 +234,9 @@ static inline void refill_32(GetBitContext *s, int is_le)
 #endif
 
 if (is_le)
-s->cache   = (uint64_t)AV_RL32(s->buffer + (s->index >> 3)) << 
s->bits_left | s->cache;
+s->cache = (uint64_t)AV_RL32(s->buffer + (s->index >> 3)) << 
s->bits_left | s->cache;
 else
-s->cache   = s->cache | (uint64_t)AV_RB32(s->buffer + (s->index >> 3)) 
<< (32 - s->bits_left);
+s->cache = s->cache | (uint64_t)AV_RB32(s->buffer + (s->index >> 3)) 
<< (32 - s->bits_left);
 s->index += 32;
 s->bits_left += 32;
 }
@@ -249,9 +249,9 @@ static inline void refill_64(GetBitContext *s, int is_le)
 #endif
 
 if (is_le)
-s->cache = AV_RL64(s->buffer + (s->index >> 3));
+s->cache = AV_RL64(s->buffer + (s->index >> 3));
 else
-s->cache = AV_RB64(s->buffer + (s->index >> 3));
+s->cache = AV_RB64(s->buffer + (s->index >> 3));
 s->index += 64;
 s->bits_left = 64;
 }
-- 
2.11.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] avcodec/wmadec: cosmetics

2019-11-05 Thread Ramiro Polla
---
 libavcodec/wmadec.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/wmadec.c b/libavcodec/wmadec.c
index 78b51e5871..e7886262f3 100644
--- a/libavcodec/wmadec.c
+++ b/libavcodec/wmadec.c
@@ -889,11 +889,11 @@ static int wma_decode_superframe(AVCodecContext *avctx, 
void *data,
 q   = s->last_superframe + s->last_superframe_len;
 len = bit_offset;
 while (len > 7) {
-*q++ = (get_bits) (&s->gb, 8);
+*q++ = get_bits(&s->gb, 8);
 len -= 8;
 }
 if (len > 0)
-*q++ = (get_bits) (&s->gb, len) << (8 - len);
+*q++ = get_bits(&s->gb, len) << (8 - len);
 memset(q, 0, AV_INPUT_BUFFER_PADDING_SIZE);
 
 /* XXX: bit_offset bits into last frame */
-- 
2.11.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] lavc/qsvenc: add the missing vp9 file

2019-11-05 Thread Fu, Linjie
> -Original Message-
> From: ffmpeg-devel  On Behalf Of
> Dennis Mungai
> Sent: Tuesday, November 5, 2019 13:04
> To: FFmpeg development discussions and patches  de...@ffmpeg.org>
> Cc: Zhong Li 
> Subject: Re: [FFmpeg-devel] [PATCH] lavc/qsvenc: add the missing vp9 file
> 
> On Mon, 4 Nov 2019 at 10:12, Zhong Li  wrote:
> >
> > It is missed in commit 3358380
> >
> > Signed-off-by: Zhong Li 
> > ---
> >  libavcodec/qsvenc_vp9.c | 113
> 
> >  1 file changed, 113 insertions(+)
> >  create mode 100644 libavcodec/qsvenc_vp9.c
> >
> > diff --git a/libavcodec/qsvenc_vp9.c b/libavcodec/qsvenc_vp9.c
> > new file mode 100644
> > index 000..9402f80
> > --- /dev/null
> > +++ b/libavcodec/qsvenc_vp9.c
> > @@ -0,0 +1,113 @@
> > +/*
> > + * Intel MediaSDK QSV based VP9 encoder
> > + *
> > + * 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 "libavutil/common.h"
> > +#include "libavutil/opt.h"
> > +
> > +#include "avcodec.h"
> > +#include "internal.h"
> > +#include "qsv.h"
> > +#include "qsv_internal.h"
> > +#include "qsvenc.h"
> > +
> > +typedef struct QSVVP9EncContext {
> > +AVClass *class;
> > +QSVEncContext qsv;
> > +} QSVVP9EncContext;
> > +
> > +static av_cold int qsv_enc_init(AVCodecContext *avctx)
> > +{
> > +QSVVP9EncContext *q = avctx->priv_data;
> > +q->qsv.low_power = 1;
> > +
> > +return ff_qsv_enc_init(avctx, &q->qsv);
> > +}
> > +
> > +static int qsv_enc_frame(AVCodecContext *avctx, AVPacket *pkt,
> > + const AVFrame *frame, int *got_packet)
> > +{
> > +QSVVP9EncContext *q = avctx->priv_data;
> > +
> > +return ff_qsv_encode(avctx, &q->qsv, pkt, frame, got_packet);
> > +}
> > +
> > +static av_cold int qsv_enc_close(AVCodecContext *avctx)
> > +{
> > +QSVVP9EncContext *q = avctx->priv_data;
> > +
> > +return ff_qsv_enc_close(avctx, &q->qsv);
> > +}
> > +
> > +#define OFFSET(x) offsetof(QSVVP9EncContext, x)
> > +#define VE AV_OPT_FLAG_VIDEO_PARAM |
> AV_OPT_FLAG_ENCODING_PARAM
> > +static const AVOption options[] = {
> > +QSV_COMMON_OPTS
> > +
> > +{ "profile",   NULL, OFFSET(qsv.profile), AV_OPT_TYPE_INT,   { .i64 =
> MFX_PROFILE_UNKNOWN },   0,   INT_MAX,  VE,  "profile" },
> > +{ "unknown",   NULL, 0,   AV_OPT_TYPE_CONST, { .i64 =
> MFX_PROFILE_UNKNOWN},   INT_MIN,  INT_MAX,  VE,  "profile" },
> > +{ "profile0",  NULL, 0,   AV_OPT_TYPE_CONST, { .i64 =
> MFX_PROFILE_VP9_0   },  INT_MIN,  INT_MAX,  VE,  "profile" },
> > +{ "profile1",  NULL, 0,   AV_OPT_TYPE_CONST, { .i64 =
> MFX_PROFILE_VP9_1   },  INT_MIN,  INT_MAX,  VE,  "profile" },
> > +{ "profile2",  NULL, 0,   AV_OPT_TYPE_CONST, { .i64 =
> MFX_PROFILE_VP9_2   },  INT_MIN,  INT_MAX,  VE,  "profile" },
> > +{ "profile3",  NULL, 0,   AV_OPT_TYPE_CONST, { .i64 =
> MFX_PROFILE_VP9_3   },  INT_MIN,  INT_MAX,  VE,  "profile" },
> > +
> > +{ NULL },
> > +};
> > +
> > +static const AVClass class = {
> > +.class_name = "vp9_qsv encoder",
> > +.item_name  = av_default_item_name,
> > +.option = options,
> > +.version= LIBAVUTIL_VERSION_INT,
> > +};
> > +
> > +static const AVCodecDefault qsv_enc_defaults[] = {
> > +{ "b", "1M"},
> > +{ "refs",  "0" },
> > +{ "g", "250"   },
> > +{ "trellis",   "-1"},
> > +{ "flags", "+cgop" },
> > +{ NULL },
> > +};
> > +
> > +AVCodec ff_vp9_qsv_encoder = {
> > +.name   = "vp9_qsv",
> > +.long_name  = NULL_IF_CONFIG_SMALL("VP9 video (Intel Quick Sync
> Video acceleration)"),
> > +.priv_data_size = sizeof(QSVVP9EncContext),
> > +.type   = AVMEDIA_TYPE_VIDEO,
> > +.id = AV_CODEC_ID_VP9,
> > +.init   = qsv_enc_init,
> > +.encode2= qsv_enc_frame,
> > +.close  = qsv_enc_close,
> > +.capabilities   = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_HYBRID,
> > +.pix_fmts   = (const enum AVPixelFormat[]){ AV_PIX_FMT_NV12,
> > +AV_PIX_FMT