[FFmpeg-devel] [PATCH] lavc/qsvdec: expose frame pic_type and key_frame

2018-01-28 Thread Zhong Li
Currently key_frame and pict_type are unset.
(./ffmpeg -c:v h264_qsv -debug_ts -i in.h264 -flags
 +global_header -c:v libx264 out.h264,
 then check the frame_type in the log)
Add an extra param to fetch the picture type from qsv decoder

Signed-off-by: ChaoX A Liu 
Signed-off-by: Zhong Li 
---
 libavcodec/qsv.c  | 24 
 libavcodec/qsv_internal.h |  3 +++
 libavcodec/qsvdec.c   |  7 +++
 3 files changed, 34 insertions(+)

diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c
index 5217adf..2362e55 100644
--- a/libavcodec/qsv.c
+++ b/libavcodec/qsv.c
@@ -195,6 +195,30 @@ int ff_qsv_find_surface_idx(QSVFramesContext *ctx, 
QSVFrame *frame)
 return AVERROR_BUG;
 }
 
+enum AVPictureType ff_qsv_map_pictype(int mfx_pic_type)
+{
+enum AVPictureType type = AV_PICTURE_TYPE_NONE;
+switch (mfx_pic_type & 0x7) {
+case MFX_FRAMETYPE_I:
+if (mfx_pic_type & MFX_FRAMETYPE_S)
+type = AV_PICTURE_TYPE_SI;
+else
+type = AV_PICTURE_TYPE_I;
+break;
+case MFX_FRAMETYPE_B:
+type = AV_PICTURE_TYPE_B;
+break;
+case MFX_FRAMETYPE_P:
+ if (mfx_pic_type & MFX_FRAMETYPE_S)
+type = AV_PICTURE_TYPE_SP;
+else
+type = AV_PICTURE_TYPE_P;
+break;
+}
+
+return type;
+}
+
 static int qsv_load_plugins(mfxSession session, const char *load_plugins,
 void *logctx)
 {
diff --git a/libavcodec/qsv_internal.h b/libavcodec/qsv_internal.h
index c030550..5c33f18 100644
--- a/libavcodec/qsv_internal.h
+++ b/libavcodec/qsv_internal.h
@@ -51,6 +51,8 @@ typedef struct QSVFrame {
 AVFrame *frame;
 mfxFrameSurface1 surface;
 mfxEncodeCtrl enc_ctrl;
+mfxExtDecodedFrameInfo dec_info;
+mfxExtBuffer *ext_param;
 
 int queued;
 int used;
@@ -86,6 +88,7 @@ int ff_qsv_codec_id_to_mfx(enum AVCodecID codec_id);
 int ff_qsv_profile_to_mfx(enum AVCodecID codec_id, int profile);
 
 int ff_qsv_map_pixfmt(enum AVPixelFormat format, uint32_t *fourcc);
+enum AVPictureType ff_qsv_map_pictype(int mfx_pic_type);
 
 int ff_qsv_init_internal_session(AVCodecContext *avctx, mfxSession *session,
  const char *load_plugins);
diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
index 45bedf9..29bdd86 100644
--- a/libavcodec/qsvdec.c
+++ b/libavcodec/qsvdec.c
@@ -232,6 +232,11 @@ static int alloc_frame(AVCodecContext *avctx, QSVContext 
*q, QSVFrame *frame)
 
 frame->surface.Data.MemId = &q->frames_ctx.mids[ret];
 }
+frame->surface.Data.ExtParam = &frame->ext_param;
+frame->surface.Data.NumExtParam = 1;
+frame->ext_param = (mfxExtBuffer*)&frame->dec_info;
+frame->dec_info.Header.BufferId = MFX_EXTBUFF_DECODED_FRAME_INFO;
+frame->dec_info.Header.BufferSz = sizeof(frame->dec_info);
 
 frame->used = 1;
 
@@ -416,6 +421,8 @@ FF_ENABLE_DEPRECATION_WARNINGS
 outsurf->Info.PicStruct & MFX_PICSTRUCT_FIELD_TFF;
 frame->interlaced_frame =
 !(outsurf->Info.PicStruct & MFX_PICSTRUCT_PROGRESSIVE);
+frame->pict_type = ff_qsv_map_pictype(out_frame->dec_info.FrameType);
+frame->key_frame = !!(out_frame->dec_info.FrameType & 
MFX_FRAMETYPE_IDR);
 
 /* update the surface properties */
 if (avctx->pix_fmt == AV_PIX_FMT_QSV)
-- 
1.8.3.1

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


[FFmpeg-devel] [PATCH 2/4] avformat/mpegenc - log error messages for unsupported LPCM streams

2018-01-28 Thread Gyan Doshi

Changes to MPEG-PS muxer factored as requested in
http://www.ffmpeg.org/pipermail/ffmpeg-devel/2018-January/224642.html
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 1/4] avformat/mpegenc - fix typo in VBV warning

2018-01-28 Thread Gyan Doshi

Changes to MPEG-PS muxer factored as requested in
http://www.ffmpeg.org/pipermail/ffmpeg-devel/2018-January/224642.html.
From a2349faf6cc3002c73840907bc440257bd078ccd Mon Sep 17 00:00:00 2001
From: Gyan Doshi 
Date: Mon, 29 Jan 2018 11:53:36 +0530
Subject: [PATCH 1/4] avformat/mpegenc - fix typo in VBV warning

Default VBV buffer size is 230KB, not 130KB.
---
 libavformat/mpegenc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/mpegenc.c b/libavformat/mpegenc.c
index c77c3dfe41..695de3f081 100644
--- a/libavformat/mpegenc.c
+++ b/libavformat/mpegenc.c
@@ -397,7 +397,7 @@ static av_cold int mpeg_mux_init(AVFormatContext *ctx)
 stream->max_buffer_size = 6 * 1024 + props->buffer_size / 8;
 else {
 av_log(ctx, AV_LOG_WARNING,
-   "VBV buffer size not set, using default size of 130KB\n"
+   "VBV buffer size not set, using default size of 230KB\n"
"If you want the mpeg file to be compliant to some 
specification\n"
"Like DVD, VCD or others, make sure you set the correct 
buffer size\n");
 // FIXME: this is probably too small as default
-- 
2.11.1.windows.1___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 4/4] avformat/mpegenc - reject unsupported audio streams

2018-01-28 Thread Gyan Doshi
From 800aa096357c5dfa822157f349a0f0d23fea8c84 Mon Sep 17 00:00:00 2001
From: Gyan Doshi 
Date: Mon, 29 Jan 2018 12:26:00 +0530
Subject: [PATCH 4/4] avformat/mpegenc - reject unsupported audio streams

Only MP2, MP3, PCM S16BE, AC3 and DTS audio codecs
are supported by the muxer.
---
 libavformat/mpegenc.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/libavformat/mpegenc.c b/libavformat/mpegenc.c
index 7a79b614ec..f3005d9518 100644
--- a/libavformat/mpegenc.c
+++ b/libavformat/mpegenc.c
@@ -388,6 +388,10 @@ static av_cold int mpeg_mux_init(AVFormatContext *ctx)
 stream->lpcm_header[1] = (st->codecpar->channels - 1) | (j << 
4);
 stream->lpcm_header[2] = 0x80;
 stream->lpcm_align = st->codecpar->channels * 2;
+} else if (st->codecpar->codec_id != AV_CODEC_ID_MP2 &&
+   st->codecpar->codec_id != AV_CODEC_ID_MP3) {
+   av_log(ctx, AV_LOG_ERROR, "Unsupported audio codec. 
Must be one of mp2, mp3, pcm_s16be, ac3 or dts.\n");
+   return AVERROR(EINVAL);
 } else {
 stream->id = mpa_id++;
 }
-- 
2.11.1.windows.1
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 3/4] avformat/mpegenc - accept PCM_DVD streams

2018-01-28 Thread Gyan Doshi
From 099ddfec0e6b1b9f2cd9b399294c8ad8123583c1 Mon Sep 17 00:00:00 2001
From: Gyan Doshi 
Date: Mon, 29 Jan 2018 12:17:46 +0530
Subject: [PATCH 3/4] avformat/mpegenc - accept PCM_DVD streams

PCM_S16BE streams in MPEG-PS are recognized as PCM_DVD by the demuxer
which prevents their proper remuxing in MPEG-1/2 PS.
---
 libavformat/mpegenc.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/libavformat/mpegenc.c b/libavformat/mpegenc.c
index 1be0cd56a3..7a79b614ec 100644
--- a/libavformat/mpegenc.c
+++ b/libavformat/mpegenc.c
@@ -353,7 +353,8 @@ static av_cold int mpeg_mux_init(AVFormatContext *ctx)
 if (!s->is_mpeg2 &&
 (st->codecpar->codec_id == AV_CODEC_ID_AC3 ||
  st->codecpar->codec_id == AV_CODEC_ID_DTS ||
- st->codecpar->codec_id == AV_CODEC_ID_PCM_S16BE))
+ st->codecpar->codec_id == AV_CODEC_ID_PCM_S16BE ||
+ st->codecpar->codec_id == AV_CODEC_ID_PCM_DVD))
  av_log(ctx, AV_LOG_WARNING,
 "%s in MPEG-1 system streams is not widely supported, "
 "consider using the vob or the dvd muxer "
@@ -363,7 +364,8 @@ static av_cold int mpeg_mux_init(AVFormatContext *ctx)
 stream->id = ac3_id++;
 } else if (st->codecpar->codec_id == AV_CODEC_ID_DTS) {
 stream->id = dts_id++;
-} else if (st->codecpar->codec_id == AV_CODEC_ID_PCM_S16BE) {
+} else if (st->codecpar->codec_id == AV_CODEC_ID_PCM_S16BE ||
+   st->codecpar->codec_id == AV_CODEC_ID_PCM_DVD) {
 stream->id = lpcm_id++;
 for (j = 0; j < 4; j++) {
 if (lpcm_freq_tab[j] == st->codecpar->sample_rate)
-- 
2.11.1.windows.1
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 2/4] avformat/mpegenc - log error messages for unsupported LPCM streams

2018-01-28 Thread Gyan Doshi

Forgot to attach patch.

Changes to MPEG-PS muxer factored as requested in
http://www.ffmpeg.org/pipermail/ffmpeg-devel/2018-January/224642.html.
From 344bd0981693a345aebb907d825cb3eb5f93b402 Mon Sep 17 00:00:00 2001
From: Gyan Doshi 
Date: Mon, 29 Jan 2018 12:11:41 +0530
Subject: [PATCH 2/4] avformat/mpegenc - log error messages for unsupported
 LPCM streams

The MPEG-PS muxer only accepts PCM S16BE streams having up to 8 channels
and one of the following sampling rates: 32 kHz 44.1kHz 48 kHz 96 kHz.
---
 libavformat/mpegenc.c | 15 ---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/libavformat/mpegenc.c b/libavformat/mpegenc.c
index 695de3f081..1be0cd56a3 100644
--- a/libavformat/mpegenc.c
+++ b/libavformat/mpegenc.c
@@ -369,10 +369,19 @@ static av_cold int mpeg_mux_init(AVFormatContext *ctx)
 if (lpcm_freq_tab[j] == st->codecpar->sample_rate)
 break;
 }
