Re: [FFmpeg-devel] [PATCH] avcodec/libopusenc: add option to set inband FEC

2020-09-07 Thread Gyan Doshi

Plan to push in a day.

On 06-09-2020 12:27 pm, Gyan Doshi wrote:

---
  doc/encoders.texi   | 5 +
  libavcodec/libopusenc.c | 9 +
  2 files changed, 14 insertions(+)

diff --git a/doc/encoders.texi b/doc/encoders.texi
index 69bf742c2d..a48b15eb1b 100644
--- a/doc/encoders.texi
+++ b/doc/encoders.texi
@@ -953,6 +953,11 @@ The default is 20ms.
  @item packet_loss (@emph{expect-loss})
  Set expected packet loss percentage. The default is 0.
  
+@item fec (@emph{n/a})

+Enable inband forward error correction. @option{packet_loss} must be non-zero
+to take advantage - frequency of FEC 'side-data' is proportional to expected 
packet loss.
+Default is disabled.
+
  @item application (N.A.)
  Set intended application type. Valid options are listed below:
  
diff --git a/libavcodec/libopusenc.c b/libavcodec/libopusenc.c

index 13017ac323..bf2d04b4fb 100644
--- a/libavcodec/libopusenc.c
+++ b/libavcodec/libopusenc.c
@@ -34,6 +34,7 @@ typedef struct LibopusEncOpts {
  int vbr;
  int application;
  int packet_loss;
+int fec;
  int complexity;
  float frame_duration;
  int packet_size;
@@ -149,6 +150,13 @@ static int libopus_configure_encoder(AVCodecContext 
*avctx, OpusMSEncoder *enc,
 "Unable to set expected packet loss percentage: %s\n",
 opus_strerror(ret));
  
+ret = opus_multistream_encoder_ctl(enc,

+   OPUS_SET_INBAND_FEC(opts->fec));
+if (ret != OPUS_OK)
+av_log(avctx, AV_LOG_WARNING,
+   "Unable to set inband FEC: %s\n",
+   opus_strerror(ret));
+
  if (avctx->cutoff) {
  ret = opus_multistream_encoder_ctl(enc,
 
OPUS_SET_MAX_BANDWIDTH(opts->max_bandwidth));
@@ -544,6 +552,7 @@ static const AVOption libopus_options[] = {
  { "lowdelay",   "Restrict to only the lowest delay modes", 0, 
AV_OPT_TYPE_CONST, { .i64 = OPUS_APPLICATION_RESTRICTED_LOWDELAY }, 0, 0, FLAGS, "application" },
  { "frame_duration", "Duration of a frame in milliseconds", 
OFFSET(frame_duration), AV_OPT_TYPE_FLOAT, { .dbl = 20.0 }, 2.5, 120.0, FLAGS },
  { "packet_loss","Expected packet loss percentage", 
OFFSET(packet_loss),AV_OPT_TYPE_INT,   { .i64 = 0 },0,   100,  FLAGS },
+{ "fec", "Enable inband FEC. Expected packet loss must be 
non-zero", OFFSET(fec),AV_OPT_TYPE_BOOL,   { .i64 = 0 }, 0, 1, FLAGS },
  { "vbr","Variable bit rate mode",  OFFSET(vbr),
AV_OPT_TYPE_INT,   { .i64 = 1 },0,   2,FLAGS, "vbr" },
  { "off","Use constant bit rate", 0, AV_OPT_TYPE_CONST, { .i64 = 0 
}, 0, 0, FLAGS, "vbr" },
  { "on", "Use variable bit rate", 0, AV_OPT_TYPE_CONST, { .i64 = 1 
}, 0, 0, FLAGS, "vbr" },


___
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/5] avcodec: add "Argonaut Games Video" descriptor

2020-09-07 Thread Zane van Iperen
On Mon, 7 Sep 2020 20:15:28 -0300
"James Almer"  wrote:
> 
> You could change the demuxer you submitted to simply skip the video
> track and demux only the audio, which afaik can be decoded by libavcodec.
> If this Argo video codec was supported by some other container then it
> would make sense adding a descriptor for it, as it would allow remuxing.
> But as is, it's probably better not to bother with it.

Fair enough. I would like to keep all the info such as size, pixel
format, etc. (as its still useful information), so I'll use
AV_CODEC_ID_NONE so it's ignored.


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

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

[FFmpeg-devel] [PATCH v2] qsv: add ${includedir}/mfx to the search path for old versions of libmfx

2020-09-07 Thread Haihao Xiang
${includedir}/mfx has been added to Cflags in libmfx.pc in new versions
of libmfx. We may add ${includedir}/mfx to the search path for old
versions of libmfx so that we may inlcude mfxfoo.h instead of
mfx/mfxfoo.h

If your libmfx comes without pkg-config support, this patch requires a
small change to your environment setting (e.g. adding
/opt/intel/mediasdk/include/mfx instead of /opt/intel/mediasdk/include
to CFLAGS) so that the build can find the headers
---
Update the git commit message in this version

 configure| 15 ---
 fftools/ffmpeg_qsv.c |  2 +-
 libavcodec/qsv.c |  8 
 libavcodec/qsv.h |  2 +-
 libavcodec/qsv_internal.h|  2 +-
 libavcodec/qsvdec.c  |  2 +-
 libavcodec/qsvdec.h  |  2 +-
 libavcodec/qsvdec_h2645.c|  2 +-
 libavcodec/qsvdec_other.c|  2 +-
 libavcodec/qsvenc.c  |  2 +-
 libavcodec/qsvenc.h  |  2 +-
 libavcodec/qsvenc_h264.c |  2 +-
 libavcodec/qsvenc_hevc.c |  2 +-
 libavcodec/qsvenc_jpeg.c |  2 +-
 libavcodec/qsvenc_mpeg2.c|  2 +-
 libavcodec/qsvenc_vp9.c  |  2 +-
 libavfilter/qsvvpp.h |  2 +-
 libavfilter/vf_deinterlace_qsv.c |  2 +-
 libavfilter/vf_scale_qsv.c   |  2 +-
 libavutil/hwcontext_opencl.c |  2 +-
 libavutil/hwcontext_qsv.c|  2 +-
 libavutil/hwcontext_qsv.h|  2 +-
 22 files changed, 36 insertions(+), 27 deletions(-)

diff --git a/configure b/configure
index f13d1a8c9a..eb4a0d9822 100755
--- a/configure
+++ b/configure
@@ -1458,6 +1458,14 @@ check_pkg_config(){
 eval add_cflags \$${name}_cflags
 }
 
+append_subdir_to_pkg_includedir(){
+log append_subdir_to_pkg_includedir "$@"
+name="$1"
+subdir="$2"
+incdir=$($pkg_config --variable=includedir $name)
+add_cflags -I$incdir/$subdir
+}
+
 test_exec(){
 test_ld "cc" "$@" && { enabled cross_compile || $TMPE >> $logfile 2>&1; }
 }
@@ -6363,10 +6371,11 @@ enabled liblensfun&& require_pkg_config 
liblensfun lensfun lensfun.h lf_
 # Media SDK or Intel Media Server Studio, these don't come with
 # pkg-config support.  Instead, users should make sure that the build
 # can find the libraries and headers through other means.
-enabled libmfx&& { check_pkg_config libmfx libmfx "mfx/mfxvideo.h" 
MFXInit ||
-   { require libmfx "mfx/mfxvideo.h" MFXInit 
"-llibmfx $advapi32_extralibs" && warn "using libmfx without pkg-config"; } }
+enabled libmfx&& { check_pkg_config libmfx libmfx "mfxvideo.h" 
MFXInit ||
+   { check_pkg_config libmfx libmfx 
"mfx/mfxvideo.h" MFXInit && append_subdir_to_pkg_includedir libmfx mfx; } ||
+   { require libmfx "mfxvideo.h" MFXInit "-llibmfx 
$advapi32_extralibs" && warn "using libmfx without pkg-config"; } }
 if enabled libmfx; then
-   check_cc MFX_CODEC_VP9 "mfx/mfxvp9.h mfx/mfxstructures.h" "MFX_CODEC_VP9"
+   check_cc MFX_CODEC_VP9 "mfxvp9.h mfxstructures.h" "MFX_CODEC_VP9"
 fi
 
 enabled libmodplug&& require_pkg_config libmodplug libmodplug 
libmodplug/modplug.h ModPlug_Load
diff --git a/fftools/ffmpeg_qsv.c b/fftools/ffmpeg_qsv.c
index 960c88b69d..0df0b5832c 100644
--- a/fftools/ffmpeg_qsv.c
+++ b/fftools/ffmpeg_qsv.c
@@ -16,7 +16,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include 
+#include 
 #include 
 
 #include "libavutil/dict.h"
diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c
index 17720070f1..55184e075a 100644
--- a/libavcodec/qsv.c
+++ b/libavcodec/qsv.c
@@ -18,9 +18,9 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include 
-#include 
-#include 
+#include 
+#include 
+#include 
 
 #include 
 #include 
@@ -37,7 +37,7 @@
 #include "qsv_internal.h"
 
 #if QSV_VERSION_ATLEAST(1, 12)
-#include "mfx/mfxvp8.h"
+#include "mfxvp8.h"
 #endif
 
 int ff_qsv_codec_id_to_mfx(enum AVCodecID codec_id)
diff --git a/libavcodec/qsv.h b/libavcodec/qsv.h
index b77158ec26..04ae0d6f34 100644
--- a/libavcodec/qsv.h
+++ b/libavcodec/qsv.h
@@ -21,7 +21,7 @@
 #ifndef AVCODEC_QSV_H
 #define AVCODEC_QSV_H
 
-#include 
+#include 
 
 #include "libavutil/buffer.h"
 
diff --git a/libavcodec/qsv_internal.h b/libavcodec/qsv_internal.h
index 6b2fbbe252..4609e7a53b 100644
--- a/libavcodec/qsv_internal.h
+++ b/libavcodec/qsv_internal.h
@@ -39,7 +39,7 @@
 #include "libavutil/hwcontext_vaapi.h"
 #endif
 
-#include 
+#include 
 
 #include "libavutil/frame.h"
 
diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
index fc25dc73e5..9e319ae709 100644
--- a/libavcodec/qsvdec.c
+++ b/libavcodec/qsvdec.c
@@ -24,7 +24,7 @@
 #include 
 #include 
 
-#include 
+#include 
 
 #include "libavutil/common.h"
 #include "libavutil/hwcontext.h"
diff --git a/libavcodec/qsvdec.h b/libavcodec/qsvdec.h
index cb948f516d..435e8eae3e 100644
--- a/libavcodec/qsvdec.h
+++ 

Re: [FFmpeg-devel] [PATCH v5 2/2] dnn_backend_native_layer_conv2d.c:Add mutithread function

2020-09-07 Thread Guo, Yejun


> -Original Message-
> From: ffmpeg-devel  On Behalf Of
> xuju...@sjtu.edu.cn
> Sent: 2020年9月6日 20:29
> To: ffmpeg-devel@ffmpeg.org
> Cc: xuju...@sjtu.edu.cn
> Subject: [FFmpeg-devel] [PATCH v5 2/2]
> dnn_backend_native_layer_conv2d.c:Add mutithread function
> 
> From: Xu Jun 
> 
> Use pthread to multithread dnn_execute_layer_conv2d.
> Can be tested with command "./ffmpeg_g -i input.png -vf \
> format=yuvj420p,dnn_processing=dnn_backend=native:model= \
> espcn.model:input=x:output=y:options=conv2d_threads=23 \  -y sr_native.jpg
> -benchmark"
> 
> before patch: utime=11.238s stime=0.005s rtime=11.248s after patch:
> utime=20.817s stime=0.047s rtime=1.051s on my 3900X 12c24t @4.2GHz
> 
> About the increase of utime, it's because that CPU HyperThreading technology
> makes logical cores twice of physical cores while cpu's counting performance
> improves less than double. And utime sums all cpu's logical cores' runtime. 
> As a
> result, using threads num near cpu's logical core's number will double utime,
> while reduce rtime less than half for HyperThreading CPUs.
> 
> Signed-off-by: Xu Jun 
> ---
> v2: add check for HAVE_PTHREAD_CANCEL and modify FATE test
> dnn-layer-conv2d-test.c
> v4: use extern to call dnn_native_class in dnn-layer-conv2d-test.c
> v5: use DNN_SUCCESS as return flag instead of 0.
> 
LGTM, will push tomorrow if no other comments.
___
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/5] avcodec: add "Argonaut Games Video" descriptor

2020-09-07 Thread James Almer
On 9/7/2020 8:10 PM, Zane van Iperen wrote:
> On Mon, 7 Sep 2020 16:33:58 +0200
> "Paul B Mahol"  wrote:
> 
>>
>> On Mon, Sep 07, 2020 at 01:14:26PM +, Zane van Iperen wrote:
>>> Signed-off-by: Zane van Iperen 
>>> ---
>>>  libavcodec/codec_desc.c | 7 +++
>>>  libavcodec/codec_id.h   | 1 +
>>>  libavcodec/version.h| 2 +-
>>>  3 files changed, 9 insertions(+), 1 deletion(-)
>>>
>>
>> If there is no actual video decoder source code ever
>> going to be added then no point in adding this.
>>
> 
> I asked about this on IRC, and this was suggested.
> If I leave it at AV_CODEC_ID_NONE, then the ffmpeg CLI complains with
> "Could not find codec parameters". I don't want to set it to
> AVMEDIA_TYPE_UNKNOWN because then you lose all the codec parameters.
> 
> I would like to add a decoder eventually, but I'd have to reverse
> engineer it. There's also not many samples to work with, so I'm not sure
> how viable it'd be.

You could change the demuxer you submitted to simply skip the video
track and demux only the audio, which afaik can be decoded by libavcodec.
If this Argo video codec was supported by some other container then it
would make sense adding a descriptor for it, as it would allow remuxing.
But as is, it's probably better not to bother with it.
___
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/5] avcodec: add "Argonaut Games Video" descriptor

2020-09-07 Thread Zane van Iperen
On Mon, 7 Sep 2020 16:33:58 +0200
"Paul B Mahol"  wrote:

> 
> On Mon, Sep 07, 2020 at 01:14:26PM +, Zane van Iperen wrote:
> > Signed-off-by: Zane van Iperen 
> > ---
> >  libavcodec/codec_desc.c | 7 +++
> >  libavcodec/codec_id.h   | 1 +
> >  libavcodec/version.h| 2 +-
> >  3 files changed, 9 insertions(+), 1 deletion(-)
> >
> 
> If there is no actual video decoder source code ever
> going to be added then no point in adding this.
> 

I asked about this on IRC, and this was suggested.
If I leave it at AV_CODEC_ID_NONE, then the ffmpeg CLI complains with
"Could not find codec parameters". I don't want to set it to
AVMEDIA_TYPE_UNKNOWN because then you lose all the codec parameters.

I would like to add a decoder eventually, but I'd have to reverse
engineer it. There's also not many samples to work with, so I'm not sure
how viable it'd be.

___
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] avformat: add Argonaut Games BRP demuxer

2020-09-07 Thread Zane van Iperen
On Mon, 7 Sep 2020 16:35:47 +0200
"Paul B Mahol"  wrote:

> > +
> > +fail:
> > +/* TODO: Remove once AVFMT_HEADER_CLEANUP lands. */
> 
> Huh, what is this one comment about?
> 
I believe Andreas is updating all the demuxers so their read_close()
function can safely be called if read_header() fails.

I was saving him the effort.

See https://ffmpeg.org/pipermail/ffmpeg-devel/2020-August/267440.html,
and https://ffmpeg.org/pipermail/ffmpeg-devel/2020-July/266575.html

___
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] avcodec/exr: add support data windows larger or outside display window

2020-09-07 Thread Paul B Mahol
On Mon, Sep 07, 2020 at 02:54:35PM -0700, mindm...@gmail.com wrote:
> From: Mark Reid 
> 
> Hi,
> The following patch adds exr support for data windows that are larger or 
> outside the display window. 
> This adds support for both scanline and tiled formats.
> 
> Here are the added exr files for the fate tests. Could somebody upload them 
> to fate for me?
> https://www.dropbox.com/s/m0941dmjoejskp0/exr_datawindow_fate_files.zip
> 

Will upload files in next 24h and apply patch in next 96h.
___
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] tools/target_dec_fuzzer: Adjust threshold for WMV3IMAGE

