[FFmpeg-devel] Problem when remuxing mpeg4 from mp4 container to ts container

2016-11-07 Thread Fredrik Persson
Hi!

(I recently posted this on -user, but as I fear this might be a bug, I
decided to also post here (-devel).)

I have a problem where the resulting file from the following commands
produce a transport stream file that does not display video.

wget http://www.sample-videos.com/video/mp4/480/big_buck_bunny_480p_1mb.mp4

(Any mp4 file will probably be fine, but I used that one.)

Reencode the h264 video into mpeg4:

ffmpeg -i big_buck_bunny_480p_1mb.mp4 -acodec copy -vcodec mpeg4
big-mpeg4.mp4

Then convert the container from mp4 to transport stream:

ffmpeg -i big-mpeg4.mp4 -codec copy big-mpeg4.ts

The resulting file "big-mpeg4.ts" cannot be played by ffplay. It prints
tons of logs, but this one seems most important.

[mpeg4 @ 0x7f9af80008c0] [IMGUTILS @ 0x7f9afe8bb420] Picture size 0x0 is
invalid

Please note that if the operations are done in one single step, like this:

ffmpeg -i ~/streams/big_buck_bunny_480p_1mb.mp4 -acodec copy -vcodec mpeg4
big-mpeg4-2.ts

... ffplay has no problem, video is shown.

This behaviour is the same on these two ffmpeg versions:

ffmpeg version 2.8.8-0ubuntu0.16.04.1 Copyright (c) 2000-2016 the FFmpeg
developers (ubuntu 16.04 standard)
ffmpeg version N-82217-gb642290 Copyright (c) 2000-2016 the FFmpeg
developers (built myself)

Any ideas what could be wrong here?

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


Re: [FFmpeg-devel] [PATCH v4] avformat/flvenc: add add_keyframe_index option

2016-11-07 Thread Steven Liu
2016-11-08 15:13 GMT+08:00 Steven Liu :