-if (j == 4)
+if (j == 4) {
+int sr;
+av_log(ctx, AV_LOG_ERROR, "Invalid sampling rate for PCM 
stream.\n");
+av_log(ctx, AV_LOG_INFO, "Allowed sampling rates:");
+for (sr = 0; sr < 4; sr++)
+ av_log(ctx, AV_LOG_INFO, " %d", lpcm_freq_tab[sr]);
+av_log(ctx, AV_LOG_INFO, "\n");
 goto fail;
-if (st->codecpar->channels > 8)
-return -1;
+}
+if (st->codecpar->channels > 8) {
+av_log(ctx, AV_LOG_ERROR, "At most 8 channels allowed for 
LPCM streams.\n");
+return AVERROR(EINVAL);
+}
 stream->lpcm_header[0] = 0x0c;
 stream->lpcm_header[1] = (st->codecpar->channels - 1) | (j << 
4);
 stream->lpcm_header[2] = 0x80;
-- 
2.11.1.windows.1___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH V3] example/vaapi_transcode: Add a VA-API transcode example.

2018-01-28 Thread Jun Zhao
V3: - Add error check when av_buffer_ref fail
- Fix exec encode/write but output file hasn't been open lead to crash issue
- Add build check 
V2: - deduce output format from file extension, because VP8/VP9 encoder
need to a muxer (e,g ivf or/and mp4).

From 1f9dcc65093e05a0a7a931352aaa9c1e67be5d2f Mon Sep 17 00:00:00 2001
From: Jun Zhao 
Date: Thu, 11 Jan 2018 15:00:30 +0800
Subject: [PATCH V3] example/vaapi_transcode: Add a VA-API transcode example.

Add VA-API transcoding example, useage like:
./vaapi_transcode input_stream h264_vaapi output_stream,
and the example can't handle resolution change case.

test case like:
- ./vaapi_transcode input.mp4 h264_vaapi output_h264.mp4
- ./vaapi_transcode input.mp4 vp8_vaapi output_vp8.ivf

Signed-off-by: Jun Zhao 
Signed-off-by: Liu, Kaixuan 
---
 configure  |   2 +
 doc/examples/Makefile  |   1 +
 doc/examples/vaapi_transcode.c | 305 +
 3 files changed, 308 insertions(+)
 create mode 100644 doc/examples/vaapi_transcode.c

diff --git a/configure b/configure
index fcfa7aa442..c4cf32e731 100755
--- a/configure
+++ b/configure
@@ -1526,6 +1526,7 @@ EXAMPLE_LIST="
 transcode_aac_example
 transcoding_example
 vaapi_encode_example
+vaapi_transcode_example
 "
 
 EXTERNAL_AUTODETECT_LIBRARY_LIST="
@@ -3320,6 +3321,7 @@ scaling_video_example_deps="avutil swscale"
 transcode_aac_example_deps="avcodec avformat swresample"
 transcoding_example_deps="avfilter avcodec avformat avutil"
 vaapi_encode_example_deps="avcodec avutil h264_vaapi_encoder"
+vaapi_transcode_example_deps="avcodec avformat avutil h264_vaapi_encoder"
 
 # EXTRALIBS_LIST
 cpu_init_extralibs="pthreads_extralibs"
diff --git a/doc/examples/Makefile b/doc/examples/Makefile
index da5af36532..928ff306b3 100644
--- a/doc/examples/Makefile
+++ b/doc/examples/Makefile
@@ -20,6 +20,7 @@ EXAMPLES-$(CONFIG_SCALING_VIDEO_EXAMPLE) += scaling_video
 EXAMPLES-$(CONFIG_TRANSCODE_AAC_EXAMPLE) += transcode_aac
 EXAMPLES-$(CONFIG_TRANSCODING_EXAMPLE)   += transcoding
 EXAMPLES-$(CONFIG_VAAPI_ENCODE_EXAMPLE)  += vaapi_encode
+EXAMPLES-$(CONFIG_VAAPI_TRANSCODE_EXAMPLE)   += vaapi_transcode
 
 EXAMPLES   := $(EXAMPLES-yes:%=doc/examples/%$(PROGSSUF)$(EXESUF))
 EXAMPLES_G := $(EXAMPLES-yes:%=doc/examples/%$(PROGSSUF)_g$(EXESUF))
diff --git a/doc/examples/vaapi_transcode.c b/doc/examples/vaapi_transcode.c
new file mode 100644
index 00..45eeef0a96
--- /dev/null
+++ b/doc/examples/vaapi_transcode.c
@@ -0,0 +1,305 @@
+/*
+ * Video Acceleration API (video transcoding) transcode sample
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file
+ * Intel VAAPI-accelerated transcoding example.
+ *
+ * @example vaapi_transcode.c
+ * This example shows how to do VAAPI-accelerated transcoding.
+ * Usage: vaapi_transcode input_stream h264_vaapi output_stream
+ * e.g: - vaapi_transcode input.mp4 h264_vaapi output_h264.mp4
+ *  - vaapi_transcode input.mp4 vp9_vaapi output_vp9.ivf
+ */
+
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+static AVFormatContext *ifmt_ctx = NULL, *ofmt_ctx = NULL;
+static AVBufferRef *hw_device_ctx = NULL;
+static AVCodecContext *decoder_ctx = NULL, *encoder_ctx = NULL;
+static int video_stream = -1;
+static AVStream *ost;
+static int initialized = 0;
+
+static enum AVPixelFormat get_vaapi_format(AVCodecContext *ctx,
+   const enum AVPixelFormat *pix_fmts)
+{
+const enum AVPixelFormat *p;
+
+for (p = pix_fmts; *p != AV_PIX_FMT_NONE; p++) {
+if (*p == AV_PIX_FMT_VAAPI)
+return *p;
+}
+
+fprintf(stderr, "Unable to decode this file using VA-API.\n");
+return AV_PIX_FMT_NONE;
+}
+
+static int open_input_file(const char *filename)
+{
+int ret;
+AVCodec *decoder = NULL;
+AVStream *video = NULL;
+
+if ((ret = avformat_open_input(&ifmt_ctx, filename, NULL, NULL)) < 0) {
+fprintf(stderr, "Cannot open input file '%s', Error code: %s\n",
+filename, av_err2str(ret));
+return ret;
+}
+
+if ((ret = avformat_find_stream_info(ifmt_ctx, NULL)) < 0) {
+fprintf(stderr, "Cannot find input stream information. Error code: 
%s\n",
+

Re: [FFmpeg-devel] [PATCH] dashdec: Fix segfault on decoding segment timeline

2018-01-28 Thread Steven Liu

>>> 
>>> libavformat/dashdec.c | 11 ---
>>> 1 file changed, 4 insertions(+), 7 deletions(-)
>>> 
>>> diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c
>>> index 2492f1d..cdb7ba5 100644
>>> --- a/libavformat/dashdec.c
>>> +++ b/libavformat/dashdec.c
>>> @@ -1083,15 +1083,12 @@ static int64_t calc_cur_seg_no(AVFormatContext *s, 
>>> struct representation *pls)
>>> if (pls->n_fragments) {
>>> num = pls->first_seq_no;
>>> } else if (pls->n_timelines) {
>>> -start_time_offset = 
>>> get_segment_start_time_based_on_timeline(pls, 0x) - 
>>> pls->timelines[pls->first_seq_no]->starttime; // total duration of playlist
>>> -if (start_time_offset < 60 * pls->fragment_timescale)
>>> -start_time_offset = 0;
>>> -else
>>> -start_time_offset = start_time_offset - 60 * 
>>> pls->fragment_timescale;
>>> -
>>> -num = calc_next_seg_no_from_timelines(pls, 
>>> pls->timelines[pls->first_seq_no]->starttime + start_time_offset);
>>> +start_time_offset = 
>>> get_segment_start_time_based_on_timeline(pls, 0x) - 60 * 
>>> pls->fragment_timescale; // 60 seconds before end
>>> +num = calc_next_seg_no_from_timelines(pls, start_time_offset);
>>> if (num == -1)
>>> num = pls->first_seq_no;
>>> +else
>>> +num += pls->first_seq_no;
>>> } else if (pls->fragment_duration){
>>> if (pls->presentation_timeoffset) {
>>> num = pls->presentation_timeoffset * 
>>> pls->fragment_timescale / pls->fragment_duration;
>> 
> 
> 
> 
Pushed

Thanks
Steven





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


Re: [FFmpeg-devel] [PATCH] avdevice/decklink_dec: Extract 1080i and NTSC VANC

2018-01-28 Thread Ray Tiley
On Sun, Jan 28, 2018 at 4:54 PM Marton Balint  wrote:

>
> On Thu, 25 Jan 2018, Ray Tiley wrote:
>
> > On Tue, Jan 23, 2018 at 9:07 AM Devin Heitmueller <
> > dheitmuel...@ltnglobal.com> wrote:
> >
> >> Hi Ray,
> >>
> >>> On Jan 22, 2018, at 11:20 PM, Ray Tiley  wrote:
> >>>
> >>> I'm reading 334-1:2017 Sec 4
> >>> "When the ANC packets defined in this standard are carried in a high
> >>> definition signal, they shall be carried in the Y stream."
> >>>
> >>> I couldn't find anywhere in the document where it calls out standard
> >>> definition
> >>
> >> Right, so my understanding was that allowing the ability to use both
> luma
> >> and chroma was a result of having less space in the VANC to hold data,
> >> compared to HD resolutions where that is much less likely to be an
> issue.
> >> That said, I’ve never seen an implementation that actually puts it in
> the
> >> chroma.
> >>
> >>>
> >>> Conversation is here:
> >>> https://video-dev.slack.com/archives/C0XKDDH5Y/p151614155574 <
> >> https://video-dev.slack.com/archives/C0XKDDH5Y/p151614155574> with
> >>> kier...@obe.tv  who I believe is in the
> >> ffmpeg-devel IRC.
> >>>
> >>
> >> Ah, ok.  That’s Kieran.  He’s really knowledgable in this area,
> although I
> >> cannot see the conversation you’ve linked to as it seems that room is
> only
> >> accessible by people with email accounts from certain domains.
> >>
> >> Devin
> >> ___
> >> ffmpeg-devel mailing list
> >> ffmpeg-devel@ffmpeg.org
> >> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> >
> >
> > Please find updated patch attatched. I reverted the vanc lines changes
> and
> > found that all my tests worked as expected, so not sure what was wrong w/
> > my original test. The need to extract vanc from the entire line vs just
> the
> > luma in NTSC is still required.
>
> Is interleaved VANC data is always the case for SD NTSC, or it depends on
> the equipment? Maybe we should add some auto detection, and check for the
> first VANC header. E.g.
>
> if (ctx->bmd_mode == bmdModeNTSC &&
>  (*(uint32_t*)buf & 0x3 == 0x3fc00))
>  unpack_v210
> else
>  unpack_luma_v210
>

Sounds good to me. Will send patch shortly.


>
> Also, later on in the code, you only parse half of the decoded VANC.
> If you decode from both the luma and chroma, get_metadata should be called
> with frame width*2, no?
>

Good catch. I was testing with very small caption packets so I did not see
it cut off. Will send patch shortly.


>
> Regards,
> Marton
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] avdevice/decklink_dec: Extract NTSC VANC

2018-01-28 Thread Ray Tiley
This changes how NTSC VANC is extracted from the buffer. In NTSC the vanc
data interleved between the uyvy and not just the luma as in
high definition resolutions.

In my testing this allows a decklink card encoding valid NTSC closed
captions to pass the caption data to the x264 encoder.

Updated with rewviews from Devon Heitmueller and Marton Balint.

Signed-off-by: Ray Tiley 
---
 libavdevice/decklink_dec.cpp | 30 +-
 1 file changed, 29 insertions(+), 1 deletion(-)

diff --git a/libavdevice/decklink_dec.cpp b/libavdevice/decklink_dec.cpp
index 94dae26..c7811eb 100644
--- a/libavdevice/decklink_dec.cpp
+++ b/libavdevice/decklink_dec.cpp
@@ -149,6 +149,30 @@ static void extract_luma_from_v210(uint16_t *dst, const 
uint8_t *src, int width)
 }
 }
 
+static void unpack_v210(uint16_t *dst, const uint8_t *src, int width)
+{
+int i;
+for (i = 0; i < width / 6; i++) {
+*dst++ =  src[0]   + ((src[1] & 3)  << 8);
+*dst++ = (src[1] >> 2) + ((src[2] & 15) << 6);
+*dst++ = (src[2] >> 4) + ((src[3] & 63) << 4);
+
+*dst++ =  src[4]   + ((src[5] & 3)  << 8);
+*dst++ = (src[5] >> 2) + ((src[6] & 15) << 6);
+*dst++ = (src[6] >> 4) + ((src[7] & 63) << 4);
+
+*dst++ =  src[8]   + ((src[9] & 3)  << 8);
+*dst++ = (src[9] >> 2) + ((src[10] & 15) << 6);
+*dst++ = (src[10] >> 4) + ((src[11] & 63) << 4);
+
+*dst++ =  src[12]   + ((src[13] & 3)  << 8);
+*dst++ = (src[13] >> 2) + ((src[14] & 15) << 6);
+*dst++ = (src[14] >> 4) + ((src[15] & 63) << 4);
+
+src += 16;
+}
+}
+
 static uint8_t calc_parity_and_line_offset(int line)
 {
 uint8_t ret = (line < 313) << 5;
@@ -741,7 +765,11 @@ HRESULT decklink_input_callback::VideoInputFrameArrived(
 uint8_t *buf;
 if (vanc->GetBufferForVerticalBlankingLine(i, 
(void**)&buf) == S_OK) {
 uint16_t luma_vanc[MAX_WIDTH_VANC];
-extract_luma_from_v210(luma_vanc, buf, 
videoFrame->GetWidth());
+if (ctx->bmd_mode == bmdModeNTSC) {
+  unpack_v210(luma_vanc, buf, 
videoFrame->GetWidth());
+} else {
+  extract_luma_from_v210(luma_vanc, buf, 
videoFrame->GetWidth());
+}
 txt_buf = get_metadata(avctx, luma_vanc, 
videoFrame->GetWidth(),
txt_buf, sizeof(txt_buf0) - 
(txt_buf - txt_buf0), &pkt);
 }
-- 
2.7.4

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


Re: [FFmpeg-devel] [PATCH] Add HW H.264 and HEVC encoding for AMD GPUs based on AMF SDK

2018-01-28 Thread James Almer
On 11/29/2017 12:13 PM, Mironov, Mikhail wrote:
>>
>>> +{ AV_PIX_FMT_D3D11,  AMF_SURFACE_NV12 },
>>
>> Wut, really? It's not a typo? It looks tricky.
>>
>> I assume AMF has D3D11 input, but then it'd still need to exclude P010.
>> I don't think this is ever done, and sending a P010 frame probably
>> crashes the thing?
>>
>>> +};
> 
> There is a checking at initialization time of sw_format that will fail for 
> P010.
> 
> Thanks,
> Mikhail

Could you take a look at https://trac.ffmpeg.org/ticket/6990? h264_amf
has issues encoding d3d11 frames.

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


Re: [FFmpeg-devel] [PATCH V2] example/vaapi_transcode: Add a VA-API transcode example.

2018-01-28 Thread Mark Thompson
On 26/01/18 13:11, Jun Zhao wrote:
> V2: - deduce output format from file extension, because VP8/VP9 encoder
> need to a muxer (e,g ivf or/and mp4).
> 
> From 9828a8889d5279202c2e8ef9429eb06ad869842b Mon Sep 17 00:00:00 2001
> From: Jun Zhao 
> Date: Thu, 11 Jan 2018 15:00:30 +0800
> Subject: [PATCH V2] example/vaapi_transcode: Add a VA-API transcode example.
> 
> Add VA-API transcoding example, useage like:
> ./vaapi_transcode input_stream h264_vaapi output_stream,
> and the example can't handle resolution change case.
> 
> test case like:
> - ./vaapi_transcode input.mp4 h264_vaapi output_h264.mp4
> - ./vaapi_transcode input.mp4 vp8_vaapi output_vp8.ivf
> 
> Signed-off-by: Jun Zhao 
> Signed-off-by: Liu, Kaixuan 
> ---
>  configure  |   2 +
>  doc/examples/Makefile  |   1 +
>  doc/examples/vaapi_transcode.c | 301 
> +
>  3 files changed, 304 insertions(+)
>  create mode 100644 doc/examples/vaapi_transcode.c

Generally looks good, some minor things below.

Thanks,

- Mark


> diff --git a/configure b/configure
> index fcfa7aa442..92aef31cbe 100755
> --- a/configure
> +++ b/configure
> @@ -1526,6 +1526,7 @@ EXAMPLE_LIST="
>  transcode_aac_example
>  transcoding_example
>  vaapi_encode_example
> +vaapi_transcode_example
>  "
>  
>  EXTERNAL_AUTODETECT_LIBRARY_LIST="
> @@ -3320,6 +3321,7 @@ scaling_video_example_deps="avutil swscale"
>  transcode_aac_example_deps="avcodec avformat swresample"
>  transcoding_example_deps="avfilter avcodec avformat avutil"
>  vaapi_encode_example_deps="avcodec avutil h264_vaapi_encoder"
> +vaapi_transcode_example_deps="avcodec avformat avutil"

Should probably depend on something VAAPI?  It will build fine without it, but 
can't actually work at all.

>  
>  # EXTRALIBS_LIST
>  cpu_init_extralibs="pthreads_extralibs"
> diff --git a/doc/examples/Makefile b/doc/examples/Makefile
> index da5af36532..928ff306b3 100644
> --- a/doc/examples/Makefile
> +++ b/doc/examples/Makefile
> @@ -20,6 +20,7 @@ EXAMPLES-$(CONFIG_SCALING_VIDEO_EXAMPLE) += 
> scaling_video
>  EXAMPLES-$(CONFIG_TRANSCODE_AAC_EXAMPLE) += transcode_aac
>  EXAMPLES-$(CONFIG_TRANSCODING_EXAMPLE)   += transcoding
>  EXAMPLES-$(CONFIG_VAAPI_ENCODE_EXAMPLE)  += vaapi_encode
> +EXAMPLES-$(CONFIG_VAAPI_TRANSCODE_EXAMPLE)   += vaapi_transcode
>  
>  EXAMPLES   := $(EXAMPLES-yes:%=doc/examples/%$(PROGSSUF)$(EXESUF))
>  EXAMPLES_G := $(EXAMPLES-yes:%=doc/examples/%$(PROGSSUF)_g$(EXESUF))
> diff --git a/doc/examples/vaapi_transcode.c b/doc/examples/vaapi_transcode.c
> new file mode 100644
> index 00..af1550f5f2
> --- /dev/null
> +++ b/doc/examples/vaapi_transcode.c
> @@ -0,0 +1,301 @@
> +/*
> + * Video Acceleration API (video transcoding) transcode sample
> + *
> + * This file is part of FFmpeg.
> + *
> + * FFmpeg is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * FFmpeg is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with FFmpeg; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 
> USA
> + */
> +
> +/**
> + * @file
> + * Intel VAAPI-accelerated transcoding example.
> + *
> + * @example vaapi_transcode.c
> + * This example shows how to do VAAPI-accelerated transcoding.
> + * Usage: vaapi_transcode input_stream h264_vaapi output_stream
> + * e.g: - vaapi_transcode input.mp4 h264_vaapi output_h264.mp4
> + *  - vaapi_transcode input.mp4 vp9_vaapi output_vp9.ivf
> + */
> +
> +#include 
> +#include 
> +
> +#include 
> +#include 
> +#include 
> +
> +static AVFormatContext *ifmt_ctx = NULL, *ofmt_ctx = NULL;
> +static AVBufferRef *hw_device_ctx = NULL;
> +static AVCodecContext *decoder_ctx = NULL, *encoder_ctx = NULL;
> +static int video_stream = -1;
> +static AVStream *ost;
> +static int initialized = 0;
> +
> +static enum AVPixelFormat get_vaapi_format(AVCodecContext *ctx,
> +   const enum AVPixelFormat 
> *pix_fmts)
> +{
> +const enum AVPixelFormat *p;
> +
> +for (p = pix_fmts; *p != AV_PIX_FMT_NONE; p++) {
> +if (*p == AV_PIX_FMT_VAAPI)
> +return *p;
> +}
> +
> +fprintf(stderr, "Unable to decode this file using VA-API.\n");
> +return AV_PIX_FMT_NONE;
> +}
> +
> +static int open_input_file(const char *filename)
> +{
> +int ret;
> +AVCodec *decoder = NULL;
> +AVStream *video = NULL;
> +
> +if ((ret = avformat_open_input(&ifmt_ctx, filename, NULL, NULL)) < 0) 

Re: [FFmpeg-devel] [PATCH 0/7] add AVFormatContext->url to replace the length limited filename field

2018-01-28 Thread Marton Balint


On Sun, 21 Jan 2018, Marton Balint wrote:


Here is a rebased version of the patch series on top of the current git master,
if I get no further comments, I will apply this in a week.

The conversion was mostly straightforward, but there were some cases where it
needed additional work, so I'd really appriciate if someone could test at least
the HLS changes.

The patch series does not remove all fixed-length buffers used for filenames
all around the codebase, that is for later.

Marton Balint (7):
 avformat/hlsenc: use av_bprintf without buffer limit in
   replace_int_data_in_filename
 avformat: add url field to AVFormatContext
 fftools, tools, examples: migrate to AVFormatContext->url
 avdevice: migrate to AVFormatContext->url
 avformat/hls: migrate to AVFormatContext->url
 avformat: migrate to AVFormatContext->url
 avformat: deprecate AVFormatContext filename field

doc/APIchanges   |   7 ++
doc/examples/transcode_aac.c |   7 +-
fftools/ffmpeg.c |  16 +--
fftools/ffmpeg_opt.c |   8 +-
fftools/ffplay.c |   6 +-
fftools/ffprobe.c|   2 +-
libavdevice/alsa.c   |   4 +-
libavdevice/avfoundation.m   |   2 +-
libavdevice/bktr.c   |   2 +-
libavdevice/caca.c   |   2 +-
libavdevice/decklink_common.cpp  |   2 +-
libavdevice/decklink_dec.cpp |   4 +-
libavdevice/decklink_enc.cpp |   4 +-
libavdevice/dshow.c  |   2 +-
libavdevice/fbdev_dec.c  |   4 +-
libavdevice/fbdev_enc.c  |   4 +-
libavdevice/gdigrab.c|   2 +-
libavdevice/iec61883.c   |   8 +-
libavdevice/jack.c   |   6 +-
libavdevice/lavfi.c  |   2 +-
libavdevice/libcdio.c|   6 +-
libavdevice/libndi_newtek_dec.c  |   2 +-
libavdevice/libndi_newtek_enc.c  |   4 +-
libavdevice/openal-dec.c |   2 +-
libavdevice/opengl_enc.c |   2 +-
libavdevice/oss_dec.c|   2 +-
libavdevice/oss_enc.c|   2 +-
libavdevice/pulse_audio_dec.c|   4 +-
libavdevice/pulse_audio_enc.c|   4 +-
libavdevice/sdl2.c   |   2 +-
libavdevice/sndio_dec.c  |   2 +-
libavdevice/sndio_enc.c  |   2 +-
libavdevice/v4l2.c   |  16 +--
libavdevice/v4l2enc.c|   4 +-
libavdevice/vfwcap.c |   4 +-
libavdevice/xcbgrab.c|   8 +-
libavdevice/xv.c |   2 +-
libavformat/avformat.h   |  20 
libavformat/concatdec.c  |   4 +-
libavformat/dashenc.c|  16 +--
libavformat/fifo.c   |   8 +-
libavformat/flvenc.c |   4 +-
libavformat/gxfenc.c |   4 +-
libavformat/hdsenc.c |  24 ++--
libavformat/hls.c|   4 +-
libavformat/hlsenc.c | 245 +--
libavformat/img2dec.c|   4 +-
libavformat/img2enc.c|   4 +-
libavformat/internal.h   |   7 ++
libavformat/matroskadec.c|   4 +-
libavformat/mlvdec.c |   4 +-
libavformat/mov.c|   2 +-
libavformat/movenc.c |  10 +-
libavformat/mpeg.c   |   4 +-
libavformat/mpegtsenc.c  |   2 +-
libavformat/mux.c|  21 +++-
libavformat/options.c|   2 +-
libavformat/rtsp.c   |  18 ++-
libavformat/rtspdec.c|   4 +-
libavformat/rtspenc.c|   4 +-
libavformat/sapdec.c |   2 +-
libavformat/sapenc.c |  10 +-
libavformat/sdp.c|   4 +-
libavformat/segment.c|  36 +++---
libavformat/smoothstreamingenc.c |  12 +-
libavformat/tee.c|   4 +-
libavformat/utils.c  |  24 +++-
libavformat/version.h|   5 +-
libavformat/webm_chunk.c |  10 +-
tools/uncoded_frame.c|   2 +-
70 files changed, 409 insertions(+), 281 deletions(-)



Pushed.

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


Re: [FFmpeg-devel] [PATCHv3] mpeg4video: Add support for MPEG-4 Simple Studio Profile.

2018-01-28 Thread Carl Eugen Hoyos
2018-01-28 19:53 GMT+01:00 Kieran Kunhya :
> Possibly fixed by below patch but frankly the ER code is impenetrable.

+/* In MPEG-4 studio mode look for a new slice startcode
+ * and decode slice header */
+if(s->codec_id==AV_CODEC_ID_MPEG4 && s->studio_profile) {
+align_get_bits(&s->gb);
+
+while (get_bits_left(&s->gb) >= 32 && show_bits_long(&s->gb,
32) != SLICE_START_CODE) {
+get_bits(&s->gb, 8);
+}
+
+if (show_bits_long(&s->gb, 32) == SLICE_START_CODE)
+return get_bits_count(&s->gb);
+else
+return -1;
+}

This hunk fixes the original issue I saw.

Does the following style that is used often in your patch have
any advantages?
"
}
else {
"
If yes, you should probably use it more consistently.

Still wondering why nobody else was able to reproduce, Carl Eugen
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avdevice/decklink_dec: Extract 1080i and NTSC VANC

2018-01-28 Thread Marton Balint


On Thu, 25 Jan 2018, Ray Tiley wrote:


On Tue, Jan 23, 2018 at 9:07 AM Devin Heitmueller <
dheitmuel...@ltnglobal.com> wrote:


Hi Ray,


On Jan 22, 2018, at 11:20 PM, Ray Tiley  wrote:

I'm reading 334-1:2017 Sec 4
"When the ANC packets defined in this standard are carried in a high
definition signal, they shall be carried in the Y stream."

I couldn't find anywhere in the document where it calls out standard
definition


Right, so my understanding was that allowing the ability to use both luma
and chroma was a result of having less space in the VANC to hold data,
compared to HD resolutions where that is much less likely to be an issue.
That said, I’ve never seen an implementation that actually puts it in the
chroma.



Conversation is here:
https://video-dev.slack.com/archives/C0XKDDH5Y/p151614155574 <

https://video-dev.slack.com/archives/C0XKDDH5Y/p151614155574> with

kier...@obe.tv  who I believe is in the

ffmpeg-devel IRC.




Ah, ok.  That’s Kieran.  He’s really knowledgable in this area, although I
cannot see the conversation you’ve linked to as it seems that room is only
accessible by people with email accounts from certain domains.

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



Please find updated patch attatched. I reverted the vanc lines changes and
found that all my tests worked as expected, so not sure what was wrong w/
my original test. The need to extract vanc from the entire line vs just the
luma in NTSC is still required.


Is interleaved VANC data is always the case for SD NTSC, or it depends on 
the equipment? Maybe we should add some auto detection, and check for the 
first VANC header. E.g.


if (ctx->bmd_mode == bmdModeNTSC &&
(*(uint32_t*)buf & 0x3 == 0x3fc00))
unpack_v210 
else

unpack_luma_v210

Also, later on in the code, you only parse half of the decoded VANC. 
If you decode from both the luma and chroma, get_metadata should be called 
with frame width*2, no?


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


Re: [FFmpeg-devel] avfilter/x86/vf_blend : add avx2 for 8b func (v2)

2018-01-28 Thread Martin Vignali
2018-01-17 21:13 GMT+01:00 Martin Vignali :

> Hello,
>
>
> New patch in attach
>
> with modification in average, grain extract, multiply, screen, grain merge
>
>
> -- blend Average --
> Prev patch :
> average_c: 15605.4
> average_sse2: 1205.9
> average_avx2: 772.4
>
> New patch :
> average_c: 15604.4
> average_sse2: 490.9
> average_avx2: 265.2
>
> With 3 operand :
> using
> %if cpuflag(avx)
> pxor m0, m2, [topq + xq]
> pxor m1, m2, [bottomq + xq]
> %else
> movu   m0, [topq + xq]
> movu   m1, [bottomq + xq]
> pxor   m0, m2
> pxor   m1, m2
> %endif
>
> average_c: 15615.5
> average_sse2: 456.2
> average_avx: 553.7
> average_avx2: 387.0
>
>
> And for grain extract, multiply, screen, grain merge
> using mmsize process at each loop (instead of mmsize / 2)
>
> -- Grain extract --
> Prev :
> grainextract_c: 22182.9
> grainextract_sse2: 1158.9
> grainextract_avx2: 777.6
>
> New :
> grainextract_c: 22206.5
> grainextract_sse2: 964.8
> grainextract_avx2: 485.3
>
> -- Multiply --
> Prev :
> multiply_c: 41347.8
> multiply_sse2: 1376.0
> multiply_avx2: 840.0
>
> New :
> multiply_c: 40432.5
> multiply_sse2: 1248.0
> multiply_avx2: 635.0
>
> -- Screen --
> Prev :
> screen_c: 21635.8
> screen_sse2: 1801.5
> screen_avx2: 1069.8
>
> New :
> screen_c: 21617.0
> screen_sse2: 1625.7
> screen_avx2: 840.2
>
> -- Grain merge --
> Prev :
> grainmerge_c: 25233.5
> grainmerge_sse2: 1158.0
> grainmerge_avx2: 775.7
>
> New :
> grainmerge_c: 25246.7
> grainmerge_sse2: 967.4
> grainmerge_avx2: 487.7
>
>
> Martin
>

Pushed

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


Re: [FFmpeg-devel] avcodec/utvideoenc : add SIMD (SSSE3) for sub_left_pred

2018-01-28 Thread Martin Vignali
2018-01-14 14:31 GMT+01:00 Martin Vignali :

> Hello,
>
> new patch in attach
> no more segfault if i remove movsxdifnidn, after change in the 
> "declare_func_emms"
> part
>
> I also modify the checkasm test, following your comments
>
> Martin
>
> Pushed

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


Re: [FFmpeg-devel] [PATCHv3] mpeg4video: Add support for MPEG-4 Simple Studio Profile.

2018-01-28 Thread Kieran Kunhya
Possibly fixed by below patch but frankly the ER code is impenetrable.

Kieran


0001-mpeg4video-Add-support-for-MPEG-4-Simple-Studio-Prof.patch
Description: Binary data
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 3/3] avcodec/mpeg4videodec: Avoid possibly aliasing violating casts

2018-01-28 Thread Michael Niedermayer
On Sun, Jan 28, 2018 at 03:13:44AM +, Kieran Kunhya wrote:
> All 3 ok.

will apply

thx

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

Take away the freedom of one citizen and you will be jailed, take away
the freedom of all citizens and you will be congratulated by your peers
in Parliament.


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


Re: [FFmpeg-devel] [PATCHv3 4/4] avfilter/vf_framerate: add SIMD functions for frame blending

2018-01-28 Thread Marton Balint


On Sat, 20 Jan 2018, Marton Balint wrote:


Blend function speedups on x86_64 Core i5 4460:

ffmpeg -f lavfi -i allyuv -vf framerate=60:threads=1 -f null none

C: 447548411 decicycles in Blend,2048 runs,  0 skips
SSSE3: 130020087 decicycles in Blend,2048 runs,  0 skips
AVX2:  128508221 decicycles in Blend,2048 runs,  0 skips

ffmpeg -f lavfi -i allyuv -vf format=yuv420p12,framerate=60:threads=1 -f null 
none

C: 228932745 decicycles in Blend,2048 runs,  0 skips
SSE4:  123357781 decicycles in Blend,2048 runs,  0 skips
AVX2:  121215353 decicycles in Blend,2048 runs,  0 skips

Signed-off-by: Marton Balint 
---
libavfilter/framerate.h |  74 
libavfilter/vf_framerate.c  |  70 +--
libavfilter/x86/Makefile|   2 +
libavfilter/x86/vf_framerate.asm| 134 
libavfilter/x86/vf_framerate_init.c |  43 
5 files changed, 269 insertions(+), 54 deletions(-)
create mode 100644 libavfilter/framerate.h
create mode 100644 libavfilter/x86/vf_framerate.asm
create mode 100644 libavfilter/x86/vf_framerate_init.c



Pushed the series.

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


Re: [FFmpeg-devel] [PATCHv3] mpeg4video: Add support for MPEG-4 Simple Studio Profile.

2018-01-28 Thread Carl Eugen Hoyos
2018-01-28 16:36 GMT+01:00 Kieran Kunhya :
> Patch updated to fix threading related crashes, thanks to Paul Mahol for
> assistance.
> Also fix segfaults on cut files by disabling unchecked bitstream reading.

Works as expected with ffmpeg, crashes now with ffplay both with and
without --disable-pthreads, backtrace below.
(The initial issue "concealing 8159 DC, 8159 AC, 8159 MV errors in I frame"
is the same as before, error concealment crashes now.)
Please ignore if you believe this can be SDL-related.

Carl Eugen

(gdb) r A003C002_SR_Lite_23.98p.mxf
Starting program: ffplay_g A003C002_SR_Lite_23.98p.mxf
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
ffplay version N-89861-g78e884f Copyright (c) 2003-2018 the FFmpeg developers
  built with gcc 6.3.0 (GCC)
  configuration: --disable-asm --disable-pthreads
  libavutil  56.  7.100 / 56.  7.100
  libavcodec 58.  9.100 / 58.  9.100
  libavformat58.  5.100 / 58.  5.100
  libavdevice58.  0.101 / 58.  0.101
  libavfilter 7. 11.101 /  7. 11.101
  libswscale  5.  0.101 /  5.  0.101
  libswresample   3.  0.101 /  3.  0.101
[New Thread 0x7515c700 (LWP 13019)]
Detaching after fork from child process 13020.
[New Thread 0x70bf1700 (LWP 13021)]
[Thread 0x70bf1700 (LWP 13021) exited]
[New Thread 0x70bf1700 (LWP 13022)]
[New Thread 0x7fffeba2f700 (LWP 13023)]
[mpeg4 @ 0x7fffe40085a0] Warning: not compiled with thread support,
using thread emulation
[pcm_s24le @ 0x7fffe4011440] Warning: not compiled with thread
support, using thread emulation
[pcm_s24le @ 0x7fffe40121f0] Warning: not compiled with thread
support, using thread emulation
[pcm_s24le @ 0x7fffe4012fd0] Warning: not compiled with thread
support, using thread emulation
[pcm_s24le @ 0x7fffe4013d60] Warning: not compiled with thread
support, using thread emulation
[pcm_s24le @ 0x7fffe4014b50] Warning: not compiled with thread
support, using thread emulation
[pcm_s24le @ 0x7fffe40158e0] Warning: not compiled with thread
support, using thread emulation
[pcm_s24le @ 0x7fffe40166e0] Warning: not compiled with thread
support, using thread emulation
[pcm_s24le @ 0x7fffe4017450] Warning: not compiled with thread
support, using thread emulation
Input #0, mxf, from 'A003C002_SR_Lite_23.98p.mxf':
  Metadata:
product_uid : cede1104-8280-11de-8a39-08004678031c
uid : 85d675bf-65d1-4ba2-826f-58ce7ec69f96
generation_uid  : 67cf5495-0583-43e4-9af1-ccc6a968f407
company_name: Sony
product_name: Mem
product_version : 1.0
application_platform: Sony MXF Development Kit (MacOS X)
modification_date: 2013-10-26T19:05:30.00Z
material_package_umid:
0x060A2B340101010501010D4313002314A5CB916505CE08004602026A87CD
timecode: 00:04:47:12
  Duration: 00:00:11.68, start: 0.00, bitrate: 191718 kb/s
Stream #0:0: Video: mpeg4 (Simple Studio Profile),
yuv422p10le(progressive), 1920x1088 [SAR 1:1 DAR 30:17], SAR 136:135
DAR 16:9, 23.98 fps, 23.98 tbr, 23.98 tbn, 23.98 tbc
Metadata:
  file_package_umid:
0x060A2B340101010501010D4313002414A5CB916505CE08004602026A87CD
  file_package_name:/
Stream #0:1: Audio: pcm_s24le, 48000 Hz, 1 channels, s32 (24 bit), 1152 kb/s
Metadata:
  file_package_umid:
0x060A2B340101010501010D4313002414A5CB916505CE08004602026A87CD
  file_package_name:/
Stream #0:2: Audio: pcm_s24le, 48000 Hz, 1 channels, s32 (24 bit), 1152 kb/s
Metadata:
  file_package_umid:
0x060A2B340101010501010D4313002414A5CB916505CE08004602026A87CD
  file_package_name:/
Stream #0:3: Audio: pcm_s24le, 48000 Hz, 1 channels, s32 (24 bit), 1152 kb/s
Metadata:
  file_package_umid:
0x060A2B340101010501010D4313002414A5CB916505CE08004602026A87CD
  file_package_name:/
Stream #0:4: Audio: pcm_s24le, 48000 Hz, 1 channels, s32 (24 bit), 1152 kb/s
Metadata:
  file_package_umid:
0x060A2B340101010501010D4313002414A5CB916505CE08004602026A87CD
  file_package_name:/
Stream #0:5: Audio: pcm_s24le, 48000 Hz, 1 channels, s32 (24 bit), 1152 kb/s
Metadata:
  file_package_umid:
0x060A2B340101010501010D4313002414A5CB916505CE08004602026A87CD
  file_package_name:/
Stream #0:6: Audio: pcm_s24le, 48000 Hz, 1 channels, s32 (24 bit), 1152 kb/s
Metadata:
  file_package_umid:
0x060A2B340101010501010D4313002414A5CB916505CE08004602026A87CD
  file_package_name:/
Stream #0:7: Audio: pcm_s24le, 48000 Hz, 1 channels, s32 (24 bit), 1152 kb/s
Metadata:
  file_package_umid:
0x060A2B340101010501010D4313002414A5CB916505CE08004602026A87CD
  file_package_name:/
Stream #0:8: Audio: pcm_s24le, 48000 Hz, 1 channels, s32 (24 bit), 1152 kb/s
Metadata:
  file_package_umid:
0x060A2B340101010501010D4313002414A5CB916505CE08004602026A87CD
  file_package_name:/
Stream #0:9: Data: none
 

Re: [FFmpeg-devel] [PATCHv3] mpeg4video: Add support for MPEG-4 Simple Studio Profile.

2018-01-28 Thread Michael Niedermayer
On Sun, Jan 28, 2018 at 03:36:47PM +, Kieran Kunhya wrote:
> Patch updated to fix threading related crashes, thanks to Paul Mahol for
> assistance.

> Also fix segfaults on cut files by disabling unchecked bitstream reading.

if unchecked bitstream reading segfaults then you are probably missing
error checks.
mpeg4 does not allow arbitrary long runs of zeros, and there are zeros in the
padding at the end of the bitstream so this should trigger an error as a
long all zero code would never be valid

Looking at the code i see that in teh DPCM branch check_marker() failure is 
ignored.
That could lead to a overread and segfault

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

What does censorship reveal? It reveals fear. -- Julian Assange


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


Re: [FFmpeg-devel] [PATCHv3] mpeg4video: Add support for MPEG-4 Simple Studio Profile.

2018-01-28 Thread Kieran Kunhya
Patch updated to fix threading related crashes, thanks to Paul Mahol for
assistance.
Also fix segfaults on cut files by disabling unchecked bitstream reading.

Kieran


0001-mpeg4video-Add-support-for-MPEG-4-Simple-Studio-Prof.patch
Description: Binary data
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avformat/mpegenc - fix PCM 16BE muxing and disallow, unsupported audio codecs

2018-01-28 Thread Michael Niedermayer
On Fri, Jan 26, 2018 at 07:30:10PM +0530, Gyan Doshi wrote:
>  mpegenc.c |   27 +--
>  1 file changed, 21 insertions(+), 6 deletions(-)
> fcea723cb22ab82ae2cbac686716a824ff08aabd  
> 0001-avformat-mpegenc-fix-PCM-16BE-muxing-and-disallow-un.patch
> From 7c31072230e392ca8be218df4a1f5a2c1b5d Mon Sep 17 00:00:00 2001
> From: Gyan Doshi 
> Date: Fri, 26 Jan 2018 19:15:28 +0530
> Subject: [PATCH] avformat/mpegenc - fix PCM 16BE muxing and disallow
>  unsupported audio codecs
> 
> PCM_S16BE streams in MPEG-PS are recognized as PCM_DVD by the demuxer
> which prevents their proper remuxing in MPEG-1/2 PS.
> 
> In addition, the muxer only supports five audio codecs but will silently
> go ahead and process any codec. Demuxing of these other streams fails.
> 
> Couple of error messages added and one error typo (VBV size) corrected.

This sounds like multiple independant changes and issues
please split the patch, one patch per issue

thx

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

Those who would give up essential Liberty, to purchase a little
temporary Safety, deserve neither Liberty nor Safety -- Benjamin Franklin


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


Re: [FFmpeg-devel] [PATCH 1/2] avfilter/vf_transpose: Fix regression with packed pixel formats

2018-01-28 Thread Michael Niedermayer
On Sun, Jan 28, 2018 at 01:55:01PM +0100, Paul B Mahol wrote:
> On 1/28/18, Michael Niedermayer  wrote:
> > Regression since: c6939f65a116b1ffed345d29d8621ee4ffb32235
> > Found-by: Paul B Mahol 
> > Signed-off-by: Michael Niedermayer 
> > ---
> >  libavfilter/vf_transpose.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/libavfilter/vf_transpose.c b/libavfilter/vf_transpose.c
> > index 1e1a5c4b89..3ff4cb4249 100644
> > --- a/libavfilter/vf_transpose.c
> > +++ b/libavfilter/vf_transpose.c
> > @@ -217,7 +217,7 @@ static int config_props_output(AVFilterLink *outlink)
> >
> >  s->hsub = desc_in->log2_chroma_w;
> >  s->vsub = desc_in->log2_chroma_h;
> > -s->planes = desc_in->nb_components;
> > +s->planes = av_pix_fmt_count_planes(outlink->format);
> >
> >  av_assert0(desc_in->nb_components == desc_out->nb_components);
> 
> lgtm

will apply

thanks

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

He who knows, does not speak. He who speaks, does not know. -- Lao Tsu


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


Re: [FFmpeg-devel] [PATCH] avcodec/nvenc: refcount input frame mappings

2018-01-28 Thread Timo Rothenpieler

applied together with some other minor fixes.

Also backported to 3.4 and 3.3, as it fixes a crash.



smime.p7s
Description: S/MIME Cryptographic Signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 1/2] avfilter/vf_transpose: Fix regression with packed pixel formats

2018-01-28 Thread Paul B Mahol
On 1/28/18, Michael Niedermayer  wrote:
> Regression since: c6939f65a116b1ffed345d29d8621ee4ffb32235
> Found-by: Paul B Mahol 
> Signed-off-by: Michael Niedermayer 
> ---
>  libavfilter/vf_transpose.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libavfilter/vf_transpose.c b/libavfilter/vf_transpose.c
> index 1e1a5c4b89..3ff4cb4249 100644
> --- a/libavfilter/vf_transpose.c
> +++ b/libavfilter/vf_transpose.c
> @@ -217,7 +217,7 @@ static int config_props_output(AVFilterLink *outlink)
>
>  s->hsub = desc_in->log2_chroma_w;
>  s->vsub = desc_in->log2_chroma_h;
> -s->planes = desc_in->nb_components;
> +s->planes = av_pix_fmt_count_planes(outlink->format);
>
>  av_assert0(desc_in->nb_components == desc_out->nb_components);

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


Re: [FFmpeg-devel] [PATCH] avfilter/vf_transpose: Fix regression with packed pixel formats

2018-01-28 Thread Michael Niedermayer
On Sat, Jan 27, 2018 at 11:24:36PM -0300, James Almer wrote:
> On 1/27/2018 10:50 PM, Michael Niedermayer wrote:
> > Regression since: c6939f65a116b1ffed345d29d8621ee4ffb32235
> > Found-by: Paul B Mahol 
> > Signed-off-by: Michael Niedermayer 
> > ---
> >  libavfilter/vf_transpose.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/libavfilter/vf_transpose.c b/libavfilter/vf_transpose.c
> > index 1e1a5c4b89..bf2ab7eb18 100644
> > --- a/libavfilter/vf_transpose.c
> > +++ b/libavfilter/vf_transpose.c
> > @@ -217,7 +217,7 @@ static int config_props_output(AVFilterLink *outlink)
> >  
> >  s->hsub = desc_in->log2_chroma_w;
> >  s->vsub = desc_in->log2_chroma_h;
> > -s->planes = desc_in->nb_components;
> > +s->planes = (desc_in->flags & AV_PIX_FMT_FLAG_PLANAR) ? 
> > desc_in->nb_components : 1;
> >  
> >  av_assert0(desc_in->nb_components == desc_out->nb_components);
> 
> If there are currently no tests for this filter (or at least not for
> packet formats), then one should be added.

patch posted that tests transpose more completely pixel format wise

thanks


[...]
-- 
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
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 1/2] avfilter/vf_transpose: Fix regression with packed pixel formats

2018-01-28 Thread Michael Niedermayer
Regression since: c6939f65a116b1ffed345d29d8621ee4ffb32235
Found-by: Paul B Mahol 
Signed-off-by: Michael Niedermayer 
---
 libavfilter/vf_transpose.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavfilter/vf_transpose.c b/libavfilter/vf_transpose.c
index 1e1a5c4b89..3ff4cb4249 100644
--- a/libavfilter/vf_transpose.c
+++ b/libavfilter/vf_transpose.c
@@ -217,7 +217,7 @@ static int config_props_output(AVFilterLink *outlink)
 
 s->hsub = desc_in->log2_chroma_w;
 s->vsub = desc_in->log2_chroma_h;
-s->planes = desc_in->nb_components;
+s->planes = av_pix_fmt_count_planes(outlink->format);
 
 av_assert0(desc_in->nb_components == desc_out->nb_components);
 
-- 
2.16.1

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


[FFmpeg-devel] [PATCH 2/2] fate: test the transpose filter more fully

2018-01-28 Thread Michael Niedermayer
Signed-off-by: Michael Niedermayer 
---
 tests/fate/filter-video.mak |   3 +
 tests/ref/fate/filter-pixfmts-transpose | 108 
 2 files changed, 111 insertions(+)
 create mode 100644 tests/ref/fate/filter-pixfmts-transpose

diff --git a/tests/fate/filter-video.mak b/tests/fate/filter-video.mak
index bf6e2c6f84..221ae81fdc 100644
--- a/tests/fate/filter-video.mak
+++ b/tests/fate/filter-video.mak
@@ -684,6 +684,9 @@ fate-filter-pixfmts-tinterlace_pad: CMD = pixfmts "pad"
 FATE_FILTER_PIXFMTS-$(CONFIG_TINTERLACE_FILTER) += 
fate-filter-pixfmts-tinterlace_vlpf
 fate-filter-pixfmts-tinterlace_vlpf: CMD = pixfmts "interleave_top:vlpf"
 
+FATE_FILTER_PIXFMTS-$(CONFIG_TRANSPOSE_FILTER) += fate-filter-pixfmts-transpose
+fate-filter-pixfmts-transpose: CMD = pixfmts "dir=cclock_flip"
+
 FATE_FILTER_PIXFMTS-$(CONFIG_VFLIP_FILTER) += fate-filter-pixfmts-vflip
 fate-filter-pixfmts-vflip: CMD = pixfmts
 
diff --git a/tests/ref/fate/filter-pixfmts-transpose 
b/tests/ref/fate/filter-pixfmts-transpose
new file mode 100644
index 00..6f25f3dd27
--- /dev/null
+++ b/tests/ref/fate/filter-pixfmts-transpose
@@ -0,0 +1,108 @@
+0bgr6929c1e308d2f4f941d002627047d262
+0rgbcf1bedd0784a3efd3ab00c4e44005c37
+abgr6d6f896f853a6c6f93ee70dba9af3d17
+argb87bbd23debb94d486ac3a6b6c0b005f9
+ayuv64lee4c07e0d5b333b3bc9eb4f3ce6af3a2c
+bgr0df3a6eedd4939ce09a357b655ac2962a
+bgr24   f9a08135e5d58c0b2a5509c369a88414
+bgr444bedd9e990a327649ec0b2b81a8ee4d8f49
+bgr444lebee1d9fae8733d0c0669bca2ac4dfaf6
+bgr48be 39f48f6353dfc772af36cbb41e6126a4
+bgr48le 9a61d9531b1f6de44b27f6bb9b4dfc79
+bgr4_byte   ddff9da461afce90e3122a41d79b287d
+bgr555be24e5c6502a6d927f8ba88f3320ebf619
+bgr555le5201d098979ea86a66d8df1ef41c79ad
+bgr565be59afe17b455e921daf428ba05a40bab9
+bgr565leb2709790684abbd2133906b637f2b4b8
+bgr8b6ee15f70989d2f52f184e32b3af2c18
+bgraf2fe61e08446900ad209f2c586997e15
+bgra64be8d01994c8c32e628fcf9749851f1ffe8
+bgra64lefaaef6d280f92e7e8abdd9fa4a61f7b5
+gbrap   0899b3af50d35a63bfecb419a5b29968
+gbrap10be   3e3be2d8f9aa5f449a1df404e27d0054
+gbrap10le   db4e4861010cbbf726492fad282d5813
+gbrap12be   1518c9a565d1ba1a45dd369acc1aa75e
+gbrap12le   714fe318af81a46f83655c6e7e13351e
+gbrap16be   39d488528aacff466aac7539c9b948a8
+gbrap16le   5426ac9457289927bfe2ec03038a8780
+gbrp7b4b6a2f1cdc51455b25515c3ecea944
+gbrp10bed7401725699b2ddf954caa16a0878a1e
+gbrp10le6036711969eae1979be6358f688bd9c8
+gbrp12beec7d6e69fc579619b53d57a76c20480d
+gbrp12lebf7478185274486c3f7dd4db1da8f7d0
+gbrp14be9b66f22e4315aaa878a430ae3f44ab57
+gbrp14le16f30349b42dca007b37b8522d3018df
+gbrp16be0d003b88d4f446ae9ba12cab1cbb359a
+gbrp16lea1c09038fa4636c9843ab8dd2b7601ea
+gbrp9be df381b4b27be25d172fa556434478807
+gbrp9le a5301e978f68b29bfc613b2462ec4888
+grayc5f8bc6636fd15dbc57deb4bba1e7379
+gray10be48b421da79c195fd91dffb8fca79a8a2
+gray10le7774e3296916b896afa46f626334a280
+gray12be89f1c4b7821b771f6d967f9db871f8ef
+gray12le43d392c3dcbd79b47cce31f2006c5050
+gray16be4aef307021a91b1de67f1d4381a39132
+gray16le76f2afe156edca7ae05cfa4e5867126e
+gray9be 2c425fa532c940d226822da8b3592310
+gray9le bcc575942910b3c72eaa72e8794f3acd
+nv12aca847644e5dc0e942419183014981a4
+nv21098884e968d27286c8cf0d2fb1557dcd
+p010be  5ff62dffa5dfdf823978c4f563f69c94
+p010le  20131abe34e084b04f1d169c66447825
+rgb031ea5da7fe779c6ea0a33f1d28aad918
+rgb24   47654cabaaad79170b90afd5a02161dd
+rgb444be3cac1f0c43a74d2a95eb02e187070845
+rgb444le46d602468bd9e5a430622e3d4b7c8f40
+rgb48be 400932419bbb780614254253ef5591c3
+rgb48le 6a99c40f21629cb0655e8772d7190374
+rgb4_byte   d3990da196266305a3f2e5b1d72401a5
+rgb555be79e4503ff0d5cf52d3a7901397499a28
+rgb555lec65f2594c0b3107a322f7aeb81aa8a16
+rgb565be0c746b5063d02d6cb98e9e9a59ad3b99
+rgb565le63b02db11c3d20be54d218c7c44f8ddb
+rgb8c90feb30c3c9391ef5f470209d7b7a15
+rgba4d76a9542143752a4ac30f82f88f68f1
+rgba64bea60041217f4c0cd796d19d3940a12a41
+rgba64lead47197774858858ae7b0c177dffa459
+xyz12be 68e5cba640f6e4ef72dff950e88b5342
+xyz12le 8b6b6a6db4d7561e80db88ccaecce7a9
+ya8 d4b7a62f80681fa44c977ff3a64f4ce4
+yuv410p 4c0143429edd30aa01493447c90132ea
+yuv420p 2fa5b2201c75034206cc20e2c613

Re: [FFmpeg-devel] [PATCH] avfilter/vf_transpose: Fix regression with packed pixel formats

2018-01-28 Thread Michael Niedermayer
On Sun, Jan 28, 2018 at 10:12:19AM +0100, Paul B Mahol wrote:
> On 1/28/18, Michael Niedermayer  wrote:
> > Regression since: c6939f65a116b1ffed345d29d8621ee4ffb32235
> > Found-by: Paul B Mahol 
> > Signed-off-by: Michael Niedermayer 
> > ---
> >  libavfilter/vf_transpose.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/libavfilter/vf_transpose.c b/libavfilter/vf_transpose.c
> > index 1e1a5c4b89..bf2ab7eb18 100644
> > --- a/libavfilter/vf_transpose.c
> > +++ b/libavfilter/vf_transpose.c
> > @@ -217,7 +217,7 @@ static int config_props_output(AVFilterLink *outlink)
> >
> >  s->hsub = desc_in->log2_chroma_w;
> >  s->vsub = desc_in->log2_chroma_h;
> > -s->planes = desc_in->nb_components;
> > +s->planes = (desc_in->flags & AV_PIX_FMT_FLAG_PLANAR) ?
> > desc_in->nb_components : 1;
> >
> >  av_assert0(desc_in->nb_components == desc_out->nb_components);
> >
> > --
> > 2.16.1
> >
> > ___
> > ffmpeg-devel mailing list
> > ffmpeg-devel@ffmpeg.org
> > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> >
> 
> There is function that count number of planes.

yes, just realized that too, i will change the code to use that

thx

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

He who knows, does not speak. He who speaks, does not know. -- Lao Tsu


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


[FFmpeg-devel] [PATCH v2 1/2] aadec: improve eof detection

2018-01-28 Thread Karsten Otto
Remember the end position of audio content in the file and check it during
read_packet. There always seems to be other data beyond it, which could be
misinterpreted as more audio. Also add some extra avio_read error checks,
to bail early in case of a broken/truncated file.
---
Update addresses comment by Michael Niedermayer, forwarding avio_read errors
to the caller.

 libavformat/aadec.c | 15 +--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/libavformat/aadec.c b/libavformat/aadec.c
index 8d39b1d9ba..4db71b1939 100644
--- a/libavformat/aadec.c
+++ b/libavformat/aadec.c
@@ -46,6 +46,7 @@ typedef struct AADemuxContext {
 struct AVTEA *tea_ctx;
 uint8_t file_key[16];
 int64_t current_chapter_size;
+int64_t content_end;
 } AADemuxContext;
 
 static int get_second_size(char *codec_name)
@@ -197,6 +198,7 @@ static int aa_read_header(AVFormatContext *s)
 }
 start = TOC[largest_idx].offset;
 avio_seek(pb, start, SEEK_SET);
+c->content_end = start + largest_size;
 c->current_chapter_size = 0;
 
 return 0;
@@ -214,6 +216,11 @@ static int aa_read_packet(AVFormatContext *s, AVPacket 
*pkt)
 int ret;
 AADemuxContext *c = s->priv_data;
 
+// are we at the end of the audio content?
+if (avio_tell(s->pb) >= c->content_end) {
+return AVERROR_EOF;
+}
+
 // are we at the start of a chapter?
 if (c->current_chapter_size == 0) {
 c->current_chapter_size = avio_rb32(s->pb);
@@ -234,7 +241,9 @@ static int aa_read_packet(AVFormatContext *s, AVPacket *pkt)
 // decrypt c->current_codec_second_size bytes
 blocks = c->current_codec_second_size / TEA_BLOCK_SIZE;
 for (i = 0; i < blocks; i++) {
-avio_read(s->pb, src, TEA_BLOCK_SIZE);
+ret = avio_read(s->pb, src, TEA_BLOCK_SIZE);
+if (ret != TEA_BLOCK_SIZE)
+return (ret < 0) ? ret : AVERROR_EOF;
 av_tea_init(c->tea_ctx, c->file_key, 16);
 av_tea_crypt(c->tea_ctx, dst, src, 1, NULL, 1);
 memcpy(buf + written, dst, TEA_BLOCK_SIZE);
@@ -242,7 +251,9 @@ static int aa_read_packet(AVFormatContext *s, AVPacket *pkt)
 }
 trailing_bytes = c->current_codec_second_size % TEA_BLOCK_SIZE;
 if (trailing_bytes != 0) { // trailing bytes are left unencrypted!
-avio_read(s->pb, src, trailing_bytes);
+ret = avio_read(s->pb, src, trailing_bytes);
+if (ret != trailing_bytes)
+return (ret < 0) ? ret : AVERROR_EOF;
 memcpy(buf + written, src, trailing_bytes);
 written = written + trailing_bytes;
 }
-- 
2.14.3 (Apple Git-98)

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


[FFmpeg-devel] [PATCH v2 2/2] aadec: add chapters and seeking

2018-01-28 Thread Karsten Otto
read_packet reads content in chunks. Thus seek must be clamped to valid
chunk positions in the file, which in turn are relative to chapter start
positions.

So in read_header, scan for chapter headers once by skipping through the
content. Set stream time_base to bitrate in bytes/s, for easy timestamp to
position conversion.

Then in read_seek, find the chapter containing the seek position, calculate
the nearest chunk position, and reinit the read_seek state accordingly.
---
Update addresses comment by wm4, honoring AVSEEK_FLAG_BACKWARD when seeking.

 libavformat/aadec.c | 80 +++--
 1 file changed, 77 insertions(+), 3 deletions(-)

diff --git a/libavformat/aadec.c b/libavformat/aadec.c
index 4db71b1939..d0123da264 100644
--- a/libavformat/aadec.c
+++ b/libavformat/aadec.c
@@ -35,6 +35,7 @@
 #define MAX_TOC_ENTRIES 16
 #define MAX_DICTIONARY_ENTRIES 128
 #define TEA_BLOCK_SIZE 8
+#define CHAPTER_HEADER_SIZE 8
 
 typedef struct AADemuxContext {
 AVClass *class;
@@ -46,6 +47,7 @@ typedef struct AADemuxContext {
 struct AVTEA *tea_ctx;
 uint8_t file_key[16];
 int64_t current_chapter_size;
+int64_t content_start;
 int64_t content_end;
 } AADemuxContext;
 
@@ -70,7 +72,7 @@ static int aa_read_header(AVFormatContext *s)
 uint32_t nkey, nval, toc_size, npairs, header_seed = 0, start;
 char key[128], val[128], codec_name[64] = {0};
 uint8_t output[24], dst[8], src[8];
-int64_t largest_size = -1, current_size = -1;
+int64_t largest_size = -1, current_size = -1, chapter_pos;
 struct toc_entry {
 uint32_t offset;
 uint32_t size;
@@ -172,19 +174,23 @@ static int aa_read_header(AVFormatContext *s)
 if (!strcmp(codec_name, "mp332")) {
 st->codecpar->codec_id = AV_CODEC_ID_MP3;
 st->codecpar->sample_rate = 22050;
+st->time_base = av_make_q(8, 32000);
 st->need_parsing = AVSTREAM_PARSE_FULL_RAW;
-st->start_time = 0;
 } else if (!strcmp(codec_name, "acelp85")) {
 st->codecpar->codec_id = AV_CODEC_ID_SIPR;
 st->codecpar->block_align = 19;
 st->codecpar->channels = 1;
 st->codecpar->sample_rate = 8500;
+st->codecpar->bit_rate = 8500;
+st->time_base = av_make_q(8, 8500);
 st->need_parsing = AVSTREAM_PARSE_FULL_RAW;
 } else if (!strcmp(codec_name, "acelp16")) {
 st->codecpar->codec_id = AV_CODEC_ID_SIPR;
 st->codecpar->block_align = 20;
 st->codecpar->channels = 1;
 st->codecpar->sample_rate = 16000;
+st->codecpar->bit_rate = 16000;
+st->time_base = av_make_q(8, 16000);
 st->need_parsing = AVSTREAM_PARSE_FULL_RAW;
 }
 
@@ -198,7 +204,30 @@ static int aa_read_header(AVFormatContext *s)
 }
 start = TOC[largest_idx].offset;
 avio_seek(pb, start, SEEK_SET);
+
+// extract chapter positions. since all formats have constant bit rate, 
use it
+// as time base in bytes/s, for easy stream position <-> timestamp 
conversion
+st->start_time = 0;
+c->content_start = start;
 c->content_end = start + largest_size;
+
+while ((chapter_pos = avio_tell(pb)) >= 0 && chapter_pos < c->content_end) 
{
+int chapter_idx, chapter_size;
+chapter_idx = s->nb_chapters;
+chapter_pos -= start + CHAPTER_HEADER_SIZE * chapter_idx;
+chapter_size = avio_rb32(pb);
+if (chapter_size == 0) break;
+avio_skip(pb, 4);
+avio_skip(pb, chapter_size);
+if (!avpriv_new_chapter(s, chapter_idx, st->time_base,
+chapter_pos, chapter_pos + chapter_size, NULL))
+return AVERROR(ENOMEM);
+}
+
+st->duration = largest_size - CHAPTER_HEADER_SIZE * s->nb_chapters;
+
+ff_update_cur_dts(s, st, 0);
+avio_seek(pb, start, SEEK_SET);
 c->current_chapter_size = 0;
 
 return 0;
@@ -271,6 +300,50 @@ static int aa_read_packet(AVFormatContext *s, AVPacket 
*pkt)
 return 0;
 }
 
+static int aa_read_seek(AVFormatContext *s,
+int stream_index, int64_t timestamp, int flags)
+{
+AADemuxContext *c = s->priv_data;
+AVChapter *ch;
+int64_t chapter_pos, chapter_start, chapter_size;
+int chapter_idx = 0;
+
+// find chapter containing seek timestamp
+if (timestamp < 0)
+timestamp = 0;
+
+while (chapter_idx < s->nb_chapters && timestamp >= 
s->chapters[chapter_idx]->end) {
+++chapter_idx;
+}
+
+if (chapter_idx >= s->nb_chapters) {
+chapter_idx = s->nb_chapters - 1;
+if (chapter_idx < 0) return -1; // there is no chapter.
+timestamp = s->chapters[chapter_idx]->end;
+}
+
+ch = s->chapters[chapter_idx];
+
+// sync by clamping timestamp to nearest valid block position in its 
chapter
+chapter_size = ch->end - ch->start;
+chapter_pos = av_rescale_rnd(timestamp - ch->start, 1, 
c->codec_second_size,
+(flags & AVSEEK_FLAG_BACKWARD) ? AV_ROUND_DOWN : AV_ROUND_UP

Re: [FFmpeg-devel] [PATCH] dashdec: Fix segfault on decoding segment timeline

2018-01-28 Thread Steven Liu

> 在 2018年1月28日,上午9:09,Brendan McGrath  写道:
> 
> Just making sure this patch hasn't been overlooked.
> 
> To better explain the existing issue - the value of 'pls->first_seq_no' comes 
> from the 'startNumber' attribute of the 'SegmentTemplate' element.
> 
> The 'pls->timelines' array represents the elements within the 
> 'SegmentTimeline' element.
> 
> So for this example:
>initialization="init-stream$RepresentationID$.m4s" 
> media="chunk-stream$RepresentationID$-$Number%05d$.m4s" startNumber="7">
> 
>   
> 
>   
> 
> 'pls->first_seq_no' will be 7 but the 'pls->timelines' array will only have 
> the one element - hence:
> pls->timelines[pls->first_seq_no]
> 
will apply it
> causes a segfault.
> 
> This patch removes the use of 'pls->first_seq_no' within the 'pls->timelines' 
> array
> 
>> On 20/01/18 18:07, Brendan McGrath wrote:
>> If first_seq_no is not within the bounds of timelines then a segfault
>> will occur.
>> 
>> This patch removes the use of first_seq_no within the timelines array
>> 
>> It also adds first_seq_no to the value returned by 
>> calc_next_seg_no_from_timelines
>> (which allows for different values of 'startNumber')
>> 
>> Signed-off-by: Brendan McGrath 
>> ---
>> 
>> This can be reproduced by creating a dash file with the following command:
>> ffmpeg -i in.ts -f dash -window_size 2 out.mpd
>> 
>> and then after about 10 seconds run ffprobe against it.
>> 
>> The SegementTemplatei of out.mpd will look something like this:
>>   > initialization="init-stream$RepresentationID$.m4s" 
>> media="chunk-stream$RepresentationID$-$Number%05d$.m4s" startNumber="7">
>> 
>>   
>> 
>>   
>> 
>> So the code was trying to access the 7th element within the timeline
>> array (which only had one element).
>> 
>> The patch doesn't worry about checking for a negative value after deducting 
>> the 60
>> seconds as calc_next_seg_no_from_timelines accepts a signed int and works 
>> correctly with
>> negative values.
>> 
>>  libavformat/dashdec.c | 11 ---
>>  1 file changed, 4 insertions(+), 7 deletions(-)
>> 
>> diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c
>> index 2492f1d..cdb7ba5 100644
>> --- a/libavformat/dashdec.c
>> +++ b/libavformat/dashdec.c
>> @@ -1083,15 +1083,12 @@ static int64_t calc_cur_seg_no(AVFormatContext *s, 
>> struct representation *pls)
>>  if (pls->n_fragments) {
>>  num = pls->first_seq_no;
>>  } else if (pls->n_timelines) {
>> -start_time_offset = 
>> get_segment_start_time_based_on_timeline(pls, 0x) - 
>> pls->timelines[pls->first_seq_no]->starttime; // total duration of playlist
>> -if (start_time_offset < 60 * pls->fragment_timescale)
>> -start_time_offset = 0;
>> -else
>> -start_time_offset = start_time_offset - 60 * 
>> pls->fragment_timescale;
>> -
>> -num = calc_next_seg_no_from_timelines(pls, 
>> pls->timelines[pls->first_seq_no]->starttime + start_time_offset);
>> +start_time_offset = 
>> get_segment_start_time_based_on_timeline(pls, 0x) - 60 * 
>> pls->fragment_timescale; // 60 seconds before end
>> +num = calc_next_seg_no_from_timelines(pls, start_time_offset);
>>  if (num == -1)
>>  num = pls->first_seq_no;
>> +else
>> +num += pls->first_seq_no;
>>  } else if (pls->fragment_duration){
>>  if (pls->presentation_timeoffset) {
>>  num = pls->presentation_timeoffset * 
>> pls->fragment_timescale / pls->fragment_duration;
> 



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


Re: [FFmpeg-devel] [PATCH] avfilter/vf_transpose: Fix regression with packed pixel formats

2018-01-28 Thread Nicolas George
James Almer (2018-01-27):
> If there are currently no tests for this filter (or at least not for
> packet formats), then one should be added.
> 
> Lavfi's current fate coverage is unacceptably low. Something like two
> third of the codebase remains untested according to LCOV.
> At this point no software filter should be added without a fate test for
> at least a basic usage example using either the fate generated synthetic
> sources or any samples in the suite. Same with new features for new filters.

I think it is a reasonable requirement.

Regards,

-- 
  Nicolas George


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


Re: [FFmpeg-devel] [PATCH] avfilter/vf_transpose: Fix regression with packed pixel formats

2018-01-28 Thread wm4
On Sun, 28 Jan 2018 10:11:20 +0100
Paul B Mahol  wrote:

> On 1/28/18, James Almer  wrote:
> > On 1/27/2018 10:50 PM, Michael Niedermayer wrote:  
> >> Regression since: c6939f65a116b1ffed345d29d8621ee4ffb32235
> >> Found-by: Paul B Mahol 
> >> Signed-off-by: Michael Niedermayer 
> >> ---
> >>  libavfilter/vf_transpose.c | 2 +-
> >>  1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >> diff --git a/libavfilter/vf_transpose.c b/libavfilter/vf_transpose.c
> >> index 1e1a5c4b89..bf2ab7eb18 100644
> >> --- a/libavfilter/vf_transpose.c
> >> +++ b/libavfilter/vf_transpose.c
> >> @@ -217,7 +217,7 @@ static int config_props_output(AVFilterLink *outlink)
> >>
> >>  s->hsub = desc_in->log2_chroma_w;
> >>  s->vsub = desc_in->log2_chroma_h;
> >> -s->planes = desc_in->nb_components;
> >> +s->planes = (desc_in->flags & AV_PIX_FMT_FLAG_PLANAR) ?
> >> desc_in->nb_components : 1;
> >>
> >>  av_assert0(desc_in->nb_components == desc_out->nb_components);  
> >
> > If there are currently no tests for this filter (or at least not for
> > packet formats), then one should be added.
> >
> > Lavfi's current fate coverage is unacceptably low. Something like two
> > third of the codebase remains untested according to LCOV.
> > At this point no software filter should be added without a fate test for
> > at least a basic usage example using either the fate generated synthetic
> > sources or any samples in the suite. Same with new features for new 
> > filters.  
> 
> That is unacceptable.

Testing code is unacceptable? Excuse me?

The only unacceptable thing is probably the slowdown you can expect
on full fate runs once the coverage reaches 100%.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avfilter/vf_transpose: Fix regression with packed pixel formats

2018-01-28 Thread Paul B Mahol
On 1/28/18, Michael Niedermayer  wrote:
> Regression since: c6939f65a116b1ffed345d29d8621ee4ffb32235
> Found-by: Paul B Mahol 
> Signed-off-by: Michael Niedermayer 
> ---
>  libavfilter/vf_transpose.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libavfilter/vf_transpose.c b/libavfilter/vf_transpose.c
> index 1e1a5c4b89..bf2ab7eb18 100644
> --- a/libavfilter/vf_transpose.c
> +++ b/libavfilter/vf_transpose.c
> @@ -217,7 +217,7 @@ static int config_props_output(AVFilterLink *outlink)
>
>  s->hsub = desc_in->log2_chroma_w;
>  s->vsub = desc_in->log2_chroma_h;
> -s->planes = desc_in->nb_components;
> +s->planes = (desc_in->flags & AV_PIX_FMT_FLAG_PLANAR) ?
> desc_in->nb_components : 1;
>
>  av_assert0(desc_in->nb_components == desc_out->nb_components);
>
> --
> 2.16.1
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>

There is function that count number of planes.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avfilter/vf_transpose: Fix regression with packed pixel formats

2018-01-28 Thread Paul B Mahol
On 1/28/18, James Almer  wrote:
> On 1/27/2018 10:50 PM, Michael Niedermayer wrote:
>> Regression since: c6939f65a116b1ffed345d29d8621ee4ffb32235
>> Found-by: Paul B Mahol 
>> Signed-off-by: Michael Niedermayer 
>> ---
>>  libavfilter/vf_transpose.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/libavfilter/vf_transpose.c b/libavfilter/vf_transpose.c
>> index 1e1a5c4b89..bf2ab7eb18 100644
>> --- a/libavfilter/vf_transpose.c
>> +++ b/libavfilter/vf_transpose.c
>> @@ -217,7 +217,7 @@ static int config_props_output(AVFilterLink *outlink)
>>
>>  s->hsub = desc_in->log2_chroma_w;
>>  s->vsub = desc_in->log2_chroma_h;
>> -s->planes = desc_in->nb_components;
>> +s->planes = (desc_in->flags & AV_PIX_FMT_FLAG_PLANAR) ?
>> desc_in->nb_components : 1;
>>
>>  av_assert0(desc_in->nb_components == desc_out->nb_components);
>
> If there are currently no tests for this filter (or at least not for
> packet formats), then one should be added.
>
> Lavfi's current fate coverage is unacceptably low. Something like two
> third of the codebase remains untested according to LCOV.
> At this point no software filter should be added without a fate test for
> at least a basic usage example using either the fate generated synthetic
> sources or any samples in the suite. Same with new features for new filters.

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