2020-09-07 Thread Michael Niedermayer
On Sun, Sep 06, 2020 at 03:26:17PM +0200, Michael Niedermayer wrote:
> Fixes: Timeout (1131sec -> 1sec)
> Fixes: 
> 24727/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WMV3IMAGE_fuzzer-5754167793287168
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  tools/target_dec_fuzzer.c | 1 +
>  1 file changed, 1 insertion(+)

will apply


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

No snowflake in an avalanche ever feels responsible. -- 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".

Re: [FFmpeg-devel] [PATCH 1/2] avcodec/ffwavesynth: Fix integer overflow in wavesynth_synth_sample / WS_SINE

2020-09-07 Thread Michael Niedermayer
On Sun, Sep 06, 2020 at 07:38:07PM +0200, Nicolas George wrote:
> Michael Niedermayer (12020-09-06):
> > Fixes: signed integer overflow: -1429092 * -32596 cannot be represented in 
> > type 'int'
> > Fixes: 
> > 24419/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FFWAVESYNTH_fuzzer-5157849974702080
> > 
> > Found-by: continuous fuzzing process 
> > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> > Signed-off-by: Michael Niedermayer 
> > ---
> >  libavcodec/ffwavesynth.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> Ok.

will apply

thx

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Freedom in capitalist society always remains about the same as it was in
ancient Greek republics: Freedom for slave owners. -- Vladimir Lenin


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/electronicarts: Check if there are any streams

2020-09-07 Thread Michael Niedermayer
On Sun, Sep 06, 2020 at 08:50:02PM -0300, James Almer wrote:
> On 9/6/2020 7:57 PM, Michael Niedermayer wrote:
> > Fixes: Assertion failure (invalid stream index)
> > Fixes: 
> > 25120/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-6565251898933248
> > 
> > Found-by: continuous fuzzing process 
> > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> > Signed-off-by: Michael Niedermayer 
> > ---
> >  libavformat/electronicarts.c | 14 --
> >  1 file changed, 8 insertions(+), 6 deletions(-)
> > 
> > diff --git a/libavformat/electronicarts.c b/libavformat/electronicarts.c
> > index 2ee5e1b6fa..6976a133c3 100644
> > --- a/libavformat/electronicarts.c
> > +++ b/libavformat/electronicarts.c
> > @@ -530,20 +530,17 @@ static int ea_read_header(AVFormatContext *s)
> >  if (ea->num_channels <= 0 || ea->num_channels > 2) {
> >  av_log(s, AV_LOG_WARNING,
> > "Unsupported number of channels: %d\n", 
> > ea->num_channels);
> > -ea->audio_codec = 0;
> > -return 1;
> > +goto no_audio;
> >  }
> >  if (ea->sample_rate <= 0) {
> >  av_log(s, AV_LOG_ERROR,
> > "Unsupported sample rate: %d\n", ea->sample_rate);
> > -ea->audio_codec = 0;
> > -return 1;
> > +goto no_audio;
> >  }
> >  if (ea->bytes <= 0 || ea->bytes > 2) {
> >  av_log(s, AV_LOG_ERROR,
> > "Invalid number of bytes per sample: %d\n", ea->bytes);
> > -ea->audio_codec = AV_CODEC_ID_NONE;
> > -return 1;
> > +goto no_audio;
> >  }
> >  
> >  /* initialize the audio decoder stream */
> > @@ -564,8 +561,13 @@ static int ea_read_header(AVFormatContext *s)
> >
> > st->codecpar->bits_per_coded_sample;
> >  ea->audio_stream_index   = st->index;
> >  st->start_time   = 0;
> > +return 1;
> 
> fwiw, return value for AVInputFormat.read_header() should be 0 for
> success, < 0 for failure (Mind, while > 0 is not defined, it's currently
> treated like 0).

indeed, this is just for the internal function pointer though, doesnt affect
the user API visible one. But ill fix this.
Will do it in a seperate comit as this is unrelated to this patch, this just
moved some of the return 1 around.

thx

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

No snowflake in an avalanche ever feels responsible. -- 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] [PATCH 1/1] avcodec/exr: add support data windows larger or outside display window

2020-09-07 Thread mindmark
From: Mark Reid 

Hi,
The following patch adds exr support for data windows that are larger or 
outside the display window. 
This adds support for both scanline and tiled formats.

Here are the added exr files for the fate tests. Could somebody upload them to 
fate for me?
https://www.dropbox.com/s/m0941dmjoejskp0/exr_datawindow_fate_files.zip

---
 libavcodec/exr.c  | 110 ++
 tests/fate/image.mak  |  31 +
 .../fate/exr-rgb-scanline-float-zip-dw-large  |   6 +
 .../fate/exr-rgb-scanline-half-piz-dw-large   |   6 +
 .../fate/exr-rgb-scanline-half-zip-dw-large   |   6 +
 .../fate/exr-rgb-scanline-half-zip-dw-outside |   6 +
 .../fate/exr-rgb-scanline-uint32-piz-dw-large |   6 +
 tests/ref/fate/exr-rgb-tile-half-piz-dw-large |   6 +
 tests/ref/fate/exr-rgb-tile-half-zip  |   6 +
 .../ref/fate/exr-rgb-tile-half-zip-dw-outside |   6 +
 .../ref/fate/exr-rgb-tile-uint32-piz-dw-large |   6 +
 tests/ref/fate/exr-ya-scanline-zip-half-12x8  |   6 +
 12 files changed, 155 insertions(+), 46 deletions(-)
 create mode 100644 tests/ref/fate/exr-rgb-scanline-float-zip-dw-large
 create mode 100644 tests/ref/fate/exr-rgb-scanline-half-piz-dw-large
 create mode 100644 tests/ref/fate/exr-rgb-scanline-half-zip-dw-large
 create mode 100644 tests/ref/fate/exr-rgb-scanline-half-zip-dw-outside
 create mode 100644 tests/ref/fate/exr-rgb-scanline-uint32-piz-dw-large
 create mode 100644 tests/ref/fate/exr-rgb-tile-half-piz-dw-large
 create mode 100644 tests/ref/fate/exr-rgb-tile-half-zip
 create mode 100644 tests/ref/fate/exr-rgb-tile-half-zip-dw-outside
 create mode 100644 tests/ref/fate/exr-rgb-tile-uint32-piz-dw-large
 create mode 100644 tests/ref/fate/exr-ya-scanline-zip-half-12x8

diff --git a/libavcodec/exr.c b/libavcodec/exr.c
index 68d5befa40..d5f12cb22a 100644
--- a/libavcodec/exr.c
+++ b/libavcodec/exr.c
@@ -134,8 +134,8 @@ typedef struct EXRContext {
 const AVPixFmtDescriptor *desc;
 
 int w, h;
-uint32_t xmax, xmin;
-uint32_t ymax, ymin;
+int32_t xmax, xmin;
+int32_t ymax, ymin;
 uint32_t xdelta, ydelta;
 
 int scan_lines_per_block;
@@ -995,12 +995,13 @@ static int decode_block(AVCodecContext *avctx, void 
*tdata,
 uint64_t line_offset, uncompressed_size;
 uint8_t *ptr;
 uint32_t data_size;
-uint64_t line, col = 0;
+int line, col = 0;
 uint64_t tile_x, tile_y, tile_level_x, tile_level_y;
 const uint8_t *src;
 int step = s->desc->flags & AV_PIX_FMT_FLAG_FLOAT ? 4 : 2 * 
s->desc->nb_components;
-int axmax = (avctx->width - (s->xmax + 1)) * step; /* nb pixel to add at 
the right of the datawindow */
-int bxmin = s->xmin * step; /* nb pixel to add at the left of the 
datawindow */
+int bxmin, axmax, window_xoffset = 0;
+int window_xmin, window_xmax, window_ymin, window_ymax;
+int data_xoffset, data_yoffset, data_window_offset, xsize, ysize;
 int i, x, buf_size = s->buf_size;
 int c, rgb_channel_count;
 float one_gamma = 1.0f / s->gamma;
@@ -1029,28 +1030,16 @@ static int decode_block(AVCodecContext *avctx, void 
*tdata,
 return AVERROR_PATCHWELCOME;
 }
 
-if (s->xmin || s->ymin) {
-avpriv_report_missing_feature(s->avctx, "Tiles with xmin/ymin");
-return AVERROR_PATCHWELCOME;
-}
-
-line = s->tile_attr.ySize * tile_y;
+line = s->ymin + s->tile_attr.ySize * tile_y;
 col = s->tile_attr.xSize * tile_x;
 
 if (line < s->ymin || line > s->ymax ||
-col  < s->xmin || col  > s->xmax)
+s->xmin + col  < s->xmin ||  s->xmin + col  > s->xmax)
 return AVERROR_INVALIDDATA;
 
 td->ysize = FFMIN(s->tile_attr.ySize, s->ydelta - tile_y * 
s->tile_attr.ySize);
 td->xsize = FFMIN(s->tile_attr.xSize, s->xdelta - tile_x * 
s->tile_attr.xSize);
 
-if (col) { /* not the first tile of the line */
-bxmin = 0; /* doesn't add pixel at the left of the datawindow */
-}
-
-if ((col + td->xsize) != s->xdelta)/* not the last tile of the line */
-axmax = 0; /* doesn't add pixel at the right of the datawindow */
-
 td->channel_line_size = td->xsize * s->current_channel_offset;/* 
uncompress size of one line */
 uncompressed_size = td->channel_line_size * (uint64_t)td->ysize;/* 
uncompress size of the block */
 } else {
@@ -1081,6 +1070,33 @@ static int decode_block(AVCodecContext *avctx, void 
*tdata,
 }
 }
 