> Add keyframe index metadata
> Used to facilitate seeking; particularly for HTTP pseudo streaming.
>  1. read live streaming or file by sequence
>  2. if use add_keyframe_index option, add a mark flag at the position,
> use to insert new context at the last step.
>  3. add the keyframes *offset* and *timestamp* into a list
>  4. if use add_keyframe_index option, shift the metadata data from
> mark flag offset
>  5. insert the keyframes *offset* and *timestamp* from the list by
> sequence
>  6. free the list
>  7. end.
>
> Add FATE test case;
> Test pass:
> PC Linux:
>
> ffmpeg version N-82288-gacd87df Copyright (c) 2000-2016 the FFmpeg
> developers
>   built with gcc 4.8 (Ubuntu 4.8.4-2ubuntu1~14.04.3)
>   configuration: --disable-yasm
>   libavutil  55. 35.100 / 55. 35.100
>   libavcodec 57. 66.101 / 57. 66.101
>   libavformat57. 57.100 / 57. 57.100
>   libavdevice57.  2.100 / 57.  2.100
>   libavfilter 6. 66.100 /  6. 66.100
>   libswscale  4.  3.100 /  4.  3.100
>   libswresample   2.  4.100 /  2.  4.100
>
> Wine + MingW:
>
> Application tried to create a window, but no driver could be loaded.
> Make sure that your X server is running and that $DISPLAY is set correctly.
> err:systray:initialize_systray Could not create tray window
> ffmpeg version N-82288-gacd87df Copyright (c) 2000-2016 the FFmpeg
> developers
>   built with gcc 4.8 (GCC)
>   configuration: --cc='ccache x86_64-w64-mingw32-gcc' --arch=x86_64
> --target-os=mingw32 --cross-prefix=x86_64-w64-mingw32- --disable-yasm
> --target_exec=wine
>   libavutil  55. 35.100 / 55. 35.100
>   libavcodec 57. 66.101 / 57. 66.101
>   libavformat57. 57.100 / 57. 57.100
>   libavdevice57.  2.100 / 57.  2.100
>   libavfilter 6. 66.100 /  6. 66.100
>   libswscale  4.  3.100 /  4.  3.100
>   libswresample   2.  4.100 /  2.  4.100
>
> qemu+mips:
> ffmpeg version N-82288-gacd87df Copyright (c) 2000-2016 the FFmpeg
> developers
>   built with gcc 4.4.5 (Debian 4.4.5-8)
>   configuration: --target-exec='qemu-mips -cpu 74Kf -L
> /usr/mips-linux-gnu/' --samples=... --enable-gpl 
> --cross-prefix=/usr/mips-linux-gnu/bin/
> --cc='ccache mips-linux-gnu-gcc-4.4' --arch=mips --target-os=linux
> --enable-cross-compile --disable-mipsfpu --disable-iconv
>   libavutil  55. 35.100 / 55. 35.100
>   libavcodec 57. 66.101 / 57. 66.101
>   libavformat57. 57.100 / 57. 57.100
>   libavdevice57.  2.100 / 57.  2.100
>   libavfilter 6. 66.100 /  6. 66.100
>   libswscale  4.  3.100 /  4.  3.100
>   libswresample   2.  4.100 /  2.  4.100
>   libpostproc54.  2.100 / 54.  2.100
>
> MacBook:
> ffmpeg version N-82275-g1a9e0d0 Copyright (c) 2000-2016 the FFmpeg
> developers
>   built with Apple LLVM version 8.0.0 (clang-800.0.42.1)
>   configuration: --enable-fontconfig --enable-gpl --enable-libass
> --enable-libbluray --enable-libfreetype --enable-libmp3lame
> --enable-libspeex --enable-libx264 --enable-libx265 --enable-version3
> --cc='ccache gcc'
>   libavutil  55. 35.100 / 55. 35.100
>   libavcodec 57. 66.101 / 57. 66.101
>   libavformat57. 57.100 / 57. 57.100
>   libavdevice57.  2.100 / 57.  2.100
>   libavfilter 6. 66.100 /  6. 66.100
>   libswscale  4.  3.100 /  4.  3.100
>   libswresample   2.  4.100 /  2.  4.100
>   libpostproc54.  2.100 / 54.  2.100
>
> Reviewed-by: Lou Logan 
> Signed-off-by: Steven Liu 
>
> ---
>  doc/muxers.texi   |3 +
>  libavformat/flvenc.c  |  331
> -
>  tests/Makefile|1 +
>  tests/fate-run.sh |4 +
>  tests/fate/flvenc.mak |   11 +
>  tests/ref/fate/flv-add_keyframe_index |   12 ++
>  6 files changed, 352 insertions(+), 10 deletions(-)
>  create mode 100644 tests/fate/flvenc.mak
>  create mode 100644 tests/ref/fate/flv-add_keyframe_index
>
> diff --git a/doc/muxers.texi b/doc/muxers.texi
> index 488ed43..806182a 100644
> --- a/doc/muxers.texi
> +++ b/doc/muxers.texi
> @@ -147,6 +147,9 @@ Place AAC sequence header based on audio stream data.
>
>  @item no_sequence_end
>  Disable sequence end tag.
> +
> +@item add_keyframe_index
> +Used to facilitate seeking; particularly for HTTP pseudo streaming.
>  @end table
>  @end table
>
> diff --git a/libavformat/flvenc.c b/libavformat/flvenc.c
> index e50f8e4..0cbf561 100644
> --- a/libavformat/flvenc.c
> +++ b/libavformat/flvenc.c
> @@ -24,6 +24,8 @@
>  #include "libavutil/intfloat.h"
>  #include "libavutil/avassert.h"
>  #include "libavutil/mathematics.h"
> +#include "avio_internal.h"
> +#include "avio.h"
>  #include "avc.h"
>  #include "avformat.h"
>  #include "flv.h"
> @@ -64,8 +66,15 @@ static const AVCodecTag flv_audio_codec_ids[] = {
>  typedef enum {
>  FLV_AAC_SEQ_HEADER_DETECT = (1 << 0),
>  FLV_NO_SEQUENCE_END = (1 << 1),
> +FLV_ADD_KEYFRAME_INDEX = (1 << 2),
>  } FLVFlags;
>
> +typedef struct FLVFileposit

[FFmpeg-devel] [PATCH v4] avformat/flvenc: add add_keyframe_index option

2016-11-07 Thread Steven Liu
Add keyframe index metadata
Used to facilitate seeking; particularly for HTTP pseudo streaming.
 1. read live streaming or file by sequence
 2. if use add_keyframe_index option, add a mark flag at the position,
use to insert new context at the last step.
 3. add the keyframes *offset* and *timestamp* into a list
 4. if use add_keyframe_index option, shift the metadata data from
mark flag offset
 5. insert the keyframes *offset* and *timestamp* from the list by
sequence
 6. free the list
 7. end.

Add FATE test case;
Test pass:
PC Linux:

ffmpeg version N-82288-gacd87df Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 4.8 (Ubuntu 4.8.4-2ubuntu1~14.04.3)
  configuration: --disable-yasm
  libavutil  55. 35.100 / 55. 35.100
  libavcodec 57. 66.101 / 57. 66.101
  libavformat57. 57.100 / 57. 57.100
  libavdevice57.  2.100 / 57.  2.100
  libavfilter 6. 66.100 /  6. 66.100
  libswscale  4.  3.100 /  4.  3.100
  libswresample   2.  4.100 /  2.  4.100

Wine + MingW:

Application tried to create a window, but no driver could be loaded.
Make sure that your X server is running and that $DISPLAY is set correctly.
err:systray:initialize_systray Could not create tray window
ffmpeg version N-82288-gacd87df Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 4.8 (GCC)
  configuration: --cc='ccache x86_64-w64-mingw32-gcc' --arch=x86_64 
--target-os=mingw32 --cross-prefix=x86_64-w64-mingw32- --disable-yasm 
--target_exec=wine
  libavutil  55. 35.100 / 55. 35.100
  libavcodec 57. 66.101 / 57. 66.101
  libavformat57. 57.100 / 57. 57.100
  libavdevice57.  2.100 / 57.  2.100
  libavfilter 6. 66.100 /  6. 66.100
  libswscale  4.  3.100 /  4.  3.100
  libswresample   2.  4.100 /  2.  4.100

qemu+mips:
ffmpeg version N-82288-gacd87df Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 4.4.5 (Debian 4.4.5-8)
  configuration: --target-exec='qemu-mips -cpu 74Kf -L /usr/mips-linux-gnu/' 
--samples=... --enable-gpl --cross-prefix=/usr/mips-linux-gnu/bin/ --cc='ccache 
mips-linux-gnu-gcc-4.4' --arch=mips --target-os=linux --enable-cross-compile 
--disable-mipsfpu --disable-iconv
  libavutil  55. 35.100 / 55. 35.100
  libavcodec 57. 66.101 / 57. 66.101
  libavformat57. 57.100 / 57. 57.100
  libavdevice57.  2.100 / 57.  2.100
  libavfilter 6. 66.100 /  6. 66.100
  libswscale  4.  3.100 /  4.  3.100
  libswresample   2.  4.100 /  2.  4.100
  libpostproc54.  2.100 / 54.  2.100

MacBook:
ffmpeg version N-82275-g1a9e0d0 Copyright (c) 2000-2016 the FFmpeg developers
  built with Apple LLVM version 8.0.0 (clang-800.0.42.1)
  configuration: --enable-fontconfig --enable-gpl --enable-libass 
--enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libspeex 
--enable-libx264 --enable-libx265 --enable-version3 --cc='ccache gcc'
  libavutil  55. 35.100 / 55. 35.100
  libavcodec 57. 66.101 / 57. 66.101
  libavformat57. 57.100 / 57. 57.100
  libavdevice57.  2.100 / 57.  2.100
  libavfilter 6. 66.100 /  6. 66.100
  libswscale  4.  3.100 /  4.  3.100
  libswresample   2.  4.100 /  2.  4.100
  libpostproc54.  2.100 / 54.  2.100

Reviewed-by: Lou Logan 
Signed-off-by: Steven Liu 

---
 doc/muxers.texi   |3 +
 libavformat/flvenc.c  |  331 -
 tests/Makefile|1 +
 tests/fate-run.sh |4 +
 tests/fate/flvenc.mak |   11 +
 tests/ref/fate/flv-add_keyframe_index |   12 ++
 6 files changed, 352 insertions(+), 10 deletions(-)
 create mode 100644 tests/fate/flvenc.mak
 create mode 100644 tests/ref/fate/flv-add_keyframe_index

diff --git a/doc/muxers.texi b/doc/muxers.texi
index 488ed43..806182a 100644
--- a/doc/muxers.texi
+++ b/doc/muxers.texi
@@ -147,6 +147,9 @@ Place AAC sequence header based on audio stream data.
 
 @item no_sequence_end
 Disable sequence end tag.
+
+@item add_keyframe_index
+Used to facilitate seeking; particularly for HTTP pseudo streaming.
 @end table
 @end table
 
diff --git a/libavformat/flvenc.c b/libavformat/flvenc.c
index e50f8e4..0cbf561 100644
--- a/libavformat/flvenc.c
+++ b/libavformat/flvenc.c
@@ -24,6 +24,8 @@
 #include "libavutil/intfloat.h"
 #include "libavutil/avassert.h"
 #include "libavutil/mathematics.h"
+#include "avio_internal.h"
+#include "avio.h"
 #include "avc.h"
 #include "avformat.h"
 #include "flv.h"
@@ -64,8 +66,15 @@ static const AVCodecTag flv_audio_codec_ids[] = {
 typedef enum {
 FLV_AAC_SEQ_HEADER_DETECT = (1 << 0),
 FLV_NO_SEQUENCE_END = (1 << 1),
+FLV_ADD_KEYFRAME_INDEX = (1 << 2),
 } FLVFlags;
 
+typedef struct FLVFileposition {
+int64_t keyframe_position;
+double keyframe_timestamp;
+struct FLVFileposition *next;
+} FLVFileposition;
+
 typedef struct FLVContext {
 AVClass *av_class;
 int reserved;
@@ -74,6 +83,33 @@ typedef struct FLVContext {
 int64_t duration;
 int64_t 

[FFmpeg-devel] [PATCH] Making xmp data process faster

2016-11-07 Thread 孟辰(阏逢)
---
 libavformat/mov.c | 15 +++
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index f06de06..341d22d 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -4533,13 +4533,20 @@ static int mov_read_uuid(MOVContext *c, AVIOContext 
*pb, MOVAtom atom)
 if (!buffer) {
 return AVERROR(ENOMEM);
 }
-ret = avio_read(pb, buffer, len);
+
+if (c->export_xmp) {
+ret = avio_read(pb, buffer, len);
+if (ret != len) {
+av_free(buffer);
+return AVERROR_INVALIDDATA;
+}
+} else {
+// skip all uuid atoms, which makes it fast for long uuid-xmp file
+ret = avio_seek(pb, len, SEEK_CUR);
+}
 if (ret < 0) {
 av_free(buffer);
 return ret;
-} else if (ret != len) {
-av_free(buffer);
-return AVERROR_INVALIDDATA;
 }
 if (c->export_xmp) {
 buffer[len] = '\0';
-- 
2.8.2

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


[FFmpeg-devel] [PATCH] libavcodec/tests: Added test for libavcodec/avpacket.c

2016-11-07 Thread Thomas Turner
Signed-off-by: Thomas Turner 
---
 libavcodec/Makefile |   3 +-
 libavcodec/tests/avpacket.c | 134 
 tests/fate/libavcodec.mak   |   5 ++
 3 files changed, 141 insertions(+), 1 deletion(-)
 create mode 100644 libavcodec/tests/avpacket.c

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index f1d5bf1..46e3af7 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1019,7 +1019,8 @@ SKIPHEADERS-$(CONFIG_VDA)  += vda.h 
vda_vt_internal.h
 SKIPHEADERS-$(CONFIG_VDPAU)+= vdpau.h vdpau_internal.h
 SKIPHEADERS-$(CONFIG_VIDEOTOOLBOX) += videotoolbox.h vda_vt_internal.h
 
-TESTPROGS = imgconvert  \
+TESTPROGS = avpacket\
+imgconvert  \
 jpeg2000dwt \
 mathops\
 options \
diff --git a/libavcodec/tests/avpacket.c b/libavcodec/tests/avpacket.c
new file mode 100644
index 000..4826522
--- /dev/null
+++ b/libavcodec/tests/avpacket.c
@@ -0,0 +1,134 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include "libavcodec/avcodec.h"
+#include "libavutil/error.h"
+
+
+
+static int setup_side_data_entry(AVPacket* avpkt)
+{
+const uint8_t *data_name = NULL;
+int ret = 0, bytes;
+uint8_t *extra_data = NULL;
+
+
+/* get side_data_name string */
+data_name = av_packet_side_data_name(AV_PKT_DATA_NEW_EXTRADATA);
+
+/* Allocate a memory bloc */
+bytes = strlen(data_name);
+
+if(!(extra_data = av_malloc(bytes))){
+ret = AVERROR(ENOMEM);
+fprintf(stderr, "Error occurred: %s\n", av_err2str(ret));
+return 1;
+}
+/* copy side_data_name to extra_data array */
+memcpy(extra_data, data_name, bytes);
+
+/* create side data for AVPacket */
+ret = av_packet_add_side_data(avpkt, AV_PKT_DATA_NEW_EXTRADATA,
+extra_data, bytes);
+if(ret < 0){
+fprintf(stderr,
+"Error occurred in av_packet_add_side_data: %s\n",
+av_err2str(ret));
+return 1;
+}
+
+return 0;
+}
+
+static int initializations(AVPacket* avpkt)
+{
+static uint8_t data[] = "selftest for av_packet_clone(...)";
+int ret = 0;
+
+/* initialize avpkt */
+av_init_packet(avpkt);
+
+/* set values for avpkt */
+avpkt->pts = 17;
+avpkt->dts = 2;
+avpkt->data = data;
+avpkt->size = strlen(data);
+avpkt->flags = AV_PKT_FLAG_DISCARD;
+avpkt->duration = 100;
+avpkt->pos = 3;
+
+if(setup_side_data_entry(avpkt))
+ret = 1;
+
+return ret;
+}
+
+int main(void)
+{
+AVPacket avpkt;
+AVPacket *avpkt_clone = NULL;
+int ret = 0;
+
+if(initializations(&avpkt)){
+printf("failed to initialize variables\n");
+return 1;
+}
+
+/* test av_packet_clone*/
+avpkt_clone = av_packet_clone(&avpkt);
+
+if(!avpkt_clone) {
+av_log(NULL, AV_LOG_ERROR,"av_packet_clone failed to clone 
AVPacket\n");
+return 1;
+}
+/* test size error check in av_new_packet*/
+if(av_new_packet(avpkt_clone, INT_MAX) == 0){
+printf( "av_new_packet failed to return error "
+"when \"size\" parameter is too large.\n" );
+ret = 1;
+}
+
+/*test av_grow_packet*/
+if(av_grow_packet(avpkt_clone, INT_MAX) == 0){
+printf( "av_grow_packet failed to return error "
+"when \"grow_by\" parameter is too large.\n" );
+ret = 1;
+}
+if(av_grow_packet(avpkt_clone, 20) < 0){
+av_log(NULL, AV_LOG_ERROR, "av_grow_packet failed\n");
+return 1;
+}
+
+/*test av_packet_from_data*/
+if(av_packet_from_data(avpkt_clone, avpkt_clone->data, INT_MAX) == 0){
+printf("av_packet_from_data failed to return error "
+"when \"size\" parameter is too large.\n" );
+ret = 1;
+}
+
+/*clean up*/
+av_packet_free(&avpkt_clone);
+av_

[FFmpeg-devel] [PATCH] mov: Read multiple stsd from DV

2016-11-07 Thread Vittorio Giovara
Signed-off-by: Vittorio Giovara 
---
Sorry, I can't share the sample or add a fate for this.
Please CC.
Vittorio

 libavformat/mov.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index e283034..a2a688b 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -2219,6 +2219,8 @@ static int mov_skip_multiple_stsd(MOVContext *c, 
AVIOContext *pb,
  (codec_tag != format &&
   // prores is allowed to have differing data format and codec tag
   codec_tag != AV_RL32("apcn") && codec_tag != AV_RL32("apch") &&
+  // so is dv (sigh)
+  codec_tag != AV_RL32("dvpp") && codec_tag != AV_RL32("dvcp") &&
   (c->fc->video_codec_id ? video_codec_id != c->fc->video_codec_id
  : codec_tag != MKTAG('j','p','e','g' {
 /* Multiple fourcc, we skip JPEG. This is not correct, we should
-- 
2.10.0

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


Re: [FFmpeg-devel] [PATCH 2/2] hevc: Support extradata changes

2016-11-07 Thread Vittorio Giovara
On Mon, Nov 7, 2016 at 6:44 PM, Michael Niedermayer
 wrote:
> the decoder should not change extradata, yes directly reading would
> be best probably

ok I'll amend.

>>
>> > also can you add a fate test ?
>>
>> I have a sample I can share but it's incredibly big for a fate test (85mb).
>
> :(
>
> cant it be cut and glued so its smaller ?

Someone tipped me of a way, I'll try.
-- 
Vittorio
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] Making xmp data process faster

2016-11-07 Thread 孟辰(阏逢)
Try to jump over all the xmp data in mov->uuid atom, which is faster than read 
every byte. It's too slow to deal with a mov file contains a big uuid/xmp 
atom(s), especially in streaming case.

0001-Making-xmp-data-process-faster.patch
Description: Binary data
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 1/2] opus: move all tables to a separate file

2016-11-07 Thread Rostislav Pehlivanov
On 8 November 2016 at 00:18, Michael Niedermayer 
wrote:

> On Mon, Nov 07, 2016 at 10:39:57PM +, Rostislav Pehlivanov wrote:
> > Signed-off-by: Rostislav Pehlivanov 
> > ---
> >  libavcodec/Makefile|2 +-
> >  libavcodec/opus_celt.c |  518 +++---
> >  libavcodec/opus_silk.c |  849 +++-
> >  libavcodec/opustab.c   | 1137 ++
> ++
> >  libavcodec/opustab.h   |  156 +++
> >  5 files changed, 1422 insertions(+), 1240 deletions(-)
> >  create mode 100644 libavcodec/opustab.c
> >  create mode 100644 libavcodec/opustab.h
>
> is there any effect on speed ?
> if theres no slowdown then this patchset should be ok
>
> [...]
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> If you think the mosad wants you dead since a long time then you are either
> wrong or dead since a long time.
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
>
Both patches have no effect on speed at all (CPU frequency scaling disabled
of course), tested over multiple runs on a decently long 1 hour file.
Will apply them tomorrow morning if there are no objections, thanks.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] aacenc: quit when the audio queue reaches 0 rather than keeping track of empty frames

2016-11-07 Thread Rostislav Pehlivanov
On 7 November 2016 at 02:14, Rostislav Pehlivanov 
wrote:

> The libopus encoder does the same thing and its better than
> keeping track of when the empty flush frames appear.
>
> Signed-off-by: Rostislav Pehlivanov 
> ---
>  libavcodec/aacenc.c | 9 +++--
>  libavcodec/aacenc.h | 1 -
>  2 files changed, 3 insertions(+), 7 deletions(-)
>
> diff --git a/libavcodec/aacenc.c b/libavcodec/aacenc.c
> index 363ed05..956e974 100644
> --- a/libavcodec/aacenc.c
> +++ b/libavcodec/aacenc.c
> @@ -520,13 +520,13 @@ static int aac_encode_frame(AVCodecContext *avctx,
> AVPacket *avpkt,
>  int chan_el_counter[4];
>  FFPsyWindowInfo windows[AAC_MAX_CHANNELS];
>
> -if (s->last_frame == 2)
> -return 0;
> -
>  /* add current frame to queue */
>  if (frame) {
>  if ((ret = ff_af_queue_add(&s->afq, frame)) < 0)
>  return ret;
> +} else {
> +if (!s->afq.remaining_samples || (!s->afq.frame_alloc &&
> !s->afq.frame_count))
> +return 0;
>  }
>
>  copy_input_samples(s, frame);
> @@ -841,9 +841,6 @@ static int aac_encode_frame(AVCodecContext *avctx,
> AVPacket *avpkt,
>  s->lambda_sum += s->lambda;
>  s->lambda_count++;
>
> -if (!frame)
> -s->last_frame++;
> -
>  ff_af_queue_remove(&s->afq, avctx->frame_size, &avpkt->pts,
> &avpkt->duration);
>
> diff --git a/libavcodec/aacenc.h b/libavcodec/aacenc.h
> index 38a9734..9d244fd 100644
> --- a/libavcodec/aacenc.h
> +++ b/libavcodec/aacenc.h
> @@ -112,7 +112,6 @@ typedef struct AACEncContext {
>  struct FFPsyPreprocessContext* psypp;
>  AACCoefficientsEncoder *coder;
>  int cur_channel; ///< current channel for
> coder context
> -int last_frame;
>  int random_state;
>  float lambda;
>  int last_frame_pb_count; ///< number of bits for
> the previous frame
> --
> 2.10.2
>
>
Pused
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH v1] add show_demuxers and show_muxers

2016-11-07 Thread Michael Niedermayer
On Fri, Nov 04, 2016 at 08:20:25PM +0800, Steven Liu wrote:
> add -muxers and -demuxers parameters to list the dexmuers and muxers
> 
> Signed-off-by: Steven Liu 
> ---
>  cmdutils.c |   66 +++
>  cmdutils.h |   14 ++
>  cmdutils_common_opts.h |2 +
>  3 files changed, 59 insertions(+), 23 deletions(-)

applied

thx

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

Into a blind darkness they enter who follow after the Ignorance,
they as if into a greater darkness enter who devote themselves
to the Knowledge alone. -- Isha Upanishad


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


Re: [FFmpeg-devel] [PATCH] mov: extract stsd vendor field in metadata.

2016-11-07 Thread Zhenni Huang
On Mon, Nov 7, 2016 at 4:30 PM, Zhenni Huang  wrote:

> Also updates fate ref for rgb24-mkv as the output video will contain the
> new metadata field and have different md5sum and file size.
> ---
>  libavformat/mov.c| 25 +++--
>  tests/ref/fate/rgb24-mkv |  4 ++--
>  2 files changed, 25 insertions(+), 4 deletions(-)
>
> diff --git a/libavformat/mov.c b/libavformat/mov.c
> index 4222088..2cb041f 100644
> --- a/libavformat/mov.c
> +++ b/libavformat/mov.c
> @@ -1824,6 +1824,8 @@ static void mov_parse_stsd_video(MOVContext *c,
> AVIOContext *pb,
>  uint8_t codec_name[32];
>  int64_t stsd_start;
>  unsigned int len;
> +int video_vendor_id = 0;
> +char video_vendor_id_buffer[5];
>
>  /* The first 16 bytes of the video sample description are already
>   * read in ff_mov_read_stsd_entries() */
> @@ -1831,10 +1833,18 @@ static void mov_parse_stsd_video(MOVContext *c,
> AVIOContext *pb,
>
>  avio_rb16(pb); /* version */
>  avio_rb16(pb); /* revision level */
> -avio_rb32(pb); /* vendor */
> +video_vendor_id = avio_rb32(pb); /* vendor */
>  avio_rb32(pb); /* temporal quality */
>  avio_rb32(pb); /* spatial quality */
>
> +/* set video_vendor_id */
> +video_vendor_id_buffer[0] = (video_vendor_id >> 24) & 0xff;
> +video_vendor_id_buffer[1] = (video_vendor_id >> 16) & 0xff;
> +video_vendor_id_buffer[2] = (video_vendor_id >>  8) & 0xff;
> +video_vendor_id_buffer[3] = (video_vendor_id >>  0) & 0xff;
> +video_vendor_id_buffer[4] = 0;
> +av_dict_set(&st->metadata, "vendor_id", video_vendor_id_buffer, 0);
> +
>  st->codecpar->width  = avio_rb16(pb); /* width */
>  st->codecpar->height = avio_rb16(pb); /* height */
>
> @@ -1880,9 +1890,20 @@ static void mov_parse_stsd_audio(MOVContext *c,
> AVIOContext *pb,
>  int bits_per_sample, flags;
>  uint16_t version = avio_rb16(pb);
>  AVDictionaryEntry *compatible_brands = av_dict_get(c->fc->metadata,
> "compatible_brands", NULL, AV_DICT_MATCH_CASE);
> +int audio_vendor_id = 0;
> +char audio_vendor_id_buffer[5];
>
>  avio_rb16(pb); /* revision level */
> -avio_rb32(pb); /* vendor */
> +audio_vendor_id = avio_rb32(pb); /* vendor */
> +
> +/* set audio_vendor_id */
> +audio_vendor_id_buffer[0] = (audio_vendor_id >> 24) & 0xff;
> +audio_vendor_id_buffer[1] = (audio_vendor_id >> 16) & 0xff;
> +audio_vendor_id_buffer[2] = (audio_vendor_id >>  8) & 0xff;
> +audio_vendor_id_buffer[3] = (audio_vendor_id >>  0) & 0xff;
> +audio_vendor_id_buffer[4] = 0;
> +
> +av_dict_set(&st->metadata, "vendor_id", audio_vendor_id_buffer, 0);
>
>  st->codecpar->channels  = avio_rb16(pb); /* channel count
> */
>  st->codecpar->bits_per_coded_sample = avio_rb16(pb); /* sample size
> */
> diff --git a/tests/ref/fate/rgb24-mkv b/tests/ref/fate/rgb24-mkv
> index 88d22c1..ba6311d 100644
> --- a/tests/ref/fate/rgb24-mkv
> +++ b/tests/ref/fate/rgb24-mkv
> @@ -1,5 +1,5 @@
> -94cce0d7d5b14b4c86e74a1ca454c5aa *tests/data/fate/rgb24-mkv.matroska
> -58361 tests/data/fate/rgb24-mkv.matroska
> +29e4fffecb2002912fc05ed910679ce3 *tests/data/fate/rgb24-mkv.matroska
> +58390 tests/data/fate/rgb24-mkv.matroska
>  #tb 0: 1/10
>  #media_type 0: video
>  #codec_id 0: rawvideo
> --
> 2.8.0.rc3.226.g39d4020
>
> I am really sorry about the FATE failure. Thanks for pointing it out.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] mov: extract stsd vendor field in metadata.

2016-11-07 Thread Zhenni Huang
Also updates fate ref for rgb24-mkv as the output video will contain the
new metadata field and have different md5sum and file size.
---
 libavformat/mov.c| 25 +++--
 tests/ref/fate/rgb24-mkv |  4 ++--
 2 files changed, 25 insertions(+), 4 deletions(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 4222088..2cb041f 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -1824,6 +1824,8 @@ static void mov_parse_stsd_video(MOVContext *c, 
AVIOContext *pb,
 uint8_t codec_name[32];
 int64_t stsd_start;
 unsigned int len;
+int video_vendor_id = 0;
+char video_vendor_id_buffer[5];
 
 /* The first 16 bytes of the video sample description are already
  * read in ff_mov_read_stsd_entries() */
@@ -1831,10 +1833,18 @@ static void mov_parse_stsd_video(MOVContext *c, 
AVIOContext *pb,
 
 avio_rb16(pb); /* version */
 avio_rb16(pb); /* revision level */
-avio_rb32(pb); /* vendor */
+video_vendor_id = avio_rb32(pb); /* vendor */
 avio_rb32(pb); /* temporal quality */
 avio_rb32(pb); /* spatial quality */
 
+/* set video_vendor_id */
+video_vendor_id_buffer[0] = (video_vendor_id >> 24) & 0xff;
+video_vendor_id_buffer[1] = (video_vendor_id >> 16) & 0xff;
+video_vendor_id_buffer[2] = (video_vendor_id >>  8) & 0xff;
+video_vendor_id_buffer[3] = (video_vendor_id >>  0) & 0xff;
+video_vendor_id_buffer[4] = 0;
+av_dict_set(&st->metadata, "vendor_id", video_vendor_id_buffer, 0);
+
 st->codecpar->width  = avio_rb16(pb); /* width */
 st->codecpar->height = avio_rb16(pb); /* height */
 
@@ -1880,9 +1890,20 @@ static void mov_parse_stsd_audio(MOVContext *c, 
AVIOContext *pb,
 int bits_per_sample, flags;
 uint16_t version = avio_rb16(pb);
 AVDictionaryEntry *compatible_brands = av_dict_get(c->fc->metadata, 
"compatible_brands", NULL, AV_DICT_MATCH_CASE);
+int audio_vendor_id = 0;
+char audio_vendor_id_buffer[5];
 
 avio_rb16(pb); /* revision level */
-avio_rb32(pb); /* vendor */
+audio_vendor_id = avio_rb32(pb); /* vendor */
+
+/* set audio_vendor_id */
+audio_vendor_id_buffer[0] = (audio_vendor_id >> 24) & 0xff;
+audio_vendor_id_buffer[1] = (audio_vendor_id >> 16) & 0xff;
+audio_vendor_id_buffer[2] = (audio_vendor_id >>  8) & 0xff;
+audio_vendor_id_buffer[3] = (audio_vendor_id >>  0) & 0xff;
+audio_vendor_id_buffer[4] = 0;
+
+av_dict_set(&st->metadata, "vendor_id", audio_vendor_id_buffer, 0);
 
 st->codecpar->channels  = avio_rb16(pb); /* channel count */
 st->codecpar->bits_per_coded_sample = avio_rb16(pb); /* sample size */
diff --git a/tests/ref/fate/rgb24-mkv b/tests/ref/fate/rgb24-mkv
index 88d22c1..ba6311d 100644
--- a/tests/ref/fate/rgb24-mkv
+++ b/tests/ref/fate/rgb24-mkv
@@ -1,5 +1,5 @@
-94cce0d7d5b14b4c86e74a1ca454c5aa *tests/data/fate/rgb24-mkv.matroska
-58361 tests/data/fate/rgb24-mkv.matroska
+29e4fffecb2002912fc05ed910679ce3 *tests/data/fate/rgb24-mkv.matroska
+58390 tests/data/fate/rgb24-mkv.matroska
 #tb 0: 1/10
 #media_type 0: video
 #codec_id 0: rawvideo
-- 
2.8.0.rc3.226.g39d4020

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


[FFmpeg-devel] [PATCH 2/2] avcodec/hap: add "compressor" option to Hap encoder to disable secondary compression

2016-11-07 Thread Tom Butterworth
The secondary compression in Hap is optional, this change exposes that option to
the user as some use-cases favour higher bitrate files to reduce workload
decoding.
Adds "none" or "snappy" as options for "compressor". Selecting "none" disregards
"chunks" option: chunking is only of benefit decompressing Snappy.
---
 libavcodec/hap.h|  1 +
 libavcodec/hapenc.c | 57 +
 2 files changed, 41 insertions(+), 17 deletions(-)

diff --git a/libavcodec/hap.h b/libavcodec/hap.h
index e4762ee..f39e621 100644
--- a/libavcodec/hap.h
+++ b/libavcodec/hap.h
@@ -65,6 +65,7 @@ typedef struct HapContext {
 
 enum HapTextureFormat opt_tex_fmt; /* Texture type (encoder only) */
 int opt_chunk_count; /* User-requested chunk count (encoder only) */
+int opt_compressor; /* User-requested compressor (encoder only) */
 
 int chunk_count;
 HapChunk *chunks;
diff --git a/libavcodec/hapenc.c b/libavcodec/hapenc.c
index 7056b62..d44ef92 100644
--- a/libavcodec/hapenc.c
+++ b/libavcodec/hapenc.c
@@ -199,13 +199,19 @@ static int hap_encode(AVCodecContext *avctx, AVPacket 
*pkt,
 if (ret < 0)
 return ret;
 
-/* DXTC compression. */
-compress_texture(avctx, ctx->tex_buf, frame);
-
-/* Compress (using Snappy) the frame */
-final_data_size = hap_compress_frame(avctx, pkt->data + header_length);
-if (final_data_size < 0)
-return final_data_size;
+if (ctx->opt_compressor == HAP_COMP_NONE) {
+/* DXTC compression directly to the packet buffer. */
+compress_texture(avctx, pkt->data + header_length, frame);
+ctx->chunks[0].compressor = HAP_COMP_NONE;
+final_data_size = ctx->tex_size;
+} else {
+/* DXTC compression. */
+compress_texture(avctx, ctx->tex_buf, frame);
+/* Compress (using Snappy) the frame */
+final_data_size = hap_compress_frame(avctx, pkt->data + header_length);
+if (final_data_size < 0)
+return final_data_size;
+}
 
 /* Write header at the start. */
 hap_write_frame_header(ctx, pkt->data, final_data_size + header_length);
@@ -266,10 +272,30 @@ static av_cold int hap_init(AVCodecContext *avctx)
 ctx->tex_size   = FFALIGN(avctx->width,  TEXTURE_BLOCK_W) *
   FFALIGN(avctx->height, TEXTURE_BLOCK_H) * 4 / ratio;
 
-/* Round the chunk count to divide evenly on DXT block edges */
-corrected_chunk_count = av_clip(ctx->opt_chunk_count, 1, HAP_MAX_CHUNKS);
-while ((ctx->tex_size / (64 / ratio)) % corrected_chunk_count != 0) {
-corrected_chunk_count--;
+switch (ctx->opt_compressor) {
+case HAP_COMP_NONE:
+/* No benefit chunking uncompressed data */
+corrected_chunk_count = 1;
+
+ctx->max_snappy = ctx->tex_size;
+ctx->tex_buf = NULL;
+break;
+case HAP_COMP_SNAPPY:
+/* Round the chunk count to divide evenly on DXT block edges */
+corrected_chunk_count = av_clip(ctx->opt_chunk_count, 1, 
HAP_MAX_CHUNKS);
+while ((ctx->tex_size / (64 / ratio)) % corrected_chunk_count != 0) {
+corrected_chunk_count--;
+}
+
+ctx->max_snappy = snappy_max_compressed_length(ctx->tex_size / 
corrected_chunk_count);
+ctx->tex_buf = av_malloc(ctx->tex_size);
+if (!ctx->tex_buf) {
+return AVERROR(ENOMEM);
+}
+break;
+default:
+av_log(avctx, AV_LOG_ERROR, "Invalid compresor %02X\n", 
ctx->opt_compressor);
+return AVERROR_INVALIDDATA;
 }
 if (corrected_chunk_count != ctx->opt_chunk_count) {
 av_log(avctx, AV_LOG_INFO, "%d chunks requested but %d used.\n",
@@ -279,12 +305,6 @@ static av_cold int hap_init(AVCodecContext *avctx)
 if (ret != 0)
 return ret;
 
-ctx->max_snappy = snappy_max_compressed_length(ctx->tex_size / 
corrected_chunk_count);
-
-ctx->tex_buf  = av_malloc(ctx->tex_size);
-if (!ctx->tex_buf)
-return AVERROR(ENOMEM);
-
 return 0;
 }
 
@@ -305,6 +325,9 @@ static const AVOption options[] = {
 { "hap_alpha", "Hap Alpha (DXT5 textures)", 0, AV_OPT_TYPE_CONST, { 
.i64 = HAP_FMT_RGBADXT5  }, 0, 0, FLAGS, "format" },
 { "hap_q", "Hap Q (DXT5-YCoCg textures)", 0, AV_OPT_TYPE_CONST, { 
.i64 = HAP_FMT_YCOCGDXT5 }, 0, 0, FLAGS, "format" },
 { "chunks", "chunk count", OFFSET(opt_chunk_count), AV_OPT_TYPE_INT, {.i64 
= 1 }, 1, HAP_MAX_CHUNKS, FLAGS, },
+{ "compressor", "second-stage compressor", OFFSET(opt_compressor), 
AV_OPT_TYPE_INT, { .i64 = HAP_COMP_SNAPPY }, HAP_COMP_NONE, HAP_COMP_SNAPPY, 
FLAGS, "compressor" },
+{ "none",   "None", 0, AV_OPT_TYPE_CONST, { .i64 = HAP_COMP_NONE 
}, 0, 0, FLAGS, "compressor" },
+{ "snappy", "Snappy", 0, AV_OPT_TYPE_CONST, { .i64 = 
HAP_COMP_SNAPPY }, 0, 0, FLAGS, "compressor" },
 { NULL },
 };
 
-- 
2.9.3 (Apple Git-75)

___
ffmpeg-devel mailing list
ffmpeg-devel

[FFmpeg-devel] [PATCH 1/2] avcodec/hap: pass texture-compression destination as argument, not in context

2016-11-07 Thread Tom Butterworth
This allows a subsequent change to compress directly into the output packet 
when possible.
---
 libavcodec/hapenc.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/libavcodec/hapenc.c b/libavcodec/hapenc.c
index 076923b..7056b62 100644
--- a/libavcodec/hapenc.c
+++ b/libavcodec/hapenc.c
@@ -52,10 +52,9 @@ enum HapHeaderLength {
 HAP_HDR_LONG = 8,
 };
 
-static void compress_texture(AVCodecContext *avctx, const AVFrame *f)
+static void compress_texture(AVCodecContext *avctx, uint8_t *out, const 
AVFrame *f)
 {
 HapContext *ctx = avctx->priv_data;
-uint8_t *out = ctx->tex_buf;
 int i, j;
 
 for (j = 0; j < avctx->height; j += 4) {
@@ -201,7 +200,7 @@ static int hap_encode(AVCodecContext *avctx, AVPacket *pkt,
 return ret;
 
 /* DXTC compression. */
-compress_texture(avctx, frame);
+compress_texture(avctx, ctx->tex_buf, frame);
 
 /* Compress (using Snappy) the frame */
 final_data_size = hap_compress_frame(avctx, pkt->data + header_length);
-- 
2.9.3 (Apple Git-75)

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


Re: [FFmpeg-devel] [PATCH 1/2] opus: move all tables to a separate file

2016-11-07 Thread Michael Niedermayer
On Mon, Nov 07, 2016 at 10:39:57PM +, Rostislav Pehlivanov wrote:
> Signed-off-by: Rostislav Pehlivanov 
> ---
>  libavcodec/Makefile|2 +-
>  libavcodec/opus_celt.c |  518 +++---
>  libavcodec/opus_silk.c |  849 +++-
>  libavcodec/opustab.c   | 1137 
> 
>  libavcodec/opustab.h   |  156 +++
>  5 files changed, 1422 insertions(+), 1240 deletions(-)
>  create mode 100644 libavcodec/opustab.c
>  create mode 100644 libavcodec/opustab.h

is there any effect on speed ?
if theres no slowdown then this patchset should be ok

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

If you think the mosad wants you dead since a long time then you are either
wrong or dead since a long time.


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


Re: [FFmpeg-devel] [PATCH] matroskadec: fix NULL pointer dereference in webm_dash_manifest_read_header

2016-11-07 Thread Michael Niedermayer
On Tue, Nov 08, 2016 at 12:44:56AM +0100, Andreas Cadhalpun wrote:
> The code assumes that s->streams[0] is valid.
> 
> Signed-off-by: Andreas Cadhalpun 
> ---
>  libavformat/matroskadec.c | 5 +
>  1 file changed, 5 insertions(+)

should be ok

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

If you think the mosad wants you dead since a long time then you are either
wrong or dead since a long time.


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


Re: [FFmpeg-devel] [PATCH] avformat/matroskadec: fix DiscardPadding element parsing

2016-11-07 Thread James Zern
On Sat, Nov 5, 2016 at 1:50 PM, James Almer  wrote:
> If the value is negative then it means padding at the start of the packet
> instead of at the end.
>
> Based on a patch by Hendrik Leppkes.
>
> Signed-off-by: James Almer 
> ---
>  libavformat/matroskadec.c | 12 +---
>  1 file changed, 9 insertions(+), 3 deletions(-)
>

lgtm

> diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
> index 32f5e49..5a22193 100644
> --- a/libavformat/matroskadec.c
> +++ b/libavformat/matroskadec.c
> @@ -3082,10 +3082,16 @@ static int matroska_parse_frame(MatroskaDemuxContext 
> *matroska,
>  av_free(pkt);
>  return AVERROR(ENOMEM);
>  }
> -AV_WL32(side_data, 0);
> -AV_WL32(side_data + 4, av_rescale_q(discard_padding,
> +discard_padding = av_rescale_q(discard_padding,
>  (AVRational){1, 10},
> -(AVRational){1, 
> st->codecpar->sample_rate}));
> +(AVRational){1, 
> st->codecpar->sample_rate});
> +if (discard_padding > 0) {
>

I might have said '>= 0' as I was reading the else as doing '-0' which
sounded weird.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 2/3] lavfi/loudnorm: add an internal libebur128 library

2016-11-07 Thread Marton Balint


On Fri, 4 Nov 2016, Marton Balint wrote:



On Thu, 3 Nov 2016, Hendrik Leppkes wrote:


On Mon, Oct 17, 2016 at 5:20 PM, Moritz Barsnick  wrote:

On Mon, Oct 17, 2016 at 17:09:15 +0200, wm4 wrote:

Does this copy parts of libebur128 to FFmpeg?
Why?


There was a long discussion regarding this patch:

http://lists.ffmpeg.org/pipermail/ffmpeg-devel/2016-April/192668.html

(in summary: "please don't require yet another small external library,
rather port it to ffmpeg and maintain it") leading to this one:



The generic idea was not to just copy/paste an external library into
internal code, but extend the ebur128 code we already have - at least
that way we get code written by one of our maintainers, code he knows
and can properly maintain.


I copied the external library because we needed an API. The way the 
internals work, I used the library code because it was simply easier, than 
factoring out f_ebur128 stuff, also there are some features which 
f_ebur128.c does not have (variable sample rate support), and there 
was the licensing issue GPL v.s. LGPL.



If you just copy the implementation of a library, you might as well
just use that library - thats what it exists for. Why do we want to
increase the maintenance burden of our project when other people (ie.
the authors of libebur128) are already doing it as well?


In general I agree with people who think that for small code, it is better 
to integrate it into our codebase, because

- it can benefit from features we already have (e.g. resampling)
- makes it easier for developers to work on features based on this
- code gets more review than code in a small 3rd party library
- code and/or improvements have stronger requirements performance-wise
- code is better audited (Coverity, etc)

Yes, some additional maintenance burden is the price we pay for this, 
which is IMHO in this case is acceptable.




Is it fine to apply, or we should put this to a vote?

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


Re: [FFmpeg-devel] [PATCH] mpegts: prevent division by zero

2016-11-07 Thread Marton Balint


On Mon, 7 Nov 2016, Andreas Cadhalpun wrote:


Signed-off-by: Andreas Cadhalpun 
---
libavformat/mpegts.c | 4 
1 file changed, 4 insertions(+)

diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index fad10c6..77d63f2 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -2692,6 +2692,10 @@ static int mpegts_read_header(AVFormatContext *s)
/* NOTE1: the bitrate is computed without the FEC */
/* NOTE2: it is only the bitrate of the start of the stream */
ts->pcr_incr = (pcrs[1] - pcrs[0]) / (packet_count[1] - 
packet_count[0]);
+if (ts->pcr_incr <= 0) {


As far as I see a negative pcr_incr can happen in valid streams in case of 
a PCR wraparound.


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


Re: [FFmpeg-devel] [PATCH] mpegts: prevent division by zero

2016-11-07 Thread Michael Niedermayer
On Mon, Nov 07, 2016 at 11:49:52PM +0100, Andreas Cadhalpun wrote:
> Signed-off-by: Andreas Cadhalpun 
> ---
>  libavformat/mpegts.c | 4 
>  1 file changed, 4 insertions(+)
> 
> diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
> index fad10c6..77d63f2 100644
> --- a/libavformat/mpegts.c
> +++ b/libavformat/mpegts.c
> @@ -2692,6 +2692,10 @@ static int mpegts_read_header(AVFormatContext *s)
>  /* NOTE1: the bitrate is computed without the FEC */
>  /* NOTE2: it is only the bitrate of the start of the stream */
>  ts->pcr_incr = (pcrs[1] - pcrs[0]) / (packet_count[1] - 
> packet_count[0]);
> +if (ts->pcr_incr <= 0) {
> +av_log(s, AV_LOG_ERROR, "invalid pcr increment %d\n", 
> ts->pcr_incr);
> +return AVERROR_INVALIDDATA;
> +}

if a pcr pair is bad i would suggest to run the loop by another
iteration

also i dont think the demuxer should fail hard and fatal from bad pcr
(it would fail completely if it fails at header reading time)


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

If you fake or manipulate statistics in a paper in physics you will never
get a job again.
If you fake or manipulate statistics in a paper in medicin you will get
a job for life at the pharma industry.


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


[FFmpeg-devel] [PATCH] matroskadec: fix NULL pointer dereference in webm_dash_manifest_read_header

2016-11-07 Thread Andreas Cadhalpun
The code assumes that s->streams[0] is valid.

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

diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index 32f5e49..130d92e 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -3772,6 +3772,11 @@ static int 
webm_dash_manifest_read_header(AVFormatContext *s)
 av_log(s, AV_LOG_ERROR, "Failed to read file headers\n");
 return -1;
 }
+if (!s->nb_streams) {
+matroska_read_close(s);
+av_log(s, AV_LOG_ERROR, "No streams found\n");
+return AVERROR_INVALIDDATA;
+}
 
 if (!matroska->is_live) {
 buf = av_asprintf("%g", matroska->duration);
-- 
2.10.2
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 2/2] hevc: Support extradata changes

2016-11-07 Thread Michael Niedermayer
On Mon, Nov 07, 2016 at 04:52:23PM -0500, Vittorio Giovara wrote:
> On Sat, Nov 5, 2016 at 9:21 AM, Michael Niedermayer
>  wrote:
> > On Wed, Nov 02, 2016 at 11:48:58AM -0400, Vittorio Giovara wrote:
> >> Signed-off-by: Vittorio Giovara 
> >> ---
> >> Please CC.
> >> Vittorio
> >>
> >>  libavcodec/hevc.c | 18 ++
> >>  libavformat/mov.c |  4 
> >>  2 files changed, 18 insertions(+), 4 deletions(-)
> >>
> >> diff --git a/libavcodec/hevc.c b/libavcodec/hevc.c
> >> index 29e0d49..b50120e 100644
> >> --- a/libavcodec/hevc.c
> >> +++ b/libavcodec/hevc.c
> >> @@ -3051,6 +3051,8 @@ static int hevc_decode_frame(AVCodecContext *avctx, 
> >> void *data, int *got_output,
> >>   AVPacket *avpkt)
> >>  {
> >>  int ret;
> >> +int new_extradata_size;
> >> +uint8_t *new_extradata;
> >>  HEVCContext *s = avctx->priv_data;
> >>
> >>  if (!avpkt->size) {
> >> @@ -3062,6 +3064,22 @@ static int hevc_decode_frame(AVCodecContext *avctx, 
> >> void *data, int *got_output,
> >>  return 0;
> >>  }
> >>
> >> +new_extradata_size = 0;
> >> +new_extradata = av_packet_get_side_data(avpkt, 
> >> AV_PKT_DATA_NEW_EXTRADATA,
> >> +&new_extradata_size);
> >> +if (new_extradata_size > 0 && new_extradata) {
> >
> > new_extradata should be checked first, that should make
> > new_extradata_size = 0; unneeded
> 
> ok
> 
> >> +if (new_extradata_size > avctx->extradata_size) {
> >
> >> +avctx->extradata = av_realloc(avctx->extradata, 
> >> new_extradata_size);
> >
> > This leaks on reallocation failure overwriting the allocated pointer
> 
> yeah, also, extradata is av_malloc'd, it is not possible call any
> *realloc* functions at all.
> 

> I thought of av_free + av_malloc but I'm afraid a free there will
> interfere with frame multi threading, like it did for h264. So maybe
> it's better to modify hevc_decode_extradata() to support reading
> extradata from input buffers rather than from avctx (like h264 does).
> Thoughts?

the decoder should not change extradata, yes directly reading would
be best probably


> 
> > also can you add a fate test ?
> 
> I have a sample I can share but it's incredibly big for a fate test (85mb).

:(

cant it be cut and glued so its smaller ?

thx

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

Those who are best at talking, realize last or never when they are wrong.


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


[FFmpeg-devel] [PATCH] mpegts: prevent division by zero

2016-11-07 Thread Andreas Cadhalpun
Signed-off-by: Andreas Cadhalpun 
---
 libavformat/mpegts.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index fad10c6..77d63f2 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -2692,6 +2692,10 @@ static int mpegts_read_header(AVFormatContext *s)
 /* NOTE1: the bitrate is computed without the FEC */
 /* NOTE2: it is only the bitrate of the start of the stream */
 ts->pcr_incr = (pcrs[1] - pcrs[0]) / (packet_count[1] - 
packet_count[0]);
+if (ts->pcr_incr <= 0) {
+av_log(s, AV_LOG_ERROR, "invalid pcr increment %d\n", 
ts->pcr_incr);
+return AVERROR_INVALIDDATA;
+}
 ts->cur_pcr  = pcrs[0] - ts->pcr_incr * packet_count[0];
 s->bit_rate  = TS_PACKET_SIZE * 8 * 2700LL / ts->pcr_incr;
 st->codecpar->bit_rate = s->bit_rate;
-- 
2.10.2
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [libav-devel] [PATCH] mpegpicture: use coded_width/coded_height to allocate frame

2016-11-07 Thread Andreas Cadhalpun
On 07.11.2016 22:52, Luca Barbato wrote:
> On 07/11/2016 22:32, Andreas Cadhalpun wrote:
>> This fixes a heap-buffer-overflow in ff_er_frame_end when decoding mss2 with
>> coded_width/coded_height larger than width/height.
>>
>> Signed-off-by: Andreas Cadhalpun 
>> ---
>>  libavcodec/mpegpicture.c | 12 ++--
>>  1 file changed, 6 insertions(+), 6 deletions(-)
>>
> 
> Do you have a sample to look at the output in that specific case?

Yes, and the output looks similar to most fuzzed samples: like garbage.

Best regards,
Andreas
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 2/2] opus: move the entropy decoding functions to opus_rc.c

2016-11-07 Thread Rostislav Pehlivanov
The intention is to have both encoding and decoding functions
in opus_rc.c.

Signed-off-by: Rostislav Pehlivanov 
---
 libavcodec/Makefile|   2 +-
 libavcodec/opus.h  | 222 +
 libavcodec/opus_celt.c |  58 ++---
 libavcodec/opus_rc.c   | 221 
 libavcodec/opus_rc.h   |  85 +++
 libavcodec/opus_silk.c |  72 
 libavcodec/opusdec.c   |  40 ++---
 7 files changed, 380 insertions(+), 320 deletions(-)
 create mode 100644 libavcodec/opus_rc.c
 create mode 100644 libavcodec/opus_rc.h

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 8e4087e..5fdc97f 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -436,7 +436,7 @@ OBJS-$(CONFIG_NELLYMOSER_DECODER)  += nellymoserdec.o 
nellymoser.o
 OBJS-$(CONFIG_NELLYMOSER_ENCODER)  += nellymoserenc.o nellymoser.o
 OBJS-$(CONFIG_NUV_DECODER) += nuv.o rtjpeg.o
 OBJS-$(CONFIG_ON2AVC_DECODER)  += on2avc.o on2avcdata.o
-OBJS-$(CONFIG_OPUS_DECODER)+= opusdec.o opus.o opus_celt.o \
+OBJS-$(CONFIG_OPUS_DECODER)+= opusdec.o opus.o opus_celt.o 
opus_rc.o \
   opus_silk.o opustab.o vorbis_data.o
 OBJS-$(CONFIG_PAF_AUDIO_DECODER)   += pafaudio.o
 OBJS-$(CONFIG_PAF_VIDEO_DECODER)   += pafvideo.o
diff --git a/libavcodec/opus.h b/libavcodec/opus.h
index 3a7ea9f..2079f42 100644
--- a/libavcodec/opus.h
+++ b/libavcodec/opus.h
@@ -32,7 +32,7 @@
 #include "libswresample/swresample.h"
 
 #include "avcodec.h"
-#include "get_bits.h"
+#include "opus_rc.h"
 
 #define MAX_FRAME_SIZE   1275
 #define MAX_FRAMES   48
@@ -59,7 +59,6 @@
 
 #define ROUND_MULL(a,b,s) (((MUL64(a, b) >> ((s) - 1)) + 1) >> 1)
 #define ROUND_MUL16(a,b)  ((MUL16(a, b) + 16384) >> 15)
-#define opus_ilog(i) (av_log2(i) + !!(i))
 
 #define OPUS_TS_HEADER 0x7FE0// 0x3ff (11 bits)
 #define OPUS_TS_MASK   0xFFE0// top 11 bits
@@ -84,21 +83,6 @@ enum OpusBandwidth {
 OPUS_BANDWIDTH_FULLBAND
 };
 
-typedef struct RawBitsContext {
-const uint8_t *position;
-unsigned int bytes;
-unsigned int cachelen;
-unsigned int cacheval;
-} RawBitsContext;
-
-typedef struct OpusRangeCoder {
-GetBitContext gb;
-RawBitsContext rb;
-unsigned int range;
-unsigned int value;
-unsigned int total_read_bits;
-} OpusRangeCoder;
-
 typedef struct SilkContext SilkContext;
 
 typedef struct CeltContext CeltContext;
@@ -193,210 +177,6 @@ typedef struct OpusContext {
 ChannelMap *channel_maps;
 } OpusContext;
 
-static av_always_inline void opus_rc_normalize(OpusRangeCoder *rc)
-{
-while (rc->range <= 1<<23) {
-rc->value = ((rc->value << 8) | (get_bits(&rc->gb, 8) ^ 0xFF)) & ((1u 
<< 31) - 1);
-rc->range  <<= 8;
-rc->total_read_bits += 8;
-}
-}
-
-static av_always_inline void opus_rc_update(OpusRangeCoder *rc, unsigned int 
scale,
-  unsigned int low, unsigned int high,
-  unsigned int total)
-{
-rc->value -= scale * (total - high);
-rc->range  = low ? scale * (high - low)
-  : rc->range - scale * (total - high);
-opus_rc_normalize(rc);
-}
-
-static av_always_inline unsigned int opus_rc_getsymbol(OpusRangeCoder *rc, 
const uint16_t *cdf)
-{
-unsigned int k, scale, total, symbol, low, high;
-
-total = *cdf++;
-
-scale   = rc->range / total;
-symbol = rc->value / scale + 1;
-symbol = total - FFMIN(symbol, total);
-
-for (k = 0; cdf[k] <= symbol; k++);
-high = cdf[k];
-low  = k ? cdf[k-1] : 0;
-
-opus_rc_update(rc, scale, low, high, total);
-
-return k;
-}
-
-static av_always_inline unsigned int opus_rc_p2model(OpusRangeCoder *rc, 
unsigned int bits)
-{
-unsigned int k, scale;
-scale = rc->range >> bits; // in this case, scale = symbol
-
-if (rc->value >= scale) {
-rc->value -= scale;
-rc->range -= scale;
-k = 0;
-} else {
-rc->range = scale;
-k = 1;
-}
-opus_rc_normalize(rc);
-return k;
-}
-
-/**
- * CELT: estimate bits of entropy that have thus far been consumed for the
- *   current CELT frame, to integer and fractional (1/8th bit) precision
- */
-static av_always_inline unsigned int opus_rc_tell(const OpusRangeCoder *rc)
-{
-return rc->total_read_bits - av_log2(rc->range) - 1;
-}
-
-static av_always_inline unsigned int opus_rc_tell_frac(const OpusRangeCoder 
*rc)
-{
-unsigned int i, total_bits, rcbuffer, range;
-
-total_bits = rc->total_read_bits << 3;
-rcbuffer   = av_log2(rc->range) + 1;
-range  = rc->range >> (rcbuffer-16);
-
-for (i = 0; i < 3; i++) {
-int bit;
-range = range * range >> 15;
-bit = range >> 16;
-rcbuffer = rcbuffer << 1 | bit;
-range >>= bit;
-}
-
-return

Re: [FFmpeg-devel] [PATCH 1/2] Move av_show_help_children() to avutil/opt

2016-11-07 Thread Reynaldo H. Verdejo Pinochet

Hi

On 11/07/2016 01:34 PM, Andreas Cadhalpun wrote:

[...]
Isn't the causality the other way around?
Because ffserver uses internal API it was decided to remove it.
If it gets fixed, there is no point in removing it, or is there?
[..]


I see no reason to remove it if it works properly.

Bests,

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


Re: [FFmpeg-devel] [PATCH 2/2] hevc: Support extradata changes

2016-11-07 Thread Vittorio Giovara
On Sat, Nov 5, 2016 at 9:21 AM, Michael Niedermayer
 wrote:
> On Wed, Nov 02, 2016 at 11:48:58AM -0400, Vittorio Giovara wrote:
>> Signed-off-by: Vittorio Giovara 
>> ---
>> Please CC.
>> Vittorio
>>
>>  libavcodec/hevc.c | 18 ++
>>  libavformat/mov.c |  4 
>>  2 files changed, 18 insertions(+), 4 deletions(-)
>>
>> diff --git a/libavcodec/hevc.c b/libavcodec/hevc.c
>> index 29e0d49..b50120e 100644
>> --- a/libavcodec/hevc.c
>> +++ b/libavcodec/hevc.c
>> @@ -3051,6 +3051,8 @@ static int hevc_decode_frame(AVCodecContext *avctx, 
>> void *data, int *got_output,
>>   AVPacket *avpkt)
>>  {
>>  int ret;
>> +int new_extradata_size;
>> +uint8_t *new_extradata;
>>  HEVCContext *s = avctx->priv_data;
>>
>>  if (!avpkt->size) {
>> @@ -3062,6 +3064,22 @@ static int hevc_decode_frame(AVCodecContext *avctx, 
>> void *data, int *got_output,
>>  return 0;
>>  }
>>
>> +new_extradata_size = 0;
>> +new_extradata = av_packet_get_side_data(avpkt, 
>> AV_PKT_DATA_NEW_EXTRADATA,
>> +&new_extradata_size);
>> +if (new_extradata_size > 0 && new_extradata) {
>
> new_extradata should be checked first, that should make
> new_extradata_size = 0; unneeded

ok

>> +if (new_extradata_size > avctx->extradata_size) {
>
>> +avctx->extradata = av_realloc(avctx->extradata, 
>> new_extradata_size);
>
> This leaks on reallocation failure overwriting the allocated pointer

yeah, also, extradata is av_malloc'd, it is not possible call any
*realloc* functions at all.

I thought of av_free + av_malloc but I'm afraid a free there will
interfere with frame multi threading, like it did for h264. So maybe
it's better to modify hevc_decode_extradata() to support reading
extradata from input buffers rather than from avctx (like h264 does).
Thoughts?

> also can you add a fate test ?

I have a sample I can share but it's incredibly big for a fate test (85mb).
-- 
Vittorio
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 1/2] Move av_show_help_children() to avutil/opt

2016-11-07 Thread Michael Niedermayer
On Mon, Nov 07, 2016 at 10:34:47PM +0100, Andreas Cadhalpun wrote:
> On 07.11.2016 20:26, James Almer wrote:
> > ffserver is being dropped from the project, as announced in the news page.
> > 
> > Reynaldo however wants to have a working copy somewhere so he's moving it to
> > an external repo and for that he's making it work without internal API, with
> > some help from Michael it seems.
> 
> Isn't the causality the other way around?
> Because ffserver uses internal API it was decided to remove it.
> If it gets fixed, there is no point in removing it, or is there?

+1

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

Concerning the gods, I have no means of knowing whether they exist or not
or of what sort they may be, because of the obscurity of the subject, and
the brevity of human life -- Protagoras


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


Re: [FFmpeg-devel] [PATCH 1/2] Move av_show_help_children() to avutil/opt

2016-11-07 Thread James Almer
On 11/7/2016 6:34 PM, Andreas Cadhalpun wrote:
> On 07.11.2016 20:26, James Almer wrote:
>> ffserver is being dropped from the project, as announced in the news page.
>>
>> Reynaldo however wants to have a working copy somewhere so he's moving it to
>> an external repo and for that he's making it work without internal API, with
>> some help from Michael it seems.
> 
> Isn't the causality the other way around?
> Because ffserver uses internal API it was decided to remove it.
> If it gets fixed, there is no point in removing it, or is there?

Removing ffserver was decided for several reasons, as mentioned in the news 
entry,
with one of them being the internal API usage. That stuff being fixed now is the
choice of a dev after the removal decision was made, since it was in his 
interests
to keep a working copy somewhere else.

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


Re: [FFmpeg-devel] [PATCH 1/2] Move av_show_help_children() to avutil/opt

2016-11-07 Thread Andreas Cadhalpun
On 07.11.2016 20:26, James Almer wrote:
> ffserver is being dropped from the project, as announced in the news page.
> 
> Reynaldo however wants to have a working copy somewhere so he's moving it to
> an external repo and for that he's making it work without internal API, with
> some help from Michael it seems.

Isn't the causality the other way around?
Because ffserver uses internal API it was decided to remove it.
If it gets fixed, there is no point in removing it, or is there?

Best regards,
Andreas

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


[FFmpeg-devel] [PATCH] mpegpicture: use coded_width/coded_height to allocate frame

2016-11-07 Thread Andreas Cadhalpun
This fixes a heap-buffer-overflow in ff_er_frame_end when decoding mss2 with
coded_width/coded_height larger than width/height.

Signed-off-by: Andreas Cadhalpun 
---
 libavcodec/mpegpicture.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/libavcodec/mpegpicture.c b/libavcodec/mpegpicture.c
index 6748fc2..70b4d3c 100644
--- a/libavcodec/mpegpicture.c
+++ b/libavcodec/mpegpicture.c
@@ -108,15 +108,15 @@ static int alloc_frame_buffer(AVCodecContext *avctx,  
Picture *pic,
 avctx->codec_id != AV_CODEC_ID_VC1IMAGE  &&
 avctx->codec_id != AV_CODEC_ID_MSS2) {
 if (edges_needed) {
-pic->f->width  = avctx->width  + 2 * EDGE_WIDTH;
-pic->f->height = avctx->height + 2 * EDGE_WIDTH;
+pic->f->width  = avctx->coded_width  + 2 * EDGE_WIDTH;
+pic->f->height = avctx->coded_height + 2 * EDGE_WIDTH;
 }
 
 r = ff_thread_get_buffer(avctx, &pic->tf,
  pic->reference ? AV_GET_BUFFER_FLAG_REF : 0);
 } else {
-pic->f->width  = avctx->width;
-pic->f->height = avctx->height;
+pic->f->width  = avctx->coded_width;
+pic->f->height = avctx->coded_height;
 pic->f->format = avctx->pix_fmt;
 r = avcodec_default_get_buffer2(avctx, pic->f, 0);
 }
@@ -135,8 +135,8 @@ static int alloc_frame_buffer(AVCodecContext *avctx,  
Picture *pic,
  (EDGE_WIDTH >> (i ? chroma_x_shift : 0));
 pic->f->data[i] += offset;
 }
-pic->f->width  = avctx->width;
-pic->f->height = avctx->height;
+pic->f->width  = avctx->coded_width;
+pic->f->height = avctx->coded_height;
 }
 
 if (avctx->hwaccel) {
-- 
2.10.2
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 1/2] Move av_show_help_children() to avutil/opt

2016-11-07 Thread James Almer
On 11/7/2016 4:05 PM, Andreas Cadhalpun wrote:
> On 04.11.2016 21:16, Michael Niedermayer wrote:
>> diff --git a/libavutil/opt.c b/libavutil/opt.c
>> index cd16bd1..1b8dae2 100644
>> --- a/libavutil/opt.c
>> +++ b/libavutil/opt.c
>> @@ -1992,3 +1992,15 @@ int av_opt_serialize(void *obj, int opt_flags, int 
>> flags, char **buffer,
>>  av_bprint_finalize(&bprint, buffer);
>>  return 0;
>>  }
>> +
>> +void av_show_help_children(const AVClass *class, int flags)
>> +{
>> +const AVClass *child = NULL;
>> +if (class->option) {
>> +av_opt_show2(&class, NULL, flags, 0);
>> +printf("\n");
> 
> The libraries must not use printf directly, because unlike av_log it
> can't be intercepted by API users. This applies also to the second patch.
> 
> On 04.11.2016 21:16, Michael Niedermayer wrote:
>> This patch-set is also required for moving ffserver into a separate
>> repository as it too uses these functions and they otherwise would need to
>> be duplicated.
> 
> I'm not sure moving ffserver to a separate repository is very useful.
> Its problem is that it uses private functions, which has to be fixed anyway.
> However, moving it to a separate repository makes it impossible to test it
> with FATE in order to prevent regressions.

ffserver is being dropped from the project, as announced in the news page.

Reynaldo however wants to have a working copy somewhere so he's moving it to
an external repo and for that he's making it work without internal API, with
some help from Michael it seems.

> 
> Best regards,
> Andreas
> ___
> 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


Re: [FFmpeg-devel] [PATCH 1/2] Move av_show_help_children() to avutil/opt

2016-11-07 Thread Andreas Cadhalpun
On 04.11.2016 21:16, Michael Niedermayer wrote:
> diff --git a/libavutil/opt.c b/libavutil/opt.c
> index cd16bd1..1b8dae2 100644
> --- a/libavutil/opt.c
> +++ b/libavutil/opt.c
> @@ -1992,3 +1992,15 @@ int av_opt_serialize(void *obj, int opt_flags, int 
> flags, char **buffer,
>  av_bprint_finalize(&bprint, buffer);
>  return 0;
>  }
> +
> +void av_show_help_children(const AVClass *class, int flags)
> +{
> +const AVClass *child = NULL;
> +if (class->option) {
> +av_opt_show2(&class, NULL, flags, 0);
> +printf("\n");

The libraries must not use printf directly, because unlike av_log it
can't be intercepted by API users. This applies also to the second patch.

On 04.11.2016 21:16, Michael Niedermayer wrote:
> This patch-set is also required for moving ffserver into a separate
> repository as it too uses these functions and they otherwise would need to
> be duplicated.

I'm not sure moving ffserver to a separate repository is very useful.
Its problem is that it uses private functions, which has to be fixed anyway.
However, moving it to a separate repository makes it impossible to test it
with FATE in order to prevent regressions.

Best regards,
Andreas
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] hls: fix leaking avio_opts on hls_read_header error

2016-11-07 Thread Andreas Cadhalpun
On 07.11.2016 16:20, Michael Niedermayer wrote:
> On Mon, Nov 07, 2016 at 12:11:25AM +0100, Andreas Cadhalpun wrote:
>> Use the hls_close function to reduce code duplication.
>>
>> Signed-off-by: Andreas Cadhalpun 
>> ---
>>  libavformat/hls.c | 30 ++
>>  1 file changed, 14 insertions(+), 16 deletions(-)
> 
> LGTM but please split into cosmetic move and bug fix

Split and pushed.

Best regards,
Andreas

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


Re: [FFmpeg-devel] [PATCH] mpegaudio_parser: don't return AVERROR_PATCHWELCOME

2016-11-07 Thread Andreas Cadhalpun
On 07.11.2016 10:23, Michael Niedermayer wrote:
> On Mon, Nov 07, 2016 at 01:21:01AM +0100, Andreas Cadhalpun wrote:
>> The API does not allow returning AVERROR codes.
>>
>> It triggers an assert in av_parser_parse2.
>>
>> Signed-off-by: Andreas Cadhalpun 
>> ---
>>  libavcodec/mpegaudio_parser.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> probably ok

Pushed.

Best regards,
Andreas

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


Re: [FFmpeg-devel] [PATCH 3/3 v2] avformat/hls: Add missing error check for avcodec_parameters_copy()

2016-11-07 Thread Anssi Hannula
07.11.2016, 01:08, Andreas Cadhalpun kirjoitti:
> On 06.11.2016 23:52, Anssi Hannula wrote:
>> Signed-off-by: Anssi Hannula 
>> ---
>>
>> 07.11.2016, 00:35, Andreas Cadhalpun kirjoitti:
>>> On 06.11.2016 22:44, Anssi Hannula wrote:
 Signed-off-by: Anssi Hannula 
 ---
  libavformat/hls.c | 18 ++
  1 file changed, 14 insertions(+), 4 deletions(-)

>>>
>>> This misses checking the return code of the other occurrence of
>>> set_stream_info_from_input_stream in hls_read_packet.
>>
>> Argh, true. Here's a new one.
>>
>>
>>  libavformat/hls.c | 27 +--
>>  1 file changed, 21 insertions(+), 6 deletions(-)
>>
> 
> LGTM.

Thanks, all 3 applied to master and backported to 3.2 branch.


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


Re: [FFmpeg-devel] [PATCH v3] avformat/flvenc: add add_keyframe_index option

2016-11-07 Thread Michael Niedermayer
On Mon, Nov 07, 2016 at 06:02:05PM +0800, Steven Liu wrote:
> Add keyframe index metadata
> Used to facilitate seeking; particularly for HTTP pseudo streaming.
>  1. read live streaming or file by sequence
>  2. if use add_keyframe_index option, add a mark flag at the position,
> use to insert new context at the last step.
>  3. add the keyframes *offset* and *timestamp* into a list
>  4. if use add_keyframe_index option, shift the metadata data from
> mark flag offset
>  5. insert the keyframes *offset* and *timestamp* from the list by
> sequence
>  6. free the list
>  7. end.
> 
> Add FATE test case;
> 
> Reviewed-by: Lou Logan 
> Signed-off-by: Steven Liu 
> ---
>  doc/muxers.texi   |3 +
>  libavformat/flvenc.c  |  331 
> -
>  tests/Makefile|1 +
>  tests/fate-run.sh |4 +
>  tests/fate/flvenc.mak |   11 +
>  tests/ref/fate/flv-add_keyframe_index |   12 ++
>  6 files changed, 352 insertions(+), 10 deletions(-)
>  create mode 100644 tests/fate/flvenc.mak
>  create mode 100644 tests/ref/fate/flv-add_keyframe_index

fate test fails on qemu arm:
@@ -4,9 +4,9 @@
 hasAudio=false
 hasMetadata=true
 canSeekToEnd=true
-datasize=633428
-videosize=633033
+datasize=629772
+videosize=629377
 audiosize=0
 lasttimestamp=20
 lastkeyframetimestamp=19
-lastkeyframelocation=601489
+lastkeyframelocation=597959
Test flv-add_keyframe_index failed. Look at 
tests/data/fate/flv-add_keyframe_index.err for details.
make: *** [fate-flv-add_keyframe_index] Error 1

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

The bravest are surely those who have the clearest vision
of what is before them, glory and danger alike, and yet
notwithstanding go out to meet it. -- Thucydides


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


Re: [FFmpeg-devel] [PATCH] hls: fix leaking avio_opts on hls_read_header error

2016-11-07 Thread Michael Niedermayer
On Mon, Nov 07, 2016 at 12:11:25AM +0100, Andreas Cadhalpun wrote:
> Use the hls_close function to reduce code duplication.
> 
> Signed-off-by: Andreas Cadhalpun 
> ---
>  libavformat/hls.c | 30 ++
>  1 file changed, 14 insertions(+), 16 deletions(-)

LGTM but please split into cosmetic move and bug fix

thx

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

Dictatorship: All citizens are under surveillance, all their steps and
actions recorded, for the politicians to enforce control.
Democracy: All politicians are under surveillance, all their steps and
actions recorded, for the citizens to enforce control.


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


Re: [FFmpeg-devel] [PATCH v1] add show_demuxers and show_muxers

2016-11-07 Thread Steven Liu
ping

2016-11-04 20:20 GMT+08:00 Steven Liu :

> add -muxers and -demuxers parameters to list the dexmuers and muxers
>
> Signed-off-by: Steven Liu 
> ---
>  cmdutils.c |   66 ++
> +
>  cmdutils.h |   14 ++
>  cmdutils_common_opts.h |2 +
>  3 files changed, 59 insertions(+), 23 deletions(-)
>
> diff --git a/cmdutils.c b/cmdutils.c
> index 469c2d5..44fe64c 100644
> --- a/cmdutils.c
> +++ b/cmdutils.c
> @@ -75,6 +75,12 @@ static FILE *report_file;
>  static int report_file_level = AV_LOG_DEBUG;
>  int hide_banner = 0;
>
> +enum show_muxdemuxers {
> +SHOW_DEFAULT,
> +SHOW_DEMUXERS,
> +SHOW_MUXERS,
> +};
> +
>  void init_opts(void)
>  {
>  av_dict_set(&sws_dict, "flags", "bicubic", 0);
> @@ -1251,7 +1257,7 @@ static int is_device(const AVClass *avclass)
>  return AV_IS_INPUT_DEVICE(avclass->category) ||
> AV_IS_OUTPUT_DEVICE(avclass->category);
>  }
>
> -static int show_formats_devices(void *optctx, const char *opt, const char
> *arg, int device_only)
> +static int show_formats_devices(void *optctx, const char *opt, const char
> *arg, int device_only, int muxdemuxers)
>  {
>  AVInputFormat *ifmt  = NULL;
>  AVOutputFormat *ofmt = NULL;
> @@ -1269,29 +1275,33 @@ static int show_formats_devices(void *optctx,
> const char *opt, const char *arg,
>  const char *name  = NULL;
>  const char *long_name = NULL;
>
> -while ((ofmt = av_oformat_next(ofmt))) {
> -is_dev = is_device(ofmt->priv_class);
> -if (!is_dev && device_only)
> -continue;
> -if ((!name || strcmp(ofmt->name, name) < 0) &&
> -strcmp(ofmt->name, last_name) > 0) {
> -name  = ofmt->name;
> -long_name = ofmt->long_name;
> -encode= 1;
> +if (muxdemuxers !=SHOW_DEMUXERS) {
> +while ((ofmt = av_oformat_next(ofmt))) {
> +is_dev = is_device(ofmt->priv_class);
> +if (!is_dev && device_only)
> +continue;
> +if ((!name || strcmp(ofmt->name, name) < 0) &&
> +strcmp(ofmt->name, last_name) > 0) {
> +name  = ofmt->name;
> +long_name = ofmt->long_name;
> +encode= 1;
> +}
>  }
>  }
> -while ((ifmt = av_iformat_next(ifmt))) {
> -is_dev = is_device(ifmt->priv_class);
> -if (!is_dev && device_only)
> -continue;
> -if ((!name || strcmp(ifmt->name, name) < 0) &&
> -strcmp(ifmt->name, last_name) > 0) {
> -name  = ifmt->name;
> -long_name = ifmt->long_name;
> -encode= 0;
> +if (muxdemuxers != SHOW_MUXERS) {
> +while ((ifmt = av_iformat_next(ifmt))) {
> +is_dev = is_device(ifmt->priv_class);
> +if (!is_dev && device_only)
> +continue;
> +if ((!name || strcmp(ifmt->name, name) < 0) &&
> +strcmp(ifmt->name, last_name) > 0) {
> +name  = ifmt->name;
> +long_name = ifmt->long_name;
> +encode= 0;
> +}
> +if (name && strcmp(ifmt->name, name) == 0)
> +decode = 1;
>  }
> -if (name && strcmp(ifmt->name, name) == 0)
> -decode = 1;
>  }
>  if (!name)
>  break;
> @@ -1308,12 +1318,22 @@ static int show_formats_devices(void *optctx,
> const char *opt, const char *arg,
>
>  int show_formats(void *optctx, const char *opt, const char *arg)
>  {
> -return show_formats_devices(optctx, opt, arg, 0);
> +return show_formats_devices(optctx, opt, arg, 0, SHOW_DEFAULT);
> +}
> +
> +int show_muxers(void *optctx, const char *opt, const char *arg)
> +{
> +return show_formats_devices(optctx, opt, arg, 0, SHOW_MUXERS);
> +}
> +
> +int show_demuxers(void *optctx, const char *opt, const char *arg)
> +{
> +return show_formats_devices(optctx, opt, arg, 0, SHOW_DEMUXERS);
>  }
>
>  int show_devices(void *optctx, const char *opt, const char *arg)
>  {
> -return show_formats_devices(optctx, opt, arg, 1);
> +return show_formats_devices(optctx, opt, arg, 1, SHOW_DEFAULT);
>  }
>
>  #define PRINT_CODEC_SUPPORTED(codec, field, type, list_name, term,
> get_name) \
> diff --git a/cmdutils.h b/cmdutils.h
> index 1b96aa4..e75d8d3 100644
> --- a/cmdutils.h
> +++ b/cmdutils.h
> @@ -442,6 +442,20 @@ int show_license(void *optctx, const char *opt, const
> char *arg);
>  int show_formats(void *optctx, const char *opt, const char *arg);
>
>  /**
> + * Print a listing containing all the muxers supported by the
> + * program (including devices).
> + * This option processing function does not utilize the arguments.
> + */
> +

Re: [FFmpeg-devel] [PATCH] WIP: subtitles in AVFrame

2016-11-07 Thread Clément Bœsch
On Thu, Nov 03, 2016 at 01:05:01AM +0100, Marton Balint wrote:
[...]
> > So long story short: AVSubtitle → AVFrame, you have to use the new M:N
> > API, and it's integrated into lavfi.
> > 
> > Now a bit longer: the AVFrame->extended_data are
> > AVFrameSubtitleRectangle (declared in lavu/frame).
> 
> Wouldn't it make sense to simply use video AVFrames here instead of a
> separate struct?
> 

mmh. AVFrame for each rectangle? So we will have AVFrame in AVFrame, and
the need to add fields such as x and y in that AVFrame? I'm not too fond
of this but it could be considered yes

-- 
Clément B.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 0/2] Move show_*() code from cmdutils to libs

2016-11-07 Thread Clément Bœsch
On Fri, Nov 04, 2016 at 09:16:34PM +0100, Michael Niedermayer wrote:
> 
> Printing the available codecs, decoders, encoders, bitstream filters and their
> options and capabilities is usefull for Apps in general and not just ffmpeg.
> 
> This patch-set is also required for moving ffserver into a separate
> repository as it too uses these functions and they otherwise would need to
> be duplicated.
> 

I don't like this. It is *not* usefull for Apps: every app will use its
logger or UI toolkit thing if they need to. They will never use that
except for debugging purpose.

This printing is specific to our tools. If ffserver goes out of the
repository, it's not considered an FFmpeg tool. So you have 2 solutions
here, duplicate or simply drop them.

Exposing printing helps makes no sense to me. Maybe it would make sense as
a string, but even then it's broken by design IMO.

Regards,

-- 
Clément B.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] Broken libnpp (was working with git snapshot 0779396)

2016-11-07 Thread Ali KIZIL
Hi All,

I was trying libnpp on Big Bunny video by below command:

./ffmpeg -loglevel debug -y -hwaccel cuvid -c:v h264_cuvid -vsync 0 -i
/root/root/bunny.mp4 -vf scale_npp=1920:1072 -vcodec h264_nvenc
/tmp/tmp0.264 -vf scale_npp=1280:720 -vcodec h264_nvenc /tmp/tmp1.264

This command is working with below Git version:
https://git.ffmpeg.org/gitweb/ffmpeg.git/snapshot/077939626eeaa0c1364065414c18ab9b3a072281.tar.gz

However, today I pulled the latest git updates and noticed now FFmpeg gives
error:

ffmpeg version N-82274-g34aeb5d Copyright (c) 2000-2016 the FFmpeg
developers
  built with gcc 4.8 (Ubuntu 4.8.4-2ubuntu1~14.04.3)
  configuration: --prefix=/opt/ffmpeg --enable-nonfree --enable-gpl
--extra-cflags='-march=corei7-avx -I/opt/ffmpeg/include
-I/usr/local/include -fno-builtin-memcpy' --extra-ldflags=-L/opt/ffmpeg/lib
--bindir=/opt/ffmpeg/bin --extra-libs=-ldl --enable-libx264
--enable-libx265 --enable-nonfree --enable-gpl --enable-nvenc
--enable-libzvbi --enable-libfdk-aac --enable-libzimg --enable-avresample
--enable-libzmq --enable-libfreetype --disable-shared
--enable-hardcoded-tables --enable-cuda --enable-cuvid --enable-libnpp
--enable-version3
  libavutil  55. 35.100 / 55. 35.100
  libavcodec 57. 66.101 / 57. 66.101
  libavformat57. 57.100 / 57. 57.100
  libavdevice57.  2.100 / 57.  2.100
  libavfilter 6. 66.100 /  6. 66.100
  libavresample   3.  2.  0 /  3.  2.  0
  libswscale  4.  3.100 /  4.  3.100
  libswresample   2.  4.100 /  2.  4.100
  libpostproc54.  2.100 / 54.  2.100
Splitting the commandline.
Reading option '-loglevel' ... matched as option 'loglevel' (set logging
level) with argument 'debug'.
Reading option '-y' ... matched as option 'y' (overwrite output files) with
argument '1'.
Reading option '-hwaccel' ... matched as option 'hwaccel' (use HW
accelerated decoding) with argument 'cuvid'.
Reading option '-c:v' ... matched as option 'c' (codec name) with argument
'h264_cuvid'.
Reading option '-vsync' ... matched as option 'vsync' (video sync method)
with argument '0'.
Reading option '-i' ... matched as input file with argument
'/root/root/bunny.mp4'.
Reading option '-vf' ... matched as option 'vf' (set video filters) with
argument 'scale_npp=1920:1072'.
Reading option '-vcodec' ... matched as option 'vcodec' (force video codec
('copy' to copy stream)) with argument 'h264_nvenc'.
Reading option '/tmp/tmp0.264' ... matched as output file.
Reading option '-vf' ... matched as option 'vf' (set video filters) with
argument 'scale_npp=1280:720'.
Reading option '-vcodec' ... matched as option 'vcodec' (force video codec
('copy' to copy stream)) with argument 'h264_nvenc'.
Reading option '/tmp/tmp1.264' ... matched as output file.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option loglevel (set logging level) with argument debug.
Applying option y (overwrite output files) with argument 1.
Applying option vsync (video sync method) with argument 0.
Successfully parsed a group of options.
Parsing a group of options: input file /root/root/bunny.mp4.
Applying option hwaccel (use HW accelerated decoding) with argument cuvid.
Applying option c:v (codec name) with argument h264_cuvid.
Successfully parsed a group of options.
Opening an input file: /root/root/bunny.mp4.
[file @ 0x35597a0] Setting default whitelist 'file,crypto'
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x3558f80] Format mov,mp4,m4a,3gp,3g2,mj2 probed
with size=2048 and score=100
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x3558f80] ISO: File Type Major Brand: isom
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x3558f80] Unknown dref type 0x08206c7275 size 12
Last message repeated 2 times
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x3558f80] Before avformat_find_stream_info()
pos: 673223828 bytes read:446246 seeks:1 nb_streams:3
[h264 @ 0x355b120] nal_unit_type: 7, nal_ref_idc: 3
[h264 @ 0x355b120] nal_unit_type: 8, nal_ref_idc: 3
[h264 @ 0x355b120] nal_unit_type: 6, nal_ref_idc: 0
[h264 @ 0x355b120] nal_unit_type: 5, nal_ref_idc: 3
[h264 @ 0x355b120] user data:"x264 - core 120 - H.264/MPEG-4 AVC codec -
Copyleft 2003-2011 - http://www.videolan.org/x264.html - options: cabac=1
ref=4 deblock=1:1:1 analyse=0x3:0x133 me=tesa subme=11 psy=1
psy_rd=0.40:0.00 mixed_ref=1 me_range=24 chroma_me=1 trellis=2 8x8dct=1
cqm=0 deadzone=21,11 fast_pskip=0 chroma_qp_offset=-2 threads=12
sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0
constrained_intra=0 bframes=16 b_pyramid=2 b_adapt=2 b_bias=0 direct=3
weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40
intra_refresh=0 rc_lookahead=60 rc=2pass mbtree=1 bitrate=8000 ratetol=1.0
qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 cplxblur=20.0 qblur=0.5 ip_ratio=1.40
aq=1:0.60"
[h264 @ 0x355b120] Reinit context to 3840x2160, pix_fmt: yuv420p
[h264 @ 0x355b120] no picture
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x3558f80] All info found
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x3558f80] After avformat_find_stream_info()
pos: 544489 bytes read:577318 seeks:2 frames:53
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/

[FFmpeg-devel] [PATCH v3] avformat/flvenc: add add_keyframe_index option

2016-11-07 Thread Steven Liu
Add keyframe index metadata
Used to facilitate seeking; particularly for HTTP pseudo streaming.
 1. read live streaming or file by sequence
 2. if use add_keyframe_index option, add a mark flag at the position,
use to insert new context at the last step.
 3. add the keyframes *offset* and *timestamp* into a list
 4. if use add_keyframe_index option, shift the metadata data from
mark flag offset
 5. insert the keyframes *offset* and *timestamp* from the list by
sequence
 6. free the list
 7. end.

Add FATE test case;

Reviewed-by: Lou Logan 
Signed-off-by: Steven Liu 
---
 doc/muxers.texi   |3 +
 libavformat/flvenc.c  |  331 -
 tests/Makefile|1 +
 tests/fate-run.sh |4 +
 tests/fate/flvenc.mak |   11 +
 tests/ref/fate/flv-add_keyframe_index |   12 ++
 6 files changed, 352 insertions(+), 10 deletions(-)
 create mode 100644 tests/fate/flvenc.mak
 create mode 100644 tests/ref/fate/flv-add_keyframe_index

diff --git a/doc/muxers.texi b/doc/muxers.texi
index 488ed43..806182a 100644
--- a/doc/muxers.texi
+++ b/doc/muxers.texi
@@ -147,6 +147,9 @@ Place AAC sequence header based on audio stream data.
 
 @item no_sequence_end
 Disable sequence end tag.
+
+@item add_keyframe_index
+Used to facilitate seeking; particularly for HTTP pseudo streaming.
 @end table
 @end table
 
diff --git a/libavformat/flvenc.c b/libavformat/flvenc.c
index e50f8e4..0cbf561 100644
--- a/libavformat/flvenc.c
+++ b/libavformat/flvenc.c
@@ -24,6 +24,8 @@
 #include "libavutil/intfloat.h"
 #include "libavutil/avassert.h"
 #include "libavutil/mathematics.h"
+#include "avio_internal.h"
+#include "avio.h"
 #include "avc.h"
 #include "avformat.h"
 #include "flv.h"
@@ -64,8 +66,15 @@ static const AVCodecTag flv_audio_codec_ids[] = {
 typedef enum {
 FLV_AAC_SEQ_HEADER_DETECT = (1 << 0),
 FLV_NO_SEQUENCE_END = (1 << 1),
+FLV_ADD_KEYFRAME_INDEX = (1 << 2),
 } FLVFlags;
 
+typedef struct FLVFileposition {
+int64_t keyframe_position;
+double keyframe_timestamp;
+struct FLVFileposition *next;
+} FLVFileposition;
+
 typedef struct FLVContext {
 AVClass *av_class;
 int reserved;
@@ -74,6 +83,33 @@ typedef struct FLVContext {
 int64_t duration;
 int64_t delay;  ///< first dts delay (needed for AVC & Speex)
 
+int64_t datastart_offset;
+int64_t datasize_offset;
+int64_t datasize;
+int64_t videosize_offset;
+int64_t videosize;
+int64_t audiosize_offset;
+int64_t audiosize;
+
+int64_t metadata_size_pos;
+int64_t metadata_totalsize_pos;
+int64_t metadata_totalsize;
+int64_t keyframe_index_size;
+
+int64_t lasttimestamp_offset;
+double lasttimestamp;
+int64_t lastkeyframetimestamp_offset;
+double lastkeyframetimestamp;
+int64_t lastkeyframelocation_offset;
+int64_t lastkeyframelocation;
+
+int acurframeindex;
+int64_t keyframes_info_offset;
+
+int64_t filepositions_count;
+FLVFileposition *filepositions;
+FLVFileposition *head_filepositions;
+
 AVCodecParameters *audio_par;
 AVCodecParameters *video_par;
 double framerate;
@@ -202,6 +238,17 @@ static void put_amf_double(AVIOContext *pb, double d)
 avio_wb64(pb, av_double2int(d));
 }
 
+static void put_amf_byte(AVIOContext *pb, unsigned char abyte)
+{
+avio_w8(pb, abyte);
+}
+
+static void put_amf_dword_array(AVIOContext *pb, uint32_t dw)
+{
+avio_w8(pb, AMF_DATA_TYPE_ARRAY);
+avio_wb32(pb, dw);
+}
+
 static void put_amf_bool(AVIOContext *pb, int b)
 {
 avio_w8(pb, AMF_DATA_TYPE_BOOL);
@@ -213,12 +260,12 @@ static void write_metadata(AVFormatContext *s, unsigned 
int ts)
 AVIOContext *pb = s->pb;
 FLVContext *flv = s->priv_data;
 int metadata_count = 0;
-int64_t metadata_size_pos, data_size, metadata_count_pos;
+int64_t metadata_count_pos;
 AVDictionaryEntry *tag = NULL;
 
 /* write meta_tag */
-avio_w8(pb, 18);// tag type META
-metadata_size_pos = avio_tell(pb);
+avio_w8(pb, FLV_TAG_TYPE_META);// tag type META
+flv->metadata_size_pos = avio_tell(pb);
 avio_wb24(pb, 0);   // size of data part (sum of all parts below)
 avio_wb24(pb, ts);  // timestamp
 avio_wb32(pb, 0);   // reserved
@@ -327,19 +374,87 @@ static void write_metadata(AVFormatContext *s, unsigned 
int ts)
 put_amf_double(pb, 0); // delayed write
 }
 
+if (flv->flags & FLV_ADD_KEYFRAME_INDEX) {
+flv->acurframeindex = 0;
+flv->keyframe_index_size = 0;
+
+put_amf_string(pb, "hasVideo");
+put_amf_bool(pb, !!flv->video_par);
+metadata_count++;
+
+put_amf_string(pb, "hasKeyframes");
+put_amf_bool(pb, 1);
+metadata_count++;
+
+put_amf_string(pb, "hasAudio");
+put_amf_bool(pb, !!flv->audio_par);
+metadata_count++;
+
+put_amf_string(

Re: [FFmpeg-devel] [PATCH] mpegaudio_parser: don't return AVERROR_PATCHWELCOME

2016-11-07 Thread Michael Niedermayer
On Mon, Nov 07, 2016 at 01:21:01AM +0100, Andreas Cadhalpun wrote:
> The API does not allow returning AVERROR codes.
> 
> It triggers an assert in av_parser_parse2.
> 
> Signed-off-by: Andreas Cadhalpun 
> ---
>  libavcodec/mpegaudio_parser.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

probably ok

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

Everything should be made as simple as possible, but not simpler.
-- Albert Einstein


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