+window_xmin = FFMIN(avctx->width, FFMAX(0, s->xmin + col));
+window_xmax = FFMIN(avctx->width, FFMAX(0, s->xmin + col + td->xsize));
+window_ymin = FFMIN(avctx->height, FFMAX(0, line ));
+window_ymax = FFMIN(avctx->height, FFMAX(0, line + td->ysize));
+xsize = window_xmax - window_xmin;
+ysize = window_ymax - window_ymin;
+
+/* tile or scanline not visible skip decoding */
+if (xsize <= 0 || ysize <= 0)
+return 0;
+
+/* 

Re: [FFmpeg-devel] [PATCH] avformat/rtsp: fix infinite loop with udp transport

2020-09-07 Thread Andriy Gelman
On Sun, 30. Aug 11:50, Zhao Zhili wrote:
> 
> 
> > On Aug 30, 2020, at 1:45 AM, Andriy Gelman  wrote:
> > 
> > Hi Zhao,
> > 
> > On Tue, 25. Aug 01:17, Zhao Zhili wrote:
> >> Ping again.
> >> 
> >>> On Aug 17, 2020, at 8:05 AM, zhilizhao  wrote:
> >>> 
> >>> Please help review the patch, thanks!
> >>> 
>  On Aug 6, 2020, at 4:50 PM, quinkbl...@foxmail.com wrote:
>  
>  From: Zhao Zhili 
>  
>  User report: 
>  http://ffmpeg.org/pipermail/ffmpeg-user/2020-August/049494.html
>  
>  server:
>  ./ffmpeg -i test.mp4 -c copy -f rtsp -rtsp_transport udp  
>  rtsp://localhost:12345/live.sdp
>  
>  client:
>  ./ffmpeg_g -y -rtsp_flags listen -timeout 100 -i 
>  rtsp://localhost:12345/live.sdp -c copy test.mp4
>  ---
>  libavformat/rtsp.c | 5 +
>  1 file changed, 5 insertions(+)
>  
>  diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
>  index 5d8491b74b..0fb9fde6b4 100644
>  --- a/libavformat/rtsp.c
>  +++ b/libavformat/rtsp.c
>  @@ -2051,6 +2051,11 @@ static int udp_read_packet(AVFormatContext *s, 
>  RTSPStream **prtsp_st,
>    if ((ret = parse_rtsp_message(s)) < 0) {
>    return ret;
>    }
>  +/* Since there is no way to detect eof of udp streams, 
>  break
>  + * the loop in teardown state to prevent run into 
>  infinite.
>  + */
>  +if (rt->state == RTSP_STATE_IDLE)
>  +return AVERROR_EOF;
>    }
>  #endif
>    } else if (n == 0 && ++timeout_cnt >= MAX_TIMEOUTS) {
> > 
> > Currently when the stream finishes a BYE message is not sent from the 
> > server.  
> > 
> > You can ensure that the message is sent by adding the send_bye option with 
> > the
> > flag:
> > "-rtpflags send_bye"
> > 
> > This will also fix the problem.
> 
> Thanks for your reply. It's a clean solution from the viewpoint of FFmpeg 
> users.
> However, I think FFmpeg should handle the case without BYE packets, even
> without RTCP. The busy loop leads to high cpu usage. I'm not saying the patch
> is the right solution, I'd like to hear other suggestions to fix the problem 
> on the
> rtsp receiver's side.
> 

The server does send a teardown message when it exits. Currently this sets 
the client state to rt->state = RTSP_STATE_IDLE.

Could adding RTSP_STATE_TEARDOWN to RTSPClientState enum be better? You could
then return AVERROR_EOF if the client is in the teardown state.

-- 
Andriy
___
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 v3] avcodec/decode: use a packet list to store packet properties

2020-09-07 Thread James Almer
Keeping only the latest packet fed to the decoder works only for decoders that
return a frame immediately after every consumed packet. Decoders that consume
several packets before they return a frame will fill said frame with properties
taken from the last consumed packet instead of the earliest.

Signed-off-by: James Almer 
---
 libavcodec/decode.c   | 36 +++-
 libavcodec/internal.h |  2 ++
 libavcodec/utils.c|  3 +++
 3 files changed, 32 insertions(+), 9 deletions(-)

diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index da587ac1f6..8f5151cd87 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -43,6 +43,7 @@
 #include "decode.h"
 #include "hwconfig.h"
 #include "internal.h"
+#include "packet_internal.h"
 #include "thread.h"
 
 typedef struct FramePool {
@@ -142,15 +143,24 @@ fail2:
 return 0;
 }
 
-static int extract_packet_props(AVCodecInternal *avci, const AVPacket *pkt)
+#define IS_EMPTY(pkt) (!(pkt)->data)
+
+static int extract_packet_props(AVCodecInternal *avci, AVPacket *pkt)
 {
 int ret = 0;
 
-av_packet_unref(avci->last_pkt_props);
-if (pkt) {
-ret = av_packet_copy_props(avci->last_pkt_props, pkt);
-if (!ret)
-avci->last_pkt_props->size = pkt->size; // HACK: Needed for 
ff_decode_frame_props().
+ret = avpriv_packet_list_put(>pkt_props, >pkt_props_tail, pkt,
+ av_packet_copy_props);
+if (ret < 0)
+return ret;
+avci->pkt_props_tail->pkt.size = pkt->size; // HACK: Needed for 
ff_decode_frame_props().
+avci->pkt_props_tail->pkt.data = (void*)1;  // HACK: Needed for IS_EMPTY().
+
+if (IS_EMPTY(avci->last_pkt_props)) {
+ret = avpriv_packet_list_get(>pkt_props,
+ >pkt_props_tail,
+ avci->last_pkt_props);
+av_assert0(ret != AVERROR(EAGAIN));
 }
 return ret;
 }
@@ -512,6 +522,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
 
 if (ret >= pkt->size || ret < 0) {
 av_packet_unref(pkt);
+av_packet_unref(avci->last_pkt_props);
 } else {
 int consumed = ret;
 
@@ -550,9 +561,11 @@ static int decode_receive_frame_internal(AVCodecContext 
*avctx, AVFrame *frame)
 
 av_assert0(!frame->buf[0]);
 
-if (avctx->codec->receive_frame)
+if (avctx->codec->receive_frame) {
 ret = avctx->codec->receive_frame(avctx, frame);
-else
+if (ret != AVERROR(EAGAIN))
+av_packet_unref(avci->last_pkt_props);
+} else
 ret = decode_simple_receive_frame(avctx, frame);
 
 if (ret == AVERROR_EOF)
@@ -1683,7 +1696,7 @@ static int add_metadata_from_side_data(const AVPacket 
*avpkt, AVFrame *frame)
 
 int ff_decode_frame_props(AVCodecContext *avctx, AVFrame *frame)
 {
-const AVPacket *pkt = avctx->internal->last_pkt_props;
+AVPacket *pkt = avctx->internal->last_pkt_props;
 int i;
 static const struct {
 enum AVPacketSideDataType packet;
@@ -1701,6 +1714,11 @@ int ff_decode_frame_props(AVCodecContext *avctx, AVFrame 
*frame)
 { AV_PKT_DATA_S12M_TIMECODE,  AV_FRAME_DATA_S12M_TIMECODE 
},
 };
 
+if (IS_EMPTY(pkt))
+avpriv_packet_list_get(>internal->pkt_props,
+   >internal->pkt_props_tail,
+   pkt);
+
 if (pkt) {
 frame->pts = pkt->pts;
 #if FF_API_PKT_PTS
diff --git a/libavcodec/internal.h b/libavcodec/internal.h
index 5d0e6e7831..ce4dbbc2b9 100644
--- a/libavcodec/internal.h
+++ b/libavcodec/internal.h
@@ -145,6 +145,8 @@ typedef struct AVCodecInternal {
  * for decoding.
  */
 AVPacket *last_pkt_props;
+AVPacketList *pkt_props;
+AVPacketList *pkt_props_tail;
 
 /**
  * temporary buffer used for encoders to store their bitstream
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 2e5185f364..3e644e246a 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -50,6 +50,7 @@
 #include "thread.h"
 #include "frame_thread_encoder.h"
 #include "internal.h"
+#include "packet_internal.h"
 #include "put_bits.h"
 #include "raw.h"
 #include "bytestream.h"
@@ -1149,6 +1150,8 @@ av_cold int avcodec_close(AVCodecContext *avctx)
 av_packet_free(>internal->compat_encode_packet);
 av_packet_free(>internal->buffer_pkt);
 av_packet_free(>internal->last_pkt_props);
+avpriv_packet_list_free(>internal->pkt_props,
+>internal->pkt_props_tail);
 
 av_packet_free(>internal->ds.in_pkt);
 av_frame_free(>internal->es.in_frame);
-- 
2.27.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 5/5] avformat: add Argonaut Games BRP demuxer

2020-09-07 Thread Paul B Mahol
On Mon, Sep 07, 2020 at 01:14:34PM +, Zane van Iperen wrote:
> Used in FMVs for FX Fighter and Croc. Supports BVID and BASF streams,
> requests samples for anything else.
> 
> Due to the way BASF streams are contained in the file, only one is
> supported. I have yet to see a BRP file with multiple.
> 
> Signed-off-by: Zane van Iperen 
> ---
>  Changelog|   1 +
>  libavformat/Makefile |   1 +
>  libavformat/allformats.c |   1 +
>  libavformat/argo_brp.c   | 447 +++
>  libavformat/version.h|   2 +-
>  5 files changed, 451 insertions(+), 1 deletion(-)
>  create mode 100644 libavformat/argo_brp.c
> 
> diff --git a/Changelog b/Changelog
> index ff9ff2fcb8..2ccecfbcc9 100644
> --- a/Changelog
> +++ b/Changelog
> @@ -21,6 +21,7 @@ version :
>  - MOFLEX demuxer
>  - MODS demuxer
>  - PhotoCD decoder
> +- Argonaut Games BRP demuxer
>  
>  
>  version 4.3:
> diff --git a/libavformat/Makefile b/libavformat/Makefile
> index 2368bc15ac..062f3bd9c2 100644
> --- a/libavformat/Makefile
> +++ b/libavformat/Makefile
> @@ -104,6 +104,7 @@ OBJS-$(CONFIG_APTX_HD_MUXER) += rawenc.o
>  OBJS-$(CONFIG_AQTITLE_DEMUXER)   += aqtitledec.o subtitles.o
>  OBJS-$(CONFIG_ARGO_ASF_DEMUXER)  += argo_asf.o
>  OBJS-$(CONFIG_ARGO_ASF_MUXER)+= argo_asf.o
> +OBJS-$(CONFIG_ARGO_BRP_DEMUXER)  += argo_brp.o argo_asf.o
>  OBJS-$(CONFIG_ASF_DEMUXER)   += asfdec_f.o asf.o asfcrypt.o \
>  avlanguage.o
>  OBJS-$(CONFIG_ASF_O_DEMUXER) += asfdec_o.o asf.o asfcrypt.o \
> diff --git a/libavformat/allformats.c b/libavformat/allformats.c
> index 3438a14141..8e7556e529 100644
> --- a/libavformat/allformats.c
> +++ b/libavformat/allformats.c
> @@ -65,6 +65,7 @@ extern AVOutputFormat ff_aptx_hd_muxer;
>  extern AVInputFormat  ff_aqtitle_demuxer;
>  extern AVInputFormat  ff_argo_asf_demuxer;
>  extern AVOutputFormat ff_argo_asf_muxer;
> +extern AVInputFormat  ff_argo_brp_demuxer;
>  extern AVInputFormat  ff_asf_demuxer;
>  extern AVOutputFormat ff_asf_muxer;
>  extern AVInputFormat  ff_asf_o_demuxer;
> diff --git a/libavformat/argo_brp.c b/libavformat/argo_brp.c
> new file mode 100644
> index 00..e8e58fb3d8
> --- /dev/null
> +++ b/libavformat/argo_brp.c
> @@ -0,0 +1,447 @@
> +/*
> + * Argonaut Games BRP Demuxer
> + *
> + * Copyright (C) 2020 Zane van Iperen (z...@zanevaniperen.com)
> + *
> + * 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 "avformat.h"
> +#include "internal.h"
> +#include "libavutil/intreadwrite.h"
> +#include "libavutil/avassert.h"
> +#include "libavutil/internal.h"
> +#include "argo_asf.h"
> +
> +#define BRP_TAG MKTAG('B', 'R', 'P', 'P')
> +#define BRP_FILE_HEADER_SIZE12
> +#define BRP_BLOCK_HEADER_SIZE   12
> +#define BRP_STREAM_HEADER_SIZE  20
> +#define BRP_MAX_STREAMS 32 /* Soft cap, but even this is overkill. */
> +#define BVID_HEADER_SIZE16
> +#define BRP_MIN_BUFFER_SIZE FFMAX(FFMAX3(BRP_FILE_HEADER_SIZE,\
> + BRP_BLOCK_HEADER_SIZE,   \
> + BRP_STREAM_HEADER_SIZE), \
> +  BVID_HEADER_SIZE)
> +
> +#define BRP_CODEC_ID_BVID   MKTAG('B', 'V', 'I', 'D')
> +#define BRP_CODEC_ID_BASF   MKTAG('B', 'A', 'S', 'F')
> +
> +typedef struct ArgoBRPFileHeader {
> +uint32_t magic;
> +uint32_t num_streams;
> +uint32_t byte_rate;
> +} ArgoBRPFileHeader;
> +
> +typedef struct ArgoBRPBlockHeader {
> +int32_t  stream_id;
> +uint32_t start_ms;
> +uint32_t size;
> +} ArgoBRPBlockHeader;
> +
> +typedef struct ArgoBVIDHeader {
> +uint32_t num_frames;
> +uint32_t width;
> +uint32_t height;
> +uint32_t depth;
> +} ArgoBVIDHeader;
> +
> +typedef struct ArgoBRPStreamHeader {
> +uint32_t codec_id;
> +uint32_t id;
> +uint32_t duration_ms;
> +uint32_t byte_rate;
> +uint32_t extradata_size;
> +union
> +{
> +/* If codec_id == BRP_CODEC_ID_BVID */
> +ArgoBVIDHeaderbvid;
> +/* If codec_id == BRP_CODEC_ID_BASF */
> +ArgoASFFileHeader basf;
> +} 

Re: [FFmpeg-devel] [PATCH 4/5] avcodec: add "Argonaut Games Video" descriptor

2020-09-07 Thread Paul B Mahol
On Mon, Sep 07, 2020 at 01:14:26PM +, Zane van Iperen wrote:
> Signed-off-by: Zane van Iperen 
> ---
>  libavcodec/codec_desc.c | 7 +++
>  libavcodec/codec_id.h   | 1 +
>  libavcodec/version.h| 2 +-
>  3 files changed, 9 insertions(+), 1 deletion(-)
>

If there is no actual video decoder source code ever
going to be added then no point in adding this.

> diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
> index 9e73dcba27..f33585adaa 100644
> --- a/libavcodec/codec_desc.c
> +++ b/libavcodec/codec_desc.c
> @@ -1412,6 +1412,13 @@ static const AVCodecDescriptor codec_descriptors[] = {
>  .long_name = NULL_IF_CONFIG_SMALL("PGX (JPEG2000 Test Format)"),
>  .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
>  },
> +{
> +.id= AV_CODEC_ID_ARGO,
> +.type  = AVMEDIA_TYPE_VIDEO,
> +.name  = "argo",
> +.long_name = NULL_IF_CONFIG_SMALL("Argonaut Games Video"),
> +.props = AV_CODEC_PROP_LOSSY,
> +},
>  {
>  .id= AV_CODEC_ID_Y41P,
>  .type  = AVMEDIA_TYPE_VIDEO,
> diff --git a/libavcodec/codec_id.h b/libavcodec/codec_id.h
> index e4eca5d580..3d115187b4 100644
> --- a/libavcodec/codec_id.h
> +++ b/libavcodec/codec_id.h
> @@ -242,6 +242,7 @@ enum AVCodecID {
>  AV_CODEC_ID_RSCC,
>  AV_CODEC_ID_AVS2,
>  AV_CODEC_ID_PGX,
> +AV_CODEC_ID_ARGO,
>  
>  AV_CODEC_ID_Y41P = 0x8000,
>  AV_CODEC_ID_AVRP,
> diff --git a/libavcodec/version.h b/libavcodec/version.h
> index 4b221f96ad..5ce4ba55d9 100644
> --- a/libavcodec/version.h
> +++ b/libavcodec/version.h
> @@ -28,7 +28,7 @@
>  #include "libavutil/version.h"
>  
>  #define LIBAVCODEC_VERSION_MAJOR  58
> -#define LIBAVCODEC_VERSION_MINOR 105
> +#define LIBAVCODEC_VERSION_MINOR 106
>  #define LIBAVCODEC_VERSION_MICRO 100
>  
>  #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
> -- 
> 2.25.4
> 
> 
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

[FFmpeg-devel] [PATCH 1/2 v3] avcodec/packet: move AVPacketList definition and function helpers over from libavformat

2020-09-07 Thread James Almer
And replace the flags parameter with a function callback that can be used to
copy the contents of the packet (e.g, av_packet_ref and av_packet_copy_props).

Signed-off-by: James Almer 
---
This version achieves the same effect as v2 while being cleaner.
I could leave the flags parameter, too, for the sake of keeping the function
easily extensible without having to wait for a major bump.

 libavcodec/avpacket.c| 66 
 libavcodec/packet.h  |  5 ++
 libavcodec/packet_internal.h | 41 +++
 libavformat/aiffenc.c|  7 +--
 libavformat/avformat.h   |  6 ---
 libavformat/flacenc.c|  7 +--
 libavformat/internal.h   | 42 
 libavformat/matroskadec.c| 11 ++--
 libavformat/mp3enc.c |  7 +--
 libavformat/ttaenc.c |  9 ++--
 libavformat/utils.c  | 98 +++-
 11 files changed, 153 insertions(+), 146 deletions(-)

diff --git a/libavcodec/avpacket.c b/libavcodec/avpacket.c
index 4801163227..e4e35900f2 100644
--- a/libavcodec/avpacket.c
+++ b/libavcodec/avpacket.c
@@ -726,6 +726,72 @@ FF_ENABLE_DEPRECATION_WARNINGS
 #endif
 }
 
+int avpriv_packet_list_put(AVPacketList **packet_buffer,
+   AVPacketList **plast_pktl,
+   AVPacket  *pkt,
+   int (*copy)(AVPacket *dst, const AVPacket *src))
+{
+AVPacketList *pktl = av_mallocz(sizeof(AVPacketList));
+int ret;
+
+if (!pktl)
+return AVERROR(ENOMEM);
+
+if (copy) {
+ret = copy(>pkt, pkt);
+if (ret < 0) {
+av_free(pktl);
+return ret;
+}
+} else {
+ret = av_packet_make_refcounted(pkt);
+if (ret < 0) {
+av_free(pktl);
+return ret;
+}
+av_packet_move_ref(>pkt, pkt);
+}
+
+if (*packet_buffer)
+(*plast_pktl)->next = pktl;
+else
+*packet_buffer = pktl;
+
+/* Add the packet in the buffered packet list. */
+*plast_pktl = pktl;
+return 0;
+}
+
+int avpriv_packet_list_get(AVPacketList **pkt_buffer,
+   AVPacketList **pkt_buffer_end,
+   AVPacket  *pkt)
+{
+AVPacketList *pktl;
+if (!*pkt_buffer)
+return AVERROR(EAGAIN);
+pktl= *pkt_buffer;
+*pkt= pktl->pkt;
+*pkt_buffer = pktl->next;
+if (!pktl->next)
+*pkt_buffer_end = NULL;
+av_freep();
+return 0;
+}
+
+void avpriv_packet_list_free(AVPacketList **pkt_buf, AVPacketList 
**pkt_buf_end)
+{
+AVPacketList *tmp = *pkt_buf;
+
+while (tmp) {
+AVPacketList *pktl = tmp;
+tmp = pktl->next;
+av_packet_unref(>pkt);
+av_freep();
+}
+*pkt_buf = NULL;
+*pkt_buf_end = NULL;
+}
+
 int ff_side_data_set_encoder_stats(AVPacket *pkt, int quality, int64_t *error, 
int error_count, int pict_type)
 {
 uint8_t *side_data;
diff --git a/libavcodec/packet.h b/libavcodec/packet.h
index 0a19a0eff3..b9d4c9c2c8 100644
--- a/libavcodec/packet.h
+++ b/libavcodec/packet.h
@@ -393,6 +393,11 @@ typedef struct AVPacket {
 #endif
 } AVPacket;
 
+typedef struct AVPacketList {
+AVPacket pkt;
+struct AVPacketList *next;
+} AVPacketList;
+
 #define AV_PKT_FLAG_KEY 0x0001 ///< The packet contains a keyframe
 #define AV_PKT_FLAG_CORRUPT 0x0002 ///< The packet content is corrupted
 /**
diff --git a/libavcodec/packet_internal.h b/libavcodec/packet_internal.h
index cdb9a27f2f..f2b058e669 100644
--- a/libavcodec/packet_internal.h
+++ b/libavcodec/packet_internal.h
@@ -23,6 +23,47 @@
 
 #include "packet.h"
 
+
+/**
+ * Append an AVPacket to the list.
+ *
+ * @param head  List head element
+ * @param tail  List tail element
+ * @param pkt   The packet being appended. The data described in it will
+ *  be made reference counted if it isn't already.
+ * @param copy  A callback to copy the contents of the packet to the list.
+May be null, in which case the packet's reference will be
+moved to the list.
+ * @return 0 on success, negative AVERROR value on failure. On failure,
+   the packet and the list are unchanged.
+ */
+int avpriv_packet_list_put(AVPacketList **head, AVPacketList **tail,
+   AVPacket *pkt,
+   int (*copy)(AVPacket *dst, const AVPacket *src));
+
+/**
+ * Remove the oldest AVPacket in the list and return it.
+ *
+ * @note The pkt will be overwritten completely on success. The caller
+ *   owns the packet and must unref it by itself.
+ *
+ * @param head List head element
+ * @param tail List tail element
+ * @param pkt  Pointer to an AVPacket struct
+ * @return 0 on success, and a packet is returned. AVERROR(EAGAIN) if
+ * the list was empty.
+ */
+int avpriv_packet_list_get(AVPacketList **head, AVPacketList **tail,
+   AVPacket *pkt);
+
+/**
+ * Wipe the list and unref all 

[FFmpeg-devel] [PATCH] avformat/utils: Avoid duplicating extradata from extract_extradata BSF

2020-09-07 Thread Andreas Rheinhardt
Instead move the extradata contained in packet side-data to its
destination. This is possible because the side data already has zeroed
padding.

Notice that the check for FF_MAX_EXTRADATA_SIZE has been dropped,
because said constant is from libavcodec/internal.h. If libavcodec
wanted to enforce this, it should do so in the extract_extradata BSF
instead.

Signed-off-by: Andreas Rheinhardt 
---
 libavformat/utils.c | 23 ---
 1 file changed, 8 insertions(+), 15 deletions(-)

diff --git a/libavformat/utils.c b/libavformat/utils.c
index 807d9f10cb..63952e31a0 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -3567,9 +3567,6 @@ static int extract_extradata(AVStream *st, const AVPacket 
*pkt)
 }
 
 while (ret >= 0 && !sti->avctx->extradata) {
-int extradata_size;
-uint8_t *extradata;
-
 ret = av_bsf_receive_packet(sti->extract_extradata.bsf, pkt_ref);
 if (ret < 0) {
 if (ret != AVERROR(EAGAIN) && ret != AVERROR_EOF)
@@ -3577,19 +3574,15 @@ static int extract_extradata(AVStream *st, const 
AVPacket *pkt)
 continue;
 }
 
-extradata = av_packet_get_side_data(pkt_ref, AV_PKT_DATA_NEW_EXTRADATA,
-_size);
-
-if (extradata) {
-av_assert0(!sti->avctx->extradata);
-if ((unsigned)extradata_size < FF_MAX_EXTRADATA_SIZE)
-sti->avctx->extradata = av_mallocz(extradata_size + 
AV_INPUT_BUFFER_PADDING_SIZE);
-if (!sti->avctx->extradata) {
-av_packet_unref(pkt_ref);
-return AVERROR(ENOMEM);
+for (int i = 0; i < pkt_ref->side_data_elems; i++) {
+AVPacketSideData *side_data = _ref->side_data[i];
+if (side_data->type == AV_PKT_DATA_NEW_EXTRADATA) {
+sti->avctx->extradata  = side_data->data;
+sti->avctx->extradata_size = side_data->size;
+side_data->data = NULL;
+side_data->size = 0;
+break;
 }
-memcpy(sti->avctx->extradata, extradata, extradata_size);
-sti->avctx->extradata_size = extradata_size;
 }
 av_packet_unref(pkt_ref);
 }
-- 
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 1/3] avcodec/extract_extradata: Consolidate zeroing extradata padding

2020-09-07 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/extract_extradata_bsf.c | 6 +-
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/libavcodec/extract_extradata_bsf.c 
b/libavcodec/extract_extradata_bsf.c
index 1fead74b57..6e80076522 100644
--- a/libavcodec/extract_extradata_bsf.c
+++ b/libavcodec/extract_extradata_bsf.c
@@ -103,7 +103,6 @@ static int extract_extradata_av1(AVBSFContext *ctx, 
AVPacket *pkt,
 av_buffer_unref(_buf);
 return AVERROR(ENOMEM);
 }
-memset(extradata + extradata_size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
 
 *data = extradata;
 *size = extradata_size;
@@ -198,7 +197,6 @@ static int extract_extradata_h2645(AVBSFContext *ctx, 
AVPacket *pkt,
 av_buffer_unref(_buf);
 return AVERROR(ENOMEM);
 }
-memset(extradata + extradata_size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
 
 *data = extradata;
 *size = extradata_size;
@@ -254,7 +252,6 @@ static int extract_extradata_vc1(AVBSFContext *ctx, 
AVPacket *pkt,
 return AVERROR(ENOMEM);
 
 memcpy(*data, pkt->data, extradata_size);
-memset(*data + extradata_size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
 *size = extradata_size;
 
 if (s->remove) {
@@ -285,7 +282,6 @@ static int extract_extradata_mpeg12(AVBSFContext *ctx, 
AVPacket *pkt,
 return AVERROR(ENOMEM);
 
 memcpy(*data, pkt->data, *size);
-memset(*data + *size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
 
 if (s->remove) {
 pkt->data += *size;
@@ -315,7 +311,6 @@ static int extract_extradata_mpeg4(AVBSFContext *ctx, 
AVPacket *pkt,
 return AVERROR(ENOMEM);
 
 memcpy(*data, pkt->data, *size);
-memset(*data + *size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
 
 if (s->remove) {
 pkt->data += *size;
@@ -377,6 +372,7 @@ static int extract_extradata_filter(AVBSFContext *ctx, 
AVPacket *pkt)
 goto fail;
 
 if (extradata) {
+memset(extradata + extradata_size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
 ret = av_packet_add_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA,
   extradata, extradata_size);
 if (ret < 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 3/3] avcodec/extract_extradata: Reindent after the last commit

2020-09-07 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/extract_extradata_bsf.c | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/libavcodec/extract_extradata_bsf.c 
b/libavcodec/extract_extradata_bsf.c
index 38517bdcf3..32c732f52b 100644
--- a/libavcodec/extract_extradata_bsf.c
+++ b/libavcodec/extract_extradata_bsf.c
@@ -275,17 +275,17 @@ static int extract_extradata_mpeg12(AVBSFContext *ctx, 
AVPacket *pkt,
 if (state == 0x1B3)
 found = 1;
 else if (found && state != 0x1B5 && state < 0x200 && state >= 0x100) {
-*size = i - 3;
-*data = av_malloc(*size + AV_INPUT_BUFFER_PADDING_SIZE);
-if (!*data)
-return AVERROR(ENOMEM);
+*size = i - 3;
+*data = av_malloc(*size + AV_INPUT_BUFFER_PADDING_SIZE);
+if (!*data)
+return AVERROR(ENOMEM);
 
-memcpy(*data, pkt->data, *size);
+memcpy(*data, pkt->data, *size);
 
-if (s->remove) {
-pkt->data += *size;
-pkt->size -= *size;
-}
+if (s->remove) {
+pkt->data += *size;
+pkt->size -= *size;
+}
 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 2/3] avcodec/extract_extradata: Remove always-true check

2020-09-07 Thread Andreas Rheinhardt
If a sequence header has already been found, it is certain that the next
startcode (being disjoint from the sequence header startcode) can begin
at index four at the earliest.

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

diff --git a/libavcodec/extract_extradata_bsf.c 
b/libavcodec/extract_extradata_bsf.c
index 6e80076522..38517bdcf3 100644
--- a/libavcodec/extract_extradata_bsf.c
+++ b/libavcodec/extract_extradata_bsf.c
@@ -275,7 +275,6 @@ static int extract_extradata_mpeg12(AVBSFContext *ctx, 
AVPacket *pkt,
 if (state == 0x1B3)
 found = 1;
 else if (found && state != 0x1B5 && state < 0x200 && state >= 0x100) {
-if (i > 3) {
 *size = i - 3;
 *data = av_malloc(*size + AV_INPUT_BUFFER_PADDING_SIZE);
 if (!*data)
@@ -287,7 +286,6 @@ static int extract_extradata_mpeg12(AVBSFContext *ctx, 
AVPacket *pkt,
 pkt->data += *size;
 pkt->size -= *size;
 }
-}
 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 5/5] avformat: add Argonaut Games BRP demuxer

2020-09-07 Thread Zane van Iperen
Used in FMVs for FX Fighter and Croc. Supports BVID and BASF streams,
requests samples for anything else.

Due to the way BASF streams are contained in the file, only one is
supported. I have yet to see a BRP file with multiple.

Signed-off-by: Zane van Iperen 
---
 Changelog|   1 +
 libavformat/Makefile |   1 +
 libavformat/allformats.c |   1 +
 libavformat/argo_brp.c   | 447 +++
 libavformat/version.h|   2 +-
 5 files changed, 451 insertions(+), 1 deletion(-)
 create mode 100644 libavformat/argo_brp.c

diff --git a/Changelog b/Changelog
index ff9ff2fcb8..2ccecfbcc9 100644
--- a/Changelog
+++ b/Changelog
@@ -21,6 +21,7 @@ version :
 - MOFLEX demuxer
 - MODS demuxer
 - PhotoCD decoder
+- Argonaut Games BRP demuxer
 
 
 version 4.3:
diff --git a/libavformat/Makefile b/libavformat/Makefile
index 2368bc15ac..062f3bd9c2 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -104,6 +104,7 @@ OBJS-$(CONFIG_APTX_HD_MUXER) += rawenc.o
 OBJS-$(CONFIG_AQTITLE_DEMUXER)   += aqtitledec.o subtitles.o
 OBJS-$(CONFIG_ARGO_ASF_DEMUXER)  += argo_asf.o
 OBJS-$(CONFIG_ARGO_ASF_MUXER)+= argo_asf.o
+OBJS-$(CONFIG_ARGO_BRP_DEMUXER)  += argo_brp.o argo_asf.o
 OBJS-$(CONFIG_ASF_DEMUXER)   += asfdec_f.o asf.o asfcrypt.o \
 avlanguage.o
 OBJS-$(CONFIG_ASF_O_DEMUXER) += asfdec_o.o asf.o asfcrypt.o \
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index 3438a14141..8e7556e529 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -65,6 +65,7 @@ extern AVOutputFormat ff_aptx_hd_muxer;
 extern AVInputFormat  ff_aqtitle_demuxer;
 extern AVInputFormat  ff_argo_asf_demuxer;
 extern AVOutputFormat ff_argo_asf_muxer;
+extern AVInputFormat  ff_argo_brp_demuxer;
 extern AVInputFormat  ff_asf_demuxer;
 extern AVOutputFormat ff_asf_muxer;
 extern AVInputFormat  ff_asf_o_demuxer;
diff --git a/libavformat/argo_brp.c b/libavformat/argo_brp.c
new file mode 100644
index 00..e8e58fb3d8
--- /dev/null
+++ b/libavformat/argo_brp.c
@@ -0,0 +1,447 @@
+/*
+ * Argonaut Games BRP Demuxer
+ *
+ * Copyright (C) 2020 Zane van Iperen (z...@zanevaniperen.com)
+ *
+ * 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 "avformat.h"
+#include "internal.h"
+#include "libavutil/intreadwrite.h"
+#include "libavutil/avassert.h"
+#include "libavutil/internal.h"
+#include "argo_asf.h"
+
+#define BRP_TAG MKTAG('B', 'R', 'P', 'P')
+#define BRP_FILE_HEADER_SIZE12
+#define BRP_BLOCK_HEADER_SIZE   12
+#define BRP_STREAM_HEADER_SIZE  20
+#define BRP_MAX_STREAMS 32 /* Soft cap, but even this is overkill. */
+#define BVID_HEADER_SIZE16
+#define BRP_MIN_BUFFER_SIZE FFMAX(FFMAX3(BRP_FILE_HEADER_SIZE,\
+ BRP_BLOCK_HEADER_SIZE,   \
+ BRP_STREAM_HEADER_SIZE), \
+  BVID_HEADER_SIZE)
+
+#define BRP_CODEC_ID_BVID   MKTAG('B', 'V', 'I', 'D')
+#define BRP_CODEC_ID_BASF   MKTAG('B', 'A', 'S', 'F')
+
+typedef struct ArgoBRPFileHeader {
+uint32_t magic;
+uint32_t num_streams;
+uint32_t byte_rate;
+} ArgoBRPFileHeader;
+
+typedef struct ArgoBRPBlockHeader {
+int32_t  stream_id;
+uint32_t start_ms;
+uint32_t size;
+} ArgoBRPBlockHeader;
+
+typedef struct ArgoBVIDHeader {
+uint32_t num_frames;
+uint32_t width;
+uint32_t height;
+uint32_t depth;
+} ArgoBVIDHeader;
+
+typedef struct ArgoBRPStreamHeader {
+uint32_t codec_id;
+uint32_t id;
+uint32_t duration_ms;
+uint32_t byte_rate;
+uint32_t extradata_size;
+union
+{
+/* If codec_id == BRP_CODEC_ID_BVID */
+ArgoBVIDHeaderbvid;
+/* If codec_id == BRP_CODEC_ID_BASF */
+ArgoASFFileHeader basf;
+} extradata;
+} ArgoBRPStreamHeader;
+
+typedef struct ArgoBRPDemuxContext {
+ArgoBRPFileHeader   fhdr;
+ArgoBRPStreamHeader *streams;
+/* To know how much of a BASF to give. */
+int64_t lastpts;
+int hit_eof;
+
+/* BASF-specific fields. */
+struct {
+int index;

[FFmpeg-devel] [PATCH 4/5] avcodec: add "Argonaut Games Video" descriptor

2020-09-07 Thread Zane van Iperen
Signed-off-by: Zane van Iperen 
---
 libavcodec/codec_desc.c | 7 +++
 libavcodec/codec_id.h   | 1 +
 libavcodec/version.h| 2 +-
 3 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
index 9e73dcba27..f33585adaa 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -1412,6 +1412,13 @@ static const AVCodecDescriptor codec_descriptors[] = {
 .long_name = NULL_IF_CONFIG_SMALL("PGX (JPEG2000 Test Format)"),
 .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
 },
+{
+.id= AV_CODEC_ID_ARGO,
+.type  = AVMEDIA_TYPE_VIDEO,
+.name  = "argo",
+.long_name = NULL_IF_CONFIG_SMALL("Argonaut Games Video"),
+.props = AV_CODEC_PROP_LOSSY,
+},
 {
 .id= AV_CODEC_ID_Y41P,
 .type  = AVMEDIA_TYPE_VIDEO,
diff --git a/libavcodec/codec_id.h b/libavcodec/codec_id.h
index e4eca5d580..3d115187b4 100644
--- a/libavcodec/codec_id.h
+++ b/libavcodec/codec_id.h
@@ -242,6 +242,7 @@ enum AVCodecID {
 AV_CODEC_ID_RSCC,
 AV_CODEC_ID_AVS2,
 AV_CODEC_ID_PGX,
+AV_CODEC_ID_ARGO,
 
 AV_CODEC_ID_Y41P = 0x8000,
 AV_CODEC_ID_AVRP,
diff --git a/libavcodec/version.h b/libavcodec/version.h
index 4b221f96ad..5ce4ba55d9 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -28,7 +28,7 @@
 #include "libavutil/version.h"
 
 #define LIBAVCODEC_VERSION_MAJOR  58
-#define LIBAVCODEC_VERSION_MINOR 105
+#define LIBAVCODEC_VERSION_MINOR 106
 #define LIBAVCODEC_VERSION_MICRO 100
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
-- 
2.25.4


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

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

[FFmpeg-devel] [PATCH 0/5] Add demuxer for Argonaut Games BRP files

2020-09-07 Thread Zane van Iperen
Adds support for demuxing BRP files from Argonaut Games' games.
Used to store the FMVs.

Zane van Iperen (5):
  avformat/argo_asf: bail if invalid tag
  avformat/argo_asf: split functionality into a header
  avformat/argo_asf: add ASF_MIN_BUFFER_SIZE #define
  avcodec: add "Argonaut Games Video" descriptor
  avformat: add Argonaut Games BRP demuxer

 Changelog|   1 +
 libavcodec/codec_desc.c  |   7 +
 libavcodec/codec_id.h|   1 +
 libavcodec/version.h |   2 +-
 libavformat/Makefile |   1 +
 libavformat/allformats.c |   1 +
 libavformat/argo_asf.c   | 203 --
 libavformat/argo_asf.h   |  69 ++
 libavformat/argo_brp.c   | 447 +++
 libavformat/version.h|   2 +-
 10 files changed, 622 insertions(+), 112 deletions(-)
 create mode 100644 libavformat/argo_asf.h
 create mode 100644 libavformat/argo_brp.c

-- 
2.25.4


___
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] avformat/argo_asf: add ASF_MIN_BUFFER_SIZE #define

2020-09-07 Thread Zane van Iperen
For future use by the argo_brp demuxer

Signed-off-by: Zane van Iperen 
---
 libavformat/argo_asf.c | 2 +-
 libavformat/argo_asf.h | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavformat/argo_asf.c b/libavformat/argo_asf.c
index ee8c85f735..c131207aa1 100644
--- a/libavformat/argo_asf.c
+++ b/libavformat/argo_asf.c
@@ -182,7 +182,7 @@ static int argo_asf_read_header(AVFormatContext *s)
 AVIOContext *pb = s->pb;
 AVStream *st;
 ArgoASFDemuxContext *asf = s->priv_data;
-uint8_t buf[FFMAX(ASF_FILE_HEADER_SIZE, ASF_CHUNK_HEADER_SIZE)];
+uint8_t buf[ASF_MIN_BUFFER_SIZE];
 
 if (!(st = avformat_new_stream(s, NULL)))
 return AVERROR(ENOMEM);
diff --git a/libavformat/argo_asf.h b/libavformat/argo_asf.h
index 905769dafe..8b1c6d5e2f 100644
--- a/libavformat/argo_asf.h
+++ b/libavformat/argo_asf.h
@@ -24,11 +24,13 @@
 #define AVFORMAT_ARGO_ASF_H
 
 #include 
+#include "libavutil/common.h"
 
 #define ASF_TAG MKTAG('A', 'S', 'F', '\0')
 #define ASF_FILE_HEADER_SIZE24
 #define ASF_CHUNK_HEADER_SIZE   20
 #define ASF_SAMPLE_COUNT32
+#define ASF_MIN_BUFFER_SIZE FFMAX(ASF_FILE_HEADER_SIZE, 
ASF_CHUNK_HEADER_SIZE)
 
 typedef struct ArgoASFFileHeader {
 uint32_tmagic;  /*< Magic Number, {'A', 'S', 'F', '\0'} */
-- 
2.25.4


___
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/argo_asf: split functionality into a header

2020-09-07 Thread Zane van Iperen
For future use by the argo_brp demuxer.

Adds:
  - void ff_argo_asf_parse_file_header(ArgoASFFileHeader *hdr, const uint8_t 
*buf);
  - int  ff_argo_asf_validate_file_header(AVFormatContext *s, const 
ArgoASFFileHeader *hdr);
  - void ff_argo_asf_parse_chunk_header(ArgoASFChunkHeader *hdr, const uint8_t 
*buf);
  - int  ff_argo_asf_fill_stream(AVStream *st, const ArgoASFChunkHeader *ckhdr);
Signed-off-by: Zane van Iperen 
---
 libavformat/argo_asf.c | 204 +++--
 libavformat/argo_asf.h |  67 ++
 2 files changed, 159 insertions(+), 112 deletions(-)
 create mode 100644 libavformat/argo_asf.h

diff --git a/libavformat/argo_asf.c b/libavformat/argo_asf.c
index 208280b4d9..ee8c85f735 100644
--- a/libavformat/argo_asf.c
+++ b/libavformat/argo_asf.c
@@ -24,39 +24,7 @@
 #include "libavutil/intreadwrite.h"
 #include "libavutil/avassert.h"
 #include "libavutil/opt.h"
-
-#define ASF_TAG MKTAG('A', 'S', 'F', '\0')
-#define ASF_FILE_HEADER_SIZE24
-#define ASF_CHUNK_HEADER_SIZE   20
-#define ASF_SAMPLE_COUNT32
-
-typedef struct ArgoASFFileHeader {
-uint32_tmagic;  /*< Magic Number, {'A', 'S', 'F', '\0'} */
-uint16_tversion_major;  /*< File Major Version. */
-uint16_tversion_minor;  /*< File Minor Version. */
-uint32_tnum_chunks; /*< No. chunks in the file. */
-uint32_tchunk_offset;   /*< Offset to the first chunk from the start 
of the file. */
-int8_t  name[8];/*< Name. */
-} ArgoASFFileHeader;
-
-typedef struct ArgoASFChunkHeader {
-uint32_tnum_blocks; /*< No. blocks in the chunk. */
-uint32_tnum_samples;/*< No. samples per channel in a block. Always 
32. */
-uint32_tunk1;   /*< Unknown */
-uint16_tsample_rate;/*< Sample rate. */
-uint16_tunk2;   /*< Unknown. */
-uint32_tflags;  /*< Stream flags. */
-} ArgoASFChunkHeader;
-
-enum {
-ASF_CF_BITS_PER_SAMPLE  = (1 << 0), /*< 16-bit if set, 8 otherwise.  */
-ASF_CF_STEREO   = (1 << 1), /*< Stereo if set, mono otherwise.   */
-ASF_CF_ALWAYS1_1= (1 << 2), /*< Unknown, always seems to be set. */
-ASF_CF_ALWAYS1_2= (1 << 3), /*< Unknown, always seems to be set. */
-
-ASF_CF_ALWAYS1  = ASF_CF_ALWAYS1_1 | ASF_CF_ALWAYS1_2,
-ASF_CF_ALWAYS0  = ~(ASF_CF_BITS_PER_SAMPLE | ASF_CF_STEREO | 
ASF_CF_ALWAYS1)
-};
+#include "argo_asf.h"
 
 typedef struct ArgoASFDemuxContext {
 ArgoASFFileHeader   fhdr;
@@ -71,8 +39,7 @@ typedef struct ArgoASFMuxContext {
 const char*name;
 } ArgoASFMuxContext;
 
-#if CONFIG_ARGO_ASF_DEMUXER
-static void argo_asf_parse_file_header(ArgoASFFileHeader *hdr, const uint8_t 
*buf)
+void ff_argo_asf_parse_file_header(ArgoASFFileHeader *hdr, const uint8_t *buf)
 {
 hdr->magic  = AV_RL32(buf + 0);
 hdr->version_major  = AV_RL16(buf + 4);
@@ -83,7 +50,23 @@ static void argo_asf_parse_file_header(ArgoASFFileHeader 
*hdr, const uint8_t *bu
 hdr->name[i]= AV_RL8(buf + 16 + i);
 }
 
-static void argo_asf_parse_chunk_header(ArgoASFChunkHeader *hdr, const uint8_t 
*buf)
+int ff_argo_asf_validate_file_header(AVFormatContext *s, const 
ArgoASFFileHeader *hdr)
+{
+if (hdr->magic != ASF_TAG || hdr->num_chunks == 0)
+return AVERROR_INVALIDDATA;
+
+if (hdr->num_chunks > 1) {
+avpriv_request_sample(s, ">1 chunk");
+return AVERROR_PATCHWELCOME;
+}
+
+if (hdr->chunk_offset < ASF_FILE_HEADER_SIZE)
+return AVERROR_INVALIDDATA;
+
+return 0;
+}
+
+void ff_argo_asf_parse_chunk_header(ArgoASFChunkHeader *hdr, const uint8_t 
*buf)
 {
 hdr->num_blocks = AV_RL32(buf + 0);
 hdr->num_samples= AV_RL32(buf + 4);
@@ -93,6 +76,73 @@ static void argo_asf_parse_chunk_header(ArgoASFChunkHeader 
*hdr, const uint8_t *
 hdr->flags  = AV_RL32(buf + 16);
 }
 
+int ff_argo_asf_fill_stream(AVStream *st, const ArgoASFFileHeader *fhdr,
+const ArgoASFChunkHeader *ckhdr)
+{
+if (ckhdr->num_samples != ASF_SAMPLE_COUNT) {
+av_log(st, AV_LOG_ERROR, "Invalid sample count. Got %u, expected %d\n",
+   ckhdr->num_samples, ASF_SAMPLE_COUNT);
+return AVERROR_INVALIDDATA;
+}
+
+if ((ckhdr->flags & ASF_CF_ALWAYS1) != ASF_CF_ALWAYS1 || (ckhdr->flags & 
ASF_CF_ALWAYS0) != 0) {
+avpriv_request_sample(st, "Nonstandard flags (0x%08X)", ckhdr->flags);
+return AVERROR_PATCHWELCOME;
+}
+
+st->codecpar->codec_type= AVMEDIA_TYPE_AUDIO;
+st->codecpar->codec_id  = AV_CODEC_ID_ADPCM_ARGO;
+st->codecpar->format= AV_SAMPLE_FMT_S16P;
+
+if (ckhdr->flags & ASF_CF_STEREO) {
+st->codecpar->channel_layout= AV_CH_LAYOUT_STEREO;
+st->codecpar->channels  = 2;
+} else {
+st->codecpar->channel_layout= AV_CH_LAYOUT_MONO;
+   

[FFmpeg-devel] [PATCH 1/5] avformat/argo_asf: bail if invalid tag

2020-09-07 Thread Zane van Iperen
Signed-off-by: Zane van Iperen 
---
 libavformat/argo_asf.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libavformat/argo_asf.c b/libavformat/argo_asf.c
index bf9b5d0c0a..208280b4d9 100644
--- a/libavformat/argo_asf.c
+++ b/libavformat/argo_asf.c
@@ -144,6 +144,9 @@ static int argo_asf_read_header(AVFormatContext *s)
 
 argo_asf_parse_file_header(>fhdr, buf);
 
+if (asf->fhdr.magic != ASF_TAG)
+return AVERROR_INVALIDDATA;
+
 if (asf->fhdr.num_chunks == 0) {
 return AVERROR_INVALIDDATA;
 } else if (asf->fhdr.num_chunks > 1) {
-- 
2.25.4


___
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/hlsenc: Fix playlist not getting flushed when using custom io

2020-09-07 Thread Steven Liu
Steve Lam  于2020年9月7日周一 上午3:23写道:
>
> ---
>  libavformat/hlsenc.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> index cb31d6aed7..fdfa907234 100644
> --- a/libavformat/hlsenc.c
> +++ b/libavformat/hlsenc.c
> @@ -287,6 +287,7 @@ static int hlsenc_io_close(AVFormatContext *s, 
> AVIOContext **pb, char *filename)
>  if (!*pb)
>  return ret;
>  if (!http_base_proto || !hls->http_persistent || hls->key_info_file || 
> hls->encrypt) {
> +avio_flush(*pb);
>  ff_format_io_close(s, pb);
>  #if CONFIG_HTTP_PROTOCOL
>  } else {
> --
> 2.17.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".


LGTM

Thanks
Steven
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

[FFmpeg-devel] [PATCH v2 3/3] avcodec/mips: Optimize function ff_h264_loop_filter_strength_msa.

2020-09-07 Thread Shiyou Yin
From: gxw 

Speed of decoding H264: 5.45x ==> 5.53x

Signed-off-by: Shiyou Yin 
---
 libavcodec/mips/Makefile|   3 +-
 libavcodec/mips/h264_deblock_msa.c  | 153 
 libavcodec/mips/h264dsp_init_mips.c |   2 +
 libavcodec/mips/h264dsp_mips.h  |   4 +
 4 files changed, 161 insertions(+), 1 deletion(-)
 create mode 100644 libavcodec/mips/h264_deblock_msa.c

diff --git a/libavcodec/mips/Makefile b/libavcodec/mips/Makefile
index 2be4d9b..81a73a4 100644
--- a/libavcodec/mips/Makefile
+++ b/libavcodec/mips/Makefile
@@ -57,7 +57,8 @@ MSA-OBJS-$(CONFIG_VP8_DECODER)+= 
mips/vp8_mc_msa.o \
  mips/vp8_lpf_msa.o
 MSA-OBJS-$(CONFIG_VP3DSP) += mips/vp3dsp_idct_msa.o
 MSA-OBJS-$(CONFIG_H264DSP)+= mips/h264dsp_msa.o\
- mips/h264idct_msa.o
+ mips/h264idct_msa.o   \
+ mips/h264_deblock_msa.o
 MSA-OBJS-$(CONFIG_H264QPEL)   += mips/h264qpel_msa.o
 MSA-OBJS-$(CONFIG_H264CHROMA) += mips/h264chroma_msa.o
 MSA-OBJS-$(CONFIG_H264PRED)   += mips/h264pred_msa.o
diff --git a/libavcodec/mips/h264_deblock_msa.c 
b/libavcodec/mips/h264_deblock_msa.c
new file mode 100644
index 000..4fed55c
--- /dev/null
+++ b/libavcodec/mips/h264_deblock_msa.c
@@ -0,0 +1,153 @@
+/*
+ * MIPS SIMD optimized H.264 deblocking code
+ *
+ * Copyright (c) 2020 Loongson Technology Corporation Limited
+ *Gu Xiwei 
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavcodec/bit_depth_template.c"
+#include "h264dsp_mips.h"
+#include "libavutil/mips/generic_macros_msa.h"
+#include "libavcodec/mips/h264dsp_mips.h"
+
+#define h264_loop_filter_strength_iteration_msa(edges, step, mask_mv, dir, \
+d_idx, mask_dir)   \
+do {   \
+int b_idx = 0; \
+int step_x4 = step << 2; \
+int d_idx_12 = d_idx + 12; \
+int d_idx_52 = d_idx + 52; \
+int d_idx_x4 = d_idx << 2; \
+int d_idx_x4_48 = d_idx_x4 + 48; \
+int dir_x32  = dir * 32; \
+uint8_t *ref_t = (uint8_t*)ref; \
+uint8_t *mv_t  = (uint8_t*)mv; \
+uint8_t *nnz_t = (uint8_t*)nnz; \
+uint8_t *bS_t  = (uint8_t*)bS; \
+mask_mv <<= 3; \
+for (; b_idx < edges; b_idx += step) { \
+out &= mask_dir; \
+if (!(mask_mv & b_idx)) { \
+if (bidir) { \
+ref_2 = LD_SB(ref_t + d_idx_12); \
+ref_3 = LD_SB(ref_t + d_idx_52); \
+ref_0 = LD_SB(ref_t + 12); \
+ref_1 = LD_SB(ref_t + 52); \
+ref_2 = (v16i8)__msa_ilvr_w((v4i32)ref_3, (v4i32)ref_2); \
+ref_0 = (v16i8)__msa_ilvr_w((v4i32)ref_0, (v4i32)ref_0); \
+ref_1 = (v16i8)__msa_ilvr_w((v4i32)ref_1, (v4i32)ref_1); \
+ref_3 = (v16i8)__msa_shf_h((v8i16)ref_2, 0x4e); \
+ref_0 -= ref_2; \
+ref_1 -= ref_3; \
+ref_0 = (v16i8)__msa_or_v((v16u8)ref_0, (v16u8)ref_1); \
+\
+tmp_2 = LD_SH(mv_t + d_idx_x4_48);   \
+tmp_3 = LD_SH(mv_t + 48); \
+tmp_4 = LD_SH(mv_t + 208); \
+tmp_5 = tmp_2 - tmp_3; \
+tmp_6 = tmp_2 - tmp_4; \
+SAT_SH2_SH(tmp_5, tmp_6, 7); \
+tmp_0 = __msa_pckev_b((v16i8)tmp_6, (v16i8)tmp_5); \
+tmp_0 += cnst_1; \
+tmp_0 = (v16i8)__msa_subs_u_b((v16u8)tmp_0, (v16u8)cnst_0);\
+tmp_0 = (v16i8)__msa_sat_s_h((v8i16)tmp_0, 7); \
+tmp_0 = __msa_pckev_b(tmp_0, tmp_0); \
+out   = (v16i8)__msa_or_v((v16u8)ref_0, (v16u8)tmp_0); \
+\
+tmp_2 = LD_SH(mv_t + 208 + d_idx_x4); \
+tmp_5 = tmp_2 - tmp_3; \
+tmp_6 = tmp_2 - tmp_4; \
+SAT_SH2_SH(tmp_5, tmp_6, 7); \
+tmp_1 = __msa_pckev_b((v16i8)tmp_6, (v16i8)tmp_5); \
+tmp_1 += cnst_1; \
+tmp_1 = 

[FFmpeg-devel] [PATCH v2 1/3] avcodec/mips: Restore the initialization sequence of MSA and MMI in ff_h264chroma_init_mips.

2020-09-07 Thread Shiyou Yin
Speed of decoding H264: 5.14x ==> 5.23x (tested on 3A4000).
---
 libavcodec/mips/h264chroma_init_mips.c | 19 +--
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/libavcodec/mips/h264chroma_init_mips.c 
b/libavcodec/mips/h264chroma_init_mips.c
index 6bb19d3..755cc04 100644
--- a/libavcodec/mips/h264chroma_init_mips.c
+++ b/libavcodec/mips/h264chroma_init_mips.c
@@ -28,7 +28,15 @@ av_cold void ff_h264chroma_init_mips(H264ChromaContext *c, 
int bit_depth)
 int cpu_flags = av_get_cpu_flags();
 int high_bit_depth = bit_depth > 8;
 
-/* MMI apears to be faster than MSA here */
+if (have_mmi(cpu_flags)) {
+if (!high_bit_depth) {
+c->put_h264_chroma_pixels_tab[0] = ff_put_h264_chroma_mc8_mmi;
+c->avg_h264_chroma_pixels_tab[0] = ff_avg_h264_chroma_mc8_mmi;
+c->put_h264_chroma_pixels_tab[1] = ff_put_h264_chroma_mc4_mmi;
+c->avg_h264_chroma_pixels_tab[1] = ff_avg_h264_chroma_mc4_mmi;
+}
+}
+
 if (have_msa(cpu_flags)) {
 if (!high_bit_depth) {
 c->put_h264_chroma_pixels_tab[0] = ff_put_h264_chroma_mc8_msa;
@@ -40,13 +48,4 @@ av_cold void ff_h264chroma_init_mips(H264ChromaContext *c, 
int bit_depth)
 c->avg_h264_chroma_pixels_tab[2] = ff_avg_h264_chroma_mc2_msa;
 }
 }
-
-if (have_mmi(cpu_flags)) {
-if (!high_bit_depth) {
-c->put_h264_chroma_pixels_tab[0] = ff_put_h264_chroma_mc8_mmi;
-c->avg_h264_chroma_pixels_tab[0] = ff_avg_h264_chroma_mc8_mmi;
-c->put_h264_chroma_pixels_tab[1] = ff_put_h264_chroma_mc4_mmi;
-c->avg_h264_chroma_pixels_tab[1] = ff_avg_h264_chroma_mc4_mmi;
-}
-}
 }
-- 
2.1.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 v2 2/3] avcodec/mips: Refine get_cabac_inline_mips.

2020-09-07 Thread Shiyou Yin
1. Refined function get_cabac_inline_mips.
2. Optimize function get_cabac_bypass and get_cabac_bypass_sign.

Speed of decoding h264: 5.23x ==> 5.45x(tested on 3A4000).
---
 libavcodec/mips/cabac.h | 131 +---
 1 file changed, 102 insertions(+), 29 deletions(-)

diff --git a/libavcodec/mips/cabac.h b/libavcodec/mips/cabac.h
index 3d09e93..0ee7594 100644
--- a/libavcodec/mips/cabac.h
+++ b/libavcodec/mips/cabac.h
@@ -2,7 +2,8 @@
  * Loongson SIMD optimized h264chroma
  *
  * Copyright (c) 2018 Loongson Technology Corporation Limited
- * Copyright (c) 2018 Shiyou Yin 
+ * Contributed by Shiyou Yin 
+ *Gu Xiwei(guxiwei...@loongson.cn)
  *
  * This file is part of FFmpeg.
  *
@@ -25,18 +26,18 @@
 #define AVCODEC_MIPS_CABAC_H
 
 #include "libavcodec/cabac.h"
-#include "libavutil/mips/asmdefs.h"
+#include "libavutil/mips/mmiutils.h"
 #include "config.h"
 
 #define get_cabac_inline get_cabac_inline_mips
 static av_always_inline int get_cabac_inline_mips(CABACContext *c,
- uint8_t * const state){
+  uint8_t * const state){
 mips_reg tmp0, tmp1, tmp2, bit;
 
 __asm__ volatile (
 "lbu  %[bit],0(%[state])   \n\t"
 "and  %[tmp0],   %[c_range], 0xC0  \n\t"
-PTR_ADDU "%[tmp0],   %[tmp0],%[tmp0]   \n\t"
+PTR_SLL  "%[tmp0],   %[tmp0],0x01  \n\t"
 PTR_ADDU "%[tmp0],   %[tmp0],%[tables] \n\t"
 PTR_ADDU "%[tmp0],   %[tmp0],%[bit]\n\t"
 /* tmp1: RangeLPS */
@@ -44,18 +45,11 @@ static av_always_inline int 
get_cabac_inline_mips(CABACContext *c,
 
 PTR_SUBU "%[c_range],%[c_range], %[tmp1]   \n\t"
 PTR_SLL  "%[tmp0],   %[c_range], 0x11  \n\t"
-PTR_SUBU "%[tmp0],   %[tmp0],%[c_low]  \n\t"
-
-/* tmp2: lps_mask */
-PTR_SRA  "%[tmp2],   %[tmp0],0x1F  \n\t"
-/* If tmp0 < 0, lps_mask ==  0x*/
-/* If tmp0 >= 0, lps_mask ==  0x*/
+"slt  %[tmp2],   %[tmp0],%[c_low]  \n\t"
 "beqz %[tmp2],   1f\n\t"
-PTR_SLL  "%[tmp0],   %[c_range], 0x11  \n\t"
+"move %[c_range],%[tmp1]   \n\t"
+"not  %[bit],%[bit]\n\t"
 PTR_SUBU "%[c_low],  %[c_low],   %[tmp0]   \n\t"
-PTR_SUBU "%[tmp0],   %[tmp1],%[c_range]\n\t"
-PTR_ADDU "%[c_range],%[c_range], %[tmp0]   \n\t"
-"xor  %[bit],%[bit], %[tmp2]   \n\t"
 
 "1:\n\t"
 /* tmp1: *state */
@@ -70,23 +64,18 @@ static av_always_inline int 
get_cabac_inline_mips(CABACContext *c,
 PTR_SLL  "%[c_range],%[c_range], %[tmp2]   \n\t"
 PTR_SLL  "%[c_low],  %[c_low],   %[tmp2]   \n\t"
 
-"and  %[tmp0],   %[c_low],   %[cabac_mask] \n\t"
-"bnez %[tmp0],   1f\n\t"
-PTR_ADDIU"%[tmp0],   %[c_low],   -0x01 \n\t"
+"and  %[tmp1],   %[c_low],   %[cabac_mask] \n\t"
+"bnez %[tmp1],   1f\n\t"
+PTR_ADDIU"%[tmp0],   %[c_low],   -0X01 \n\t"
 "xor  %[tmp0],   %[c_low],   %[tmp0]   \n\t"
 PTR_SRA  "%[tmp0],   %[tmp0],0x0f  \n\t"
 PTR_ADDU "%[tmp0],   %[tmp0],%[tables] \n\t"
+/* tmp2: ff_h264_norm_shift[x >> (CABAC_BITS - 1)] */
 "lbu  %[tmp2],   %[norm_off](%[tmp0])  \n\t"
-#if CABAC_BITS == 16
-"lbu  %[tmp0],   0(%[c_bytestream])\n\t"
-"lbu  %[tmp1],   1(%[c_bytestream])\n\t"
-PTR_SLL  "%[tmp0],   %[tmp0],0x09  \n\t"
-PTR_SLL  "%[tmp1],   %[tmp1],0x01  \n\t"
-PTR_ADDU "%[tmp0],   %[tmp0],%[tmp1]   \n\t"
-#else
-"lbu  %[tmp0],   0(%[c_bytestream])\n\t"
+
+"lhu  %[tmp0],   0(%[c_bytestream])\n\t"
+"wsbh %[tmp0],   %[tmp0]   \n\t"
 PTR_SLL  "%[tmp0],   %[tmp0],0x01  \n\t"
-#endif
 PTR_SUBU "%[tmp0],   %[tmp0],%[cabac_mask] \n\t"
 
 "li   %[tmp1],   0x07  \n\t"
@@ -94,10 +83,13 @@ static av_always_inline int 
get_cabac_inline_mips(CABACContext *c,
  

[FFmpeg-devel] [loongson] Optimize H264 decoding.

2020-09-07 Thread Shiyou Yin
H264 decoding speed: 154fps ==> 165fps, 5.14x ==> 5.53x (tested on 3A4000)

V2: Fixed a build error in [PATCH 2/3].
"Error: opcode not supported on this processor: mips32r2 (mips32r2) `dsbh 
$10,$10'"

[PATCH 1/3] avcodec/mips: Restore the initialization sequence of MSA. 
[PATCH 2/3] avcodec/mips: Refine get_cabac_inline_mips.
[PATCH 3/3] avcodec/mips: Optimize function ff_h264_loop_filter_strength_msa.

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

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

Re: [FFmpeg-devel] [PATCH 1/3] avformat/mxfdec: Read Mastering Display Colour Volume from MXF

2020-09-07 Thread Tomas Härdin
mån 2020-09-07 klockan 11:40 +0200 skrev Tomas Härdin:
> mån 2020-08-31 klockan 20:07 +0100 skrev Harry Mallon:
> > +static const uint8_t mxf_mastering_display_primaries[]= { 
> > 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x04,0x20,0x04,0x01,0x01,0x01,0x00,0x00
> >  };
> > +static const uint8_t mxf_mastering_display_white_point_chromaticity[] = { 
> > 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x04,0x20,0x04,0x01,0x01,0x02,0x00,0x00
> >  };
> > +static const uint8_t mxf_mastering_display_maximum_luminance[]= { 
> > 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x04,0x20,0x04,0x01,0x01,0x03,0x00,0x00
> >  };
> > +static const uint8_t mxf_mastering_display_minimum_luminance[]= { 
> > 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x04,0x20,0x04,0x01,0x01,0x04,0x00,0x00
> >  };
> 
> I can't find any of these ULs in any of the specs I have on hand. Are
> they all defined in 2067-21? ULs for for example primaries are already
> defined in RP210 (06.0E.2B.34.01.01.01.09.04.01.02.01.01.06.00.00) and
> RP224 (06.0E.2B.34.04.01.01.06.04.01.01.01.03.00.00.00).

Small update: I grabbed a copy of ST 2067-21:2020 and these ULs do not
appear (search for "04.20.04"). What gives?

/Tomas

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

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

Re: [FFmpeg-devel] [PATCH] Support HDR10+ metadata for HEVC.

2020-09-07 Thread Jan Ekström
On Sat, Jul 25, 2020 at 12:09 AM Mohammad Izadi
 wrote:
>
> On Fri, Jul 24, 2020 at 9:30 AM Andreas Rheinhardt <
> andreas.rheinha...@gmail.com> wrote:
>
> > Mohammad Izadi:
> > > From: Mohammad Izadi 
> > >
> > > HDR10+ is dynamic metadata (A/341 Amendment - SMPTE2094-40) that needs
> > to be decoded from ITU-T T.35 in HEVC bitstream. The HDR10+ is transferred
> > to side data packet to be used or passed through.
> > > ---
> > >  libavcodec/avpacket.c |   1 +
> > >  libavcodec/decode.c   |   1 +
> > >  libavcodec/hevc_sei.c |  39 ++---
> > >  libavcodec/hevc_sei.h |   5 ++
> > >  libavcodec/hevcdec.c  |  16 
> > >  libavcodec/internal.h |   9 +++
> > >  libavcodec/packet.h   |   8 ++
> > >  libavcodec/utils.c| 180 ++
> > >  libavcodec/version.h  |   2 +-
> > >  9 files changed, 248 insertions(+), 13 deletions(-)
> > >
> > > diff --git a/libavcodec/avpacket.c b/libavcodec/avpacket.c
> > > index dce26cb31a..8307032335 <(830)%20703-2335> 100644
> > > --- a/libavcodec/avpacket.c
> > > +++ b/libavcodec/avpacket.c
> > > @@ -394,6 +394,7 @@ const char *av_packet_side_data_name(enum
> > AVPacketSideDataType type)
> > >  case AV_PKT_DATA_CONTENT_LIGHT_LEVEL:return "Content light
> > level metadata";
> > >  case AV_PKT_DATA_SPHERICAL:  return "Spherical
> > Mapping";
> > >  case AV_PKT_DATA_A53_CC: return "A53 Closed
> > Captions";
> > > +case AV_PKT_DATA_DYNAMIC_HDR_PLUS:   return "HDR10+ Dynamic
> > Metadata (SMPTE 2094-40)";
> > >  case AV_PKT_DATA_ENCRYPTION_INIT_INFO:   return "Encryption
> > initialization data";
> > >  case AV_PKT_DATA_ENCRYPTION_INFO:return "Encryption
> > info";
> > >  case AV_PKT_DATA_AFD:return "Active Format
> > Description data";
> > > diff --git a/libavcodec/decode.c b/libavcodec/decode.c
> > > index de9c079f9d..cd3286f7fb 100644
> > > --- a/libavcodec/decode.c
> > > +++ b/libavcodec/decode.c
> > > @@ -1698,6 +1698,7 @@ int ff_decode_frame_props(AVCodecContext *avctx,
> > AVFrame *frame)
> > >  { AV_PKT_DATA_MASTERING_DISPLAY_METADATA,
> > AV_FRAME_DATA_MASTERING_DISPLAY_METADATA },
> > >  { AV_PKT_DATA_CONTENT_LIGHT_LEVEL,
> > AV_FRAME_DATA_CONTENT_LIGHT_LEVEL },
> > >  { AV_PKT_DATA_A53_CC, AV_FRAME_DATA_A53_CC
> > },
> > > +{ AV_PKT_DATA_DYNAMIC_HDR_PLUS,
> >  AV_FRAME_DATA_DYNAMIC_HDR_PLUS },
> > >  { AV_PKT_DATA_ICC_PROFILE,
> > AV_FRAME_DATA_ICC_PROFILE },
> > >  };
> > >
> > > diff --git a/libavcodec/hevc_sei.c b/libavcodec/hevc_sei.c
> > > index a4ec65dc1a..a490e752dd 100644
> > > --- a/libavcodec/hevc_sei.c
> > > +++ b/libavcodec/hevc_sei.c
> > > @@ -25,6 +25,7 @@
> > >  #include "golomb.h"
> > >  #include "hevc_ps.h"
> > >  #include "hevc_sei.h"
> > > +#include "internal.h"
> > >
> > >  static int decode_nal_sei_decoded_picture_hash(HEVCSEIPictureHash *s,
> > GetBitContext *gb)
> > >  {
> > > @@ -242,8 +243,8 @@ static int
> > decode_nal_sei_user_data_unregistered(HEVCSEIUnregistered *s, GetBitC
> > >  static int decode_nal_sei_user_data_registered_itu_t_t35(HEVCSEI *s,
> > GetBitContext *gb,
> > >   int size)
> > >  {
> > > -uint32_t country_code;
> > > -uint32_t user_identifier;
> > > +uint8_t country_code;
> > > +uint16_t provider_code;
> > >
> > >  if (size < 7)
> > >  return AVERROR(EINVAL);
> > > @@ -255,18 +256,31 @@ static int
> > decode_nal_sei_user_data_registered_itu_t_t35(HEVCSEI *s, GetBitConte
> > >  size--;
> > >  }
> > >
> > > -skip_bits(gb, 8);
> > > -skip_bits(gb, 8);
> > > -
> > > -user_identifier = get_bits_long(gb, 32);
> > > -
> > > -switch (user_identifier) {
> > > -case MKBETAG('G', 'A', '9', '4'):
> > > +provider_code = get_bits(gb, 16);
> > > +
> > > +const uint8_t usa_country_code = 0xB5;
> > > +const uint16_t smpte_provider_code = 0x003C;
> > > +if (country_code == usa_country_code &&
> > > +provider_code == smpte_provider_code) {
> > > +// A/341 Amendment – 2094-40
> > > +uint16_t provider_oriented_code = get_bits(gb, 16);
> > > +uint8_t application_identifier = get_bits(gb, 8);
> > > +const uint16_t smpte2094_40_provider_oriented_code = 0x0001;
> > > +const uint16_t smpte2094_40_application_identifier = 0x04;
> > > +if (provider_oriented_code ==
> > smpte2094_40_provider_oriented_code &&
> > > +application_identifier ==
> > smpte2094_40_application_identifier) {
> > > +int err = ff_read_itu_t_t35_to_dynamic_hdr_plus(gb, s->
> > dynamic_hdr_plus.info);
> > > +if (err < 0 && s->dynamic_hdr_plus.info) {
> > > +av_buffer_unref(>dynamic_hdr_plus.info);
> > > +}
> > > +return err;
> > > +}
> > > +} else {
> > > +uint32_t  

Re: [FFmpeg-devel] [PATCH 2/3] avformat/mxfenc: Write Mastering Display Colour Volume to MXF

2020-09-07 Thread Tomas Härdin
mån 2020-08-31 klockan 20:07 +0100 skrev Harry Mallon:
> +static const MXFLocalTagPair mxf_mastering_display_local_tags[] = {
> +{ 0x8201, 
> {0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x04,0x20,0x04,0x01,0x01,0x01,0x00,0x00}},
>  /* Mastering Display Primaries */
> +{ 0x8202, 
> {0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x04,0x20,0x04,0x01,0x01,0x02,0x00,0x00}},
>  /* Mastering Display White Point Chromaticity */
> +{ 0x8203, 
> {0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x04,0x20,0x04,0x01,0x01,0x03,0x00,0x00}},
>  /* Mastering Display Maximum Luminance */
> +{ 0x8204, 
> {0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x04,0x20,0x04,0x01,0x01,0x04,0x00,0x00}},
>  /* Mastering Display Minimum Luminance */
> +};

These conflict with existing local tags, as Marton says. It also
strikes me that these duplicate the keys already defined in patch 1.
Consider having both mxfdec and mxfenc share tables for them.

Maybe a better solution would be to have mxfenc automagically come up
with local tags for custom ULs, so we avoid these kinds of collisions
in the future.

/Tomas


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

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

Re: [FFmpeg-devel] [PATCH 3/3] avformat/mxfdec: Read Apple private Content Light Level from MXF

2020-09-07 Thread Tomas Härdin
mån 2020-08-31 klockan 20:07 +0100 skrev Harry Mallon:
> * As embedded by Apple Compressor

This needs a sample since it isn't part of any official spec, so that
we can have a test for this.

> +if (IS_KLV_KEY(uid, mxf_coll_apple_max_cll)) {
> +if (!descriptor->coll) {
> +descriptor->coll = 
> av_content_light_metadata_alloc(>coll_size);
> +if (!descriptor->coll)
> +return AVERROR(ENOMEM);
> +}

Duplicated allocation here as well. See my comment on PATCH 1/3.

/Tomas


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

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

Re: [FFmpeg-devel] [PATCH 1/3] avformat/mxfdec: Read Mastering Display Colour Volume from MXF

2020-09-07 Thread Tomas Härdin
mån 2020-08-31 klockan 20:07 +0100 skrev Harry Mallon:
> +static const uint8_t mxf_mastering_display_primaries[]= { 
> 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x04,0x20,0x04,0x01,0x01,0x01,0x00,0x00
>  };
> +static const uint8_t mxf_mastering_display_white_point_chromaticity[] = { 
> 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x04,0x20,0x04,0x01,0x01,0x02,0x00,0x00
>  };
> +static const uint8_t mxf_mastering_display_maximum_luminance[]= { 
> 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x04,0x20,0x04,0x01,0x01,0x03,0x00,0x00
>  };
> +static const uint8_t mxf_mastering_display_minimum_luminance[]= { 
> 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x04,0x20,0x04,0x01,0x01,0x04,0x00,0x00
>  };

I can't find any of these ULs in any of the specs I have on hand. Are
they all defined in 2067-21? ULs for for example primaries are already
defined in RP210 (06.0E.2B.34.01.01.01.09.04.01.02.01.01.06.00.00) and
RP224 (06.0E.2B.34.04.01.01.06.04.01.01.01.03.00.00.00).


> @@ -1272,6 +1280,60 @@ static int mxf_read_generic_descriptor(void *arg, 
> AVIOContext *pb, int tag, int
>  rsiz == FF_PROFILE_JPEG2000_DCINEMA_4K)
>  descriptor->pix_fmt = AV_PIX_FMT_XYZ12;
>  }
> +if (IS_KLV_KEY(uid, mxf_mastering_display_primaries)) {
> +const int chroma_den = 5;

I see this and luma_den used both here and in the mxfenc patch. Since
they're the same values, consider defining them as macros in mxf.h
instead.

> +int i;
> +if (!descriptor->mastering) {
> +descriptor->mastering = 
> av_mastering_display_metadata_alloc();
> +if (!descriptor->mastering)
> +return AVERROR(ENOMEM);
> +}

This exact code appears four times, should be de-duplicated. You could
for example do IS_KLV_KEY() with a prefix of all four keys
(0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x04,0x20,0x04,0x01,0x01)
before these four IS_KLV_KEY() ifs.

/Tomas

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

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