[FFmpeg-devel] [PATCH 12/17] vaapi_decode: Ignore the profile when not useful

2017-11-23 Thread Mark Thompson
Enables VP8 decoding - the decoder places the the bitstream version
in the profile field, which we want to ignore.
---
 libavcodec/vaapi_decode.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavcodec/vaapi_decode.c b/libavcodec/vaapi_decode.c
index d36ef906a2..572b3a40ac 100644
--- a/libavcodec/vaapi_decode.c
+++ b/libavcodec/vaapi_decode.c
@@ -324,7 +324,8 @@ static int vaapi_decode_make_config(AVCodecContext *avctx,
 int profile_match = 0;
 if (avctx->codec_id != vaapi_profile_map[i].codec_id)
 continue;
-if (avctx->profile == vaapi_profile_map[i].codec_profile)
+if (avctx->profile == vaapi_profile_map[i].codec_profile ||
+vaapi_profile_map[i].codec_profile == FF_PROFILE_UNKNOWN)
 profile_match = 1;
 for (j = 0; j < profile_count; j++) {
 if (vaapi_profile_map[i].va_profile == profile_list[j]) {
-- 
2.11.0

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


[FFmpeg-devel] [PATCH 13/17] lavc/mjpeg: Add profiles for MJPEG using SOF marker codes

2017-11-23 Thread Mark Thompson
This is needed by later hwaccel code to tell which encoding process was
used for a particular frame, because hardware decoders may only support a
subset of possible methods.
---
 libavcodec/avcodec.h  | 6 ++
 libavcodec/mjpegdec.c | 7 +++
 2 files changed, 13 insertions(+)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 0972df0bde..c1e68b1d13 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -2897,6 +2897,12 @@ typedef struct AVCodecContext {
 #define FF_PROFILE_HEVC_MAIN_STILL_PICTURE  3
 #define FF_PROFILE_HEVC_REXT4
 
+#define FF_PROFILE_MJPEG_HUFFMAN_BASELINE_DCT0xc0
+#define FF_PROFILE_MJPEG_HUFFMAN_EXTENDED_SEQUENTIAL_DCT 0xc1
+#define FF_PROFILE_MJPEG_HUFFMAN_PROGRESSIVE_DCT 0xc2
+#define FF_PROFILE_MJPEG_HUFFMAN_LOSSLESS0xc3
+#define FF_PROFILE_MJPEG_JPEG_LS 0xf7
+
 /**
  * level
  * - encoding: Set by user.
diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index e005dd0cd3..f01d44a169 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -2288,6 +2288,10 @@ int ff_mjpeg_decode_frame(AVCodecContext *avctx, void 
*data, int *got_frame,
 break;
 case SOF0:
 case SOF1:
+if (start_code == SOF0)
+s->avctx->profile = FF_PROFILE_MJPEG_HUFFMAN_BASELINE_DCT;
+else
+s->avctx->profile = 
FF_PROFILE_MJPEG_HUFFMAN_EXTENDED_SEQUENTIAL_DCT;
 s->lossless= 0;
 s->ls  = 0;
 s->progressive = 0;
@@ -2295,6 +2299,7 @@ int ff_mjpeg_decode_frame(AVCodecContext *avctx, void 
*data, int *got_frame,
 goto fail;
 break;
 case SOF2:
+s->avctx->profile = FF_PROFILE_MJPEG_HUFFMAN_PROGRESSIVE_DCT;
 s->lossless= 0;
 s->ls  = 0;
 s->progressive = 1;
@@ -2302,6 +2307,7 @@ int ff_mjpeg_decode_frame(AVCodecContext *avctx, void 
*data, int *got_frame,
 goto fail;
 break;
 case SOF3:
+s->avctx->profile = FF_PROFILE_MJPEG_HUFFMAN_LOSSLESS;
 s->avctx->properties |= FF_CODEC_PROPERTY_LOSSLESS;
 s->lossless= 1;
 s->ls  = 0;
@@ -2310,6 +2316,7 @@ int ff_mjpeg_decode_frame(AVCodecContext *avctx, void 
*data, int *got_frame,
 goto fail;
 break;
 case SOF48:
+s->avctx->profile = FF_PROFILE_MJPEG_JPEG_LS;
 s->avctx->properties |= FF_CODEC_PROPERTY_LOSSLESS;
 s->lossless= 1;
 s->ls  = 1;
-- 
2.11.0

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


[FFmpeg-devel] [PATCH 04/17] lavc: Deprecate av_hwaccel_next() and av_register_hwaccel()

2017-11-23 Thread Mark Thompson
---
 doc/APIchanges   |  4 
 libavcodec/avcodec.h | 14 +-
 libavcodec/utils.c   | 16 +---
 libavcodec/version.h |  3 +++
 4 files changed, 25 insertions(+), 12 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 704efe1719..a3afa8b2a6 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -16,6 +16,10 @@ libavutil: 2017-10-21
 API changes, most recent first:
 
 2017-xx-xx - xxx - lavc 58.x+1.0 - avcodec.h
+  Deprecate user visibility of the AVHWAccel structure and the functions
+  av_register_hwaccel() and av_hwaccel_next().
+
+2017-xx-xx - xxx - lavc 58.x+1.0 - avcodec.h
   Add AVCodecHWConfig and avcodec_get_hw_config().
 
 2017-11-xx - xxx - lavu 55.3.0 - opencl.h
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index a78c69a708..1ae0344bb2 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -3489,6 +3489,10 @@ const AVCodecHWConfig *avcodec_get_hw_config(const 
AVCodec *codec, int index);
 
 /**
  * @defgroup lavc_hwaccel AVHWAccel
+ *
+ * @note  Nothing in this structure should be accessed by the user.  At some
+ *point in future it will not be externally visible at all.
+ *
  * @{
  */
 typedef struct AVHWAccel {
@@ -3533,7 +3537,6 @@ typedef struct AVHWAccel {
  * New public fields should be added right above.
  *
  */
-struct AVHWAccel *next;
 
 /**
  * Allocate a custom buffer
@@ -5874,17 +5877,26 @@ void av_fast_padded_mallocz(void *ptr, unsigned int 
*size, size_t min_size);
  */
 unsigned int av_xiphlacing(unsigned char *s, unsigned int v);
 
+#if FF_API_USER_VISIBLE_AVHWACCEL
 /**
  * Register the hardware accelerator hwaccel.
+ *
+ * @deprecated  This function doesn't do anything.
  */
+attribute_deprecated
 void av_register_hwaccel(AVHWAccel *hwaccel);
 
 /**
  * If hwaccel is NULL, returns the first registered hardware accelerator,
  * if hwaccel is non-NULL, returns the next registered hardware accelerator
  * after hwaccel, or NULL if hwaccel is the last one.
+ *
+ * @deprecated  AVHWaccel structures contain no user-serviceable parts, so
+ *  this function should not be used.
  */
+attribute_deprecated
 AVHWAccel *av_hwaccel_next(const AVHWAccel *hwaccel);
+#endif
 
 
 /**
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 01bf7556f7..417ebcb770 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -1897,22 +1897,16 @@ const AVCodecHWConfig *avcodec_get_hw_config(const 
AVCodec *codec, int index)
 return >hw_configs[index]->public;
 }
 
-static AVHWAccel *first_hwaccel = NULL;
-static AVHWAccel **last_hwaccel = _hwaccel;
-
-void av_register_hwaccel(AVHWAccel *hwaccel)
+#if FF_API_USER_VISIBLE_AVHWACCEL
+AVHWAccel *av_hwaccel_next(const AVHWAccel *hwaccel)
 {
-AVHWAccel **p = last_hwaccel;
-hwaccel->next = NULL;
-while(*p || avpriv_atomic_ptr_cas((void * volatile *)p, NULL, hwaccel))
-p = &(*p)->next;
-last_hwaccel = >next;
+return NULL;
 }
 
-AVHWAccel *av_hwaccel_next(const AVHWAccel *hwaccel)
+void av_register_hwaccel(AVHWAccel *hwaccel)
 {
-return hwaccel ? hwaccel->next : first_hwaccel;
 }
+#endif
 
 int av_lockmgr_register(int (*cb)(void **mutex, enum AVLockOp op))
 {
diff --git a/libavcodec/version.h b/libavcodec/version.h
index c8550bca9a..1bd8f1b411 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -123,6 +123,9 @@
 #ifndef FF_API_CODEC_GET_SET
 #define FF_API_CODEC_GET_SET (LIBAVCODEC_VERSION_MAJOR < 59)
 #endif
+#ifndef FF_API_USER_VISIBLE_AVHWACCEL
+#define FF_API_USER_VISIBLE_AVHWACCEL (LIBAVCODEC_VERSION_MAJOR < 59)
+#endif
 
 
 #endif /* AVCODEC_VERSION_H */
-- 
2.11.0

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


[FFmpeg-devel] [PATCH 01/17] lavc: Add codec metadata to indicate hardware support

2017-11-23 Thread Mark Thompson
---
 doc/APIchanges   |  3 +++
 libavcodec/avcodec.h | 74 
 libavcodec/hwaccel.h | 18 +
 libavcodec/utils.c   | 12 +
 4 files changed, 107 insertions(+)

diff --git a/doc/APIchanges b/doc/APIchanges
index 45276f734c..704efe1719 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -15,6 +15,9 @@ libavutil: 2017-10-21
 
 API changes, most recent first:
 
+2017-xx-xx - xxx - lavc 58.x+1.0 - avcodec.h
+  Add AVCodecHWConfig and avcodec_get_hw_config().
+
 2017-11-xx - xxx - lavu 55.3.0 - opencl.h
   Remove experiental OpenCL API (av_opencl_*).
 
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 4cd72b5961..e2dc97d62f 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -36,6 +36,7 @@
 #include "libavutil/channel_layout.h"
 #include "libavutil/dict.h"
 #include "libavutil/frame.h"
+#include "libavutil/hwcontext.h"
 #include "libavutil/log.h"
 #include "libavutil/pixfmt.h"
 #include "libavutil/rational.h"
@@ -3279,6 +3280,61 @@ typedef struct AVProfile {
 const char *name; ///< short name for the profile
 } AVProfile;
 
+enum {
+/**
+ * The codec supports this format via the hw_device_ctx interface.
+ *
+ * When selecting this format, AVCodecContext.hw_device_ctx should
+ * have been set to a device of the specified type before calling
+ * avcodec_open2().
+ */
+AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX = 0x01,
+/**
+ * The codec supports this format via the hw_frames_ctx interface.
+ *
+ * When selecting this format for a decoder,
+ * AVCodecContext.hw_frames_ctx should be set to a suitable frames
+ * context inside the get_format() callback.  The frames context
+ * must have been created on a device of the specified type.
+ */
+AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX = 0x02,
+/**
+ * The codec supports this format by some internal method.
+ *
+ * This format can be selected without any additional configuration -
+ * no device or frames context is required.
+ */
+AV_CODEC_HW_CONFIG_METHOD_INTERNAL  = 0x04,
+/**
+ * The codec supports this format by some ad-hoc method.
+ *
+ * Additional settings and/or function calls are required.  See the
+ * codec-specific documentation for details.  (Methods requiring
+ * this sort of configuration are deprecated and others should be
+ * used in preference.)
+ */
+AV_CODEC_HW_CONFIG_METHOD_AD_HOC= 0x08,
+};
+
+typedef struct AVCodecHWConfig {
+/**
+ * A hardware pixel format which the codec can use.
+ */
+enum AVPixelFormat pix_fmt;
+/**
+ * Bit set of AV_CODEC_HW_CONFIG_METHOD_* flags, describing the possible
+ * setup methods which can be used with this configuration.
+ */
+int methods;
+/**
+ * The device type associated with the configuration.
+ *
+ * Must be set for AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX and
+ * AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX, otherwise unused.
+ */
+enum AVHWDeviceType device_type;
+} AVCodecHWConfig;
+
 typedef struct AVCodecDefault AVCodecDefault;
 
 struct AVSubtitle;
@@ -3404,6 +3460,15 @@ typedef struct AVCodec {
  * packets before decoding.
  */
 const char *bsfs;
+
+/**
+ * Array of pointers to hardware configurations supported by the codec,
+ * or NULL if no hardware supported.  The array is terminated by a NULL
+ * pointer.
+ *
+ * The user can only access this field via avcodec_get_hw_config().
+ */
+const struct AVCodecHWConfigInternal **hw_configs;
 } AVCodec;
 
 #if FF_API_CODEC_GET_SET
@@ -3414,6 +3479,15 @@ int av_codec_get_max_lowres(const AVCodec *codec);
 struct MpegEncContext;
 
 /**
+ * Retrieve supported hardware configurations for a codec.
+ *
+ * Values of index from zero to some maximum return the indexed configuration
+ * descriptor; all other values return NULL.  If the codec does not support
+ * any hardware configurations then it will always return NULL.
+ */
+const AVCodecHWConfig *avcodec_get_hw_config(const AVCodec *codec, int index);
+
+/**
  * @defgroup lavc_hwaccel AVHWAccel
  * @{
  */
diff --git a/libavcodec/hwaccel.h b/libavcodec/hwaccel.h
index 124fbbf1fd..0198c7f858 100644
--- a/libavcodec/hwaccel.h
+++ b/libavcodec/hwaccel.h
@@ -19,6 +19,24 @@
 #ifndef AVCODEC_HWACCEL_H
 #define AVCODEC_HWACCEL_H
 
+#include "avcodec.h"
+
+
 #define HWACCEL_CAP_ASYNC_SAFE  (1 << 0)
 
+
+typedef struct AVCodecHWConfigInternal {
+/**
+ * This is the structure which will be returned to the user by
+ * avcodec_get_hw_config().
+ */
+AVCodecHWConfig public;
+/**
+ * If this configuration uses a hwaccel, a pointer to it.
+ * If not, NULL.
+ */
+const AVHWAccel *hwaccel;
+} AVCodecHWConfigInternal;
+
+
 #endif /* AVCODEC_HWACCEL_H */
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index e50de6e89b..01bf7556f7 100644
--- 

[FFmpeg-devel] [PATCH 05/17] lavc: Remove register mechanism for hwaccels

2017-11-23 Thread Mark Thompson
There is no longer any need for a list of them at runtime, because
decoders now carry the pointers to their associated hwaccels internally.
The file containing external declarations is now used to make the list
of hwaccels for configure.
---
 configure  |  2 +-
 libavcodec/allcodecs.c | 82 --
 2 files changed, 1 insertion(+), 83 deletions(-)

diff --git a/configure b/configure
index 3ec6407fb2..d74bd06be5 100755
--- a/configure
+++ b/configure
@@ -3524,7 +3524,6 @@ find_things(){
 
 ENCODER_LIST=$(find_things  encoder  ENC  libavcodec/allcodecs.c)
 DECODER_LIST=$(find_things  decoder  DEC  libavcodec/allcodecs.c)
-HWACCEL_LIST=$(find_things  hwaccel  HWACCEL  libavcodec/allcodecs.c)
 PARSER_LIST=$(find_things   parser   PARSER   libavcodec/allcodecs.c)
 MUXER_LIST=$(find_thingsmuxer_MUX libavformat/allformats.c)
 DEMUXER_LIST=$(find_things  demuxer  DEMUXlibavformat/allformats.c)
@@ -3540,6 +3539,7 @@ find_things_extern(){
 }
 
 BSF_LIST=$(find_things_extern bsf AVBitStreamFilter 
libavcodec/bitstream_filters.c)
+HWACCEL_LIST=$(find_things_extern hwaccel AVHWAccel libavcodec/hwaccels.h)
 PROTOCOL_LIST=$(find_things_extern protocol URLProtocol 
libavformat/protocols.c)
 
 AVCODEC_COMPONENTS_LIST="
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index 85c38c83aa..4a21687b20 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -29,13 +29,6 @@
 #include "avcodec.h"
 #include "version.h"
 
-#define REGISTER_HWACCEL(X, x)  \
-{   \
-extern AVHWAccel ff_##x##_hwaccel;  \
-if (CONFIG_##X##_HWACCEL)   \
-av_register_hwaccel(_##x##_hwaccel); \
-}
-
 #define REGISTER_ENCODER(X, x)  \
 {   \
 extern AVCodec ff_##x##_encoder;\
@@ -61,81 +54,6 @@
 
 static void register_all(void)
 {
-/* hardware accelerators */
-REGISTER_HWACCEL(H263_VAAPI,h263_vaapi);
-REGISTER_HWACCEL(H263_VIDEOTOOLBOX, h263_videotoolbox);
-REGISTER_HWACCEL(H264_CUVID,h264_cuvid);
-REGISTER_HWACCEL(H264_D3D11VA,  h264_d3d11va);
-REGISTER_HWACCEL(H264_D3D11VA2, h264_d3d11va2);
-REGISTER_HWACCEL(H264_DXVA2,h264_dxva2);
-REGISTER_HWACCEL(H264_MEDIACODEC,   h264_mediacodec);
-REGISTER_HWACCEL(H264_MMAL, h264_mmal);
-REGISTER_HWACCEL(H264_NVDEC,h264_nvdec);
-REGISTER_HWACCEL(H264_QSV,  h264_qsv);
-REGISTER_HWACCEL(H264_VAAPI,h264_vaapi);
-REGISTER_HWACCEL(H264_VDPAU,h264_vdpau);
-REGISTER_HWACCEL(H264_VIDEOTOOLBOX, h264_videotoolbox);
-REGISTER_HWACCEL(HEVC_CUVID,hevc_cuvid);
-REGISTER_HWACCEL(HEVC_D3D11VA,  hevc_d3d11va);
-REGISTER_HWACCEL(HEVC_D3D11VA2, hevc_d3d11va2);
-REGISTER_HWACCEL(HEVC_DXVA2,hevc_dxva2);
-REGISTER_HWACCEL(HEVC_NVDEC,hevc_nvdec);
-REGISTER_HWACCEL(HEVC_MEDIACODEC,   hevc_mediacodec);
-REGISTER_HWACCEL(HEVC_QSV,  hevc_qsv);
-REGISTER_HWACCEL(HEVC_VAAPI,hevc_vaapi);
-REGISTER_HWACCEL(HEVC_VDPAU,hevc_vdpau);
-REGISTER_HWACCEL(HEVC_VIDEOTOOLBOX, hevc_videotoolbox);
-REGISTER_HWACCEL(MJPEG_CUVID,   mjpeg_cuvid);
-REGISTER_HWACCEL(MPEG1_CUVID,   mpeg1_cuvid);
-REGISTER_HWACCEL(MPEG1_NVDEC,   mpeg1_nvdec);
-REGISTER_HWACCEL(MPEG1_XVMC,mpeg1_xvmc);
-REGISTER_HWACCEL(MPEG1_VDPAU,   mpeg1_vdpau);
-REGISTER_HWACCEL(MPEG1_VIDEOTOOLBOX, mpeg1_videotoolbox);
-REGISTER_HWACCEL(MPEG2_CUVID,   mpeg2_cuvid);
-REGISTER_HWACCEL(MPEG2_XVMC,mpeg2_xvmc);
-REGISTER_HWACCEL(MPEG2_D3D11VA, mpeg2_d3d11va);
-REGISTER_HWACCEL(MPEG2_D3D11VA2,mpeg2_d3d11va2);
-REGISTER_HWACCEL(MPEG2_DXVA2,   mpeg2_dxva2);
-REGISTER_HWACCEL(MPEG2_MMAL,mpeg2_mmal);
-REGISTER_HWACCEL(MPEG2_NVDEC,   mpeg2_nvdec);
-REGISTER_HWACCEL(MPEG2_QSV, mpeg2_qsv);
-REGISTER_HWACCEL(MPEG2_VAAPI,   mpeg2_vaapi);
-REGISTER_HWACCEL(MPEG2_VDPAU,   mpeg2_vdpau);
-REGISTER_HWACCEL(MPEG2_VIDEOTOOLBOX, mpeg2_videotoolbox);
-REGISTER_HWACCEL(MPEG2_MEDIACODEC,  mpeg2_mediacodec);
-REGISTER_HWACCEL(MPEG4_CUVID,   mpeg4_cuvid);
-REGISTER_HWACCEL(MPEG4_MEDIACODEC,  mpeg4_mediacodec);
-REGISTER_HWACCEL(MPEG4_MMAL,mpeg4_mmal);
-REGISTER_HWACCEL(MPEG4_NVDEC,   mpeg4_nvdec);
-REGISTER_HWACCEL(MPEG4_VAAPI,   mpeg4_vaapi);
-REGISTER_HWACCEL(MPEG4_VDPAU,   mpeg4_vdpau);
-REGISTER_HWACCEL(MPEG4_VIDEOTOOLBOX, mpeg4_videotoolbox);
-REGISTER_HWACCEL(VC1_CUVID, vc1_cuvid);
-REGISTER_HWACCEL(VC1_D3D11VA,   

[FFmpeg-devel] [PATCH v3 1/2] avformat/hlsenc: Modularized playlist creation to allow reuse

2017-11-23 Thread Karthick J
---
 libavformat/hlsenc.c | 238 +++
 libavformat/hlsenc.h |  68 +++
 2 files changed, 194 insertions(+), 112 deletions(-)
 create mode 100644 libavformat/hlsenc.h

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 30ccf73..5c4f459 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -45,6 +45,7 @@
 
 #include "avformat.h"
 #include "avio_internal.h"
+#include "hlsenc.h"
 #include "internal.h"
 #include "os_support.h"
 
@@ -73,36 +74,11 @@ typedef struct HLSSegment {
 struct HLSSegment *next;
 } HLSSegment;
 
-typedef enum HLSFlags {
-// Generate a single media file and use byte ranges in the playlist.
-HLS_SINGLE_FILE = (1 << 0),
-HLS_DELETE_SEGMENTS = (1 << 1),
-HLS_ROUND_DURATIONS = (1 << 2),
-HLS_DISCONT_START = (1 << 3),
-HLS_OMIT_ENDLIST = (1 << 4),
-HLS_SPLIT_BY_TIME = (1 << 5),
-HLS_APPEND_LIST = (1 << 6),
-HLS_PROGRAM_DATE_TIME = (1 << 7),
-HLS_SECOND_LEVEL_SEGMENT_INDEX = (1 << 8), // include segment index in 
segment filenames when use_localtime  e.g.: %%03d
-HLS_SECOND_LEVEL_SEGMENT_DURATION = (1 << 9), // include segment duration 
(microsec) in segment filenames when use_localtime  e.g.: %%09t
-HLS_SECOND_LEVEL_SEGMENT_SIZE = (1 << 10), // include segment size (bytes) 
in segment filenames when use_localtime  e.g.: %%014s
-HLS_TEMP_FILE = (1 << 11),
-HLS_PERIODIC_REKEY = (1 << 12),
-HLS_INDEPENDENT_SEGMENTS = (1 << 13),
-} HLSFlags;
-
 typedef enum {
 SEGMENT_TYPE_MPEGTS,
 SEGMENT_TYPE_FMP4,
 } SegmentType;
 
-typedef enum {
-PLAYLIST_TYPE_NONE,
-PLAYLIST_TYPE_EVENT,
-PLAYLIST_TYPE_VOD,
-PLAYLIST_TYPE_NB,
-} PlaylistType;
-
 typedef struct VariantStream {
 unsigned number;
 int64_t sequence;
@@ -207,6 +183,113 @@ typedef struct HLSContext {
 unsigned int master_publish_rate;
 } HLSContext;
 
+void ff_hls_write_playlist_version(AVIOContext *out, int version) {
+if (!out)
+return;
+avio_printf(out, "#EXTM3U\n");
+avio_printf(out, "#EXT-X-VERSION:%d\n", version);
+}
+
+void ff_hls_write_stream_info(AVStream *st, AVIOContext *out,
+  int bandwidth, char *filename) {
+if (!out || !filename)
+return;
+
+if (!bandwidth) {
+av_log(NULL, AV_LOG_WARNING,
+"Bandwidth info not available, set audio and video 
bitrates\n");
+return;
+}
+
+avio_printf(out, "#EXT-X-STREAM-INF:BANDWIDTH=%d", bandwidth);
+if (st && st->codecpar->width > 0 && st->codecpar->height > 0)
+avio_printf(out, ",RESOLUTION=%dx%d", st->codecpar->width,
+st->codecpar->height);
+avio_printf(out, "\n%s\n\n", filename);
+}
+
+void ff_hls_write_playlist_header(AVIOContext *out, int version, int 
allowcache,
+  int target_duration, int64_t sequence,
+  uint32_t playlist_type) {
+if (!out)
+return;
+ff_hls_write_playlist_version(out, version);
+if (allowcache == 0 || allowcache == 1) {
+avio_printf(out, "#EXT-X-ALLOW-CACHE:%s\n", allowcache == 0 ? "NO" : 
"YES");
+}
+avio_printf(out, "#EXT-X-TARGETDURATION:%d\n", target_duration);
+avio_printf(out, "#EXT-X-MEDIA-SEQUENCE:%"PRId64"\n", sequence);
+av_log(NULL, AV_LOG_VERBOSE, "EXT-X-MEDIA-SEQUENCE:%"PRId64"\n", sequence);
+
+if (playlist_type == PLAYLIST_TYPE_EVENT) {
+avio_printf(out, "#EXT-X-PLAYLIST-TYPE:EVENT\n");
+} else if (playlist_type == PLAYLIST_TYPE_VOD) {
+avio_printf(out, "#EXT-X-PLAYLIST-TYPE:VOD\n");
+}
+}
+
+void ff_hls_write_init_file(AVIOContext *out, char *filename,
+int byterange_mode, int64_t size, int64_t pos) {
+avio_printf(out, "#EXT-X-MAP:URI=\"%s\"", filename);
+if (byterange_mode) {
+avio_printf(out, ",BYTERANGE=\"%"PRId64"@%"PRId64"\"", size, pos);
+}
+avio_printf(out, "\n");
+}
+
+void ff_hls_write_file_entry(AVIOContext *out, int insert_discont,
+int byterange_mode, uint32_t flags, double 
duration,
+int64_t size, int64_t pos, //Used only if 
HLS_SINGLE_FILE flag is set
+char *baseurl, //Ignored if NULL
+char *filename, double *prog_date_time) {
+if (!out || !filename)
+return;
+
+if (insert_discont) {
+avio_printf(out, "#EXT-X-DISCONTINUITY\n");
+}
+if (flags & HLS_ROUND_DURATIONS)
+avio_printf(out, "#EXTINF:%ld,\n",  lrint(duration));
+else
+avio_printf(out, "#EXTINF:%f,\n", duration);
+if (byterange_mode)
+avio_printf(out, "#EXT-X-BYTERANGE:%"PRId64"@%"PRId64"\n", size, pos);
+
+if ((flags & HLS_PROGRAM_DATE_TIME) && prog_date_time) {
+time_t tt, wrongsecs;
+int milli;
+struct tm *tm, tmpbuf;
+char buf0[128], buf1[128];
+tt = 

Re: [FFmpeg-devel] [PATCH 14/17] mjpegdec: Add hwaccel hooks

2017-11-23 Thread Jun Zhao


On 2017/11/24 8:51, Mark Thompson wrote:
> Also adds some extra fields to the main context structure that may
> be needed by a hwaccel decoder.
> ---
> The YUVJ formats really mess with this.  This patch hacks them out so that 
> the hwaccel works, suggestions welcome on what to actually do about them.
>
>
>  libavcodec/mjpegdec.c | 70 
> +--
>  libavcodec/mjpegdec.h | 11 
>  2 files changed, 79 insertions(+), 2 deletions(-)
>
> diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
> index f01d44a169..846dec2f42 100644
> --- a/libavcodec/mjpegdec.c
> +++ b/libavcodec/mjpegdec.c
> @@ -36,6 +36,7 @@
>  #include "avcodec.h"
>  #include "blockdsp.h"
>  #include "copy_block.h"
> +#include "hwaccel.h"
>  #include "idctdsp.h"
>  #include "internal.h"
>  #include "jpegtables.h"
> @@ -147,6 +148,7 @@ av_cold int ff_mjpeg_decode_init(AVCodecContext *avctx)
>  s->org_height= avctx->coded_height;
>  avctx->chroma_sample_location = AVCHROMA_LOC_CENTER;
>  avctx->colorspace = AVCOL_SPC_BT470BG;
> +s->hwaccel_pix_fmt = s->hwaccel_sw_pix_fmt = AV_PIX_FMT_NONE;
>  
>  if ((ret = build_basic_mjpeg_vlc(s)) < 0)
>  return ret;
> @@ -279,6 +281,11 @@ int ff_mjpeg_decode_dht(MJpegDecodeContext *s)
>   code_max + 1, 0, 0)) < 0)
>  return ret;
>  }
> +
> +for (i = 0; i < 16; i++)
> +s->raw_huffman_lengths[class][index][i] = bits_table[i + 1];
> +for (i = 0; i < 256; i++)
> +s->raw_huffman_values[class][index][i] = val_table[i];
>  }
>  return 0;
>  }
> @@ -636,6 +643,26 @@ unk_pixfmt:
>  return AVERROR_BUG;
>  }
>  
> +if (s->avctx->pix_fmt == AV_PIX_FMT_YUVJ420P)
> +s->avctx->pix_fmt = AV_PIX_FMT_YUV420P;
> +if (s->avctx->pix_fmt == AV_PIX_FMT_YUVJ422P)
> +s->avctx->pix_fmt = AV_PIX_FMT_YUV422P;
> +
Maybe need to give a comments in the code for this workaround, not just
in the commit message.
> +if (s->avctx->pix_fmt == s->hwaccel_sw_pix_fmt) {
> +s->avctx->pix_fmt = s->hwaccel_pix_fmt;
> +} else {
> +enum AVPixelFormat pix_fmts[] = {
> +s->avctx->pix_fmt,
> +AV_PIX_FMT_NONE,
> +};
> +s->hwaccel_pix_fmt = ff_get_format(s->avctx, pix_fmts);
> +if (s->hwaccel_pix_fmt < 0)
> +return AVERROR(EINVAL);
> +
> +s->hwaccel_sw_pix_fmt = s->avctx->pix_fmt;
> +s->avctx->pix_fmt = s->hwaccel_pix_fmt;
> +}
> +
>  if (s->avctx->skip_frame == AVDISCARD_ALL) {
>  s->picture_ptr->pict_type = AV_PICTURE_TYPE_I;
>  s->picture_ptr->key_frame = 1;
> @@ -683,6 +710,19 @@ unk_pixfmt:
>  }
>  memset(s->coefs_finished, 0, sizeof(s->coefs_finished));
>  }
> +
> +if (s->avctx->hwaccel) {
> +s->hwaccel_picture_private =
> +av_mallocz(s->avctx->hwaccel->frame_priv_data_size);
> +if (!s->hwaccel_picture_private)
> +return AVERROR(ENOMEM);
> +
> +ret = s->avctx->hwaccel->start_frame(s->avctx, s->raw_buffer,
> + s->raw_buffer_size);
> +if (ret < 0)
> +return ret;
> +}
> +
>  return 0;
>  }
>  
> @@ -1510,7 +1550,7 @@ int ff_mjpeg_decode_sos(MJpegDecodeContext *s, const 
> uint8_t *mb_bitmask,
>  }
>  }
>  
> -av_assert0(s->picture_ptr->data[0]);
> +//av_assert0(s->picture_ptr->data[0]);
Remove the assert ?
>  /* XXX: verify len field validity */
>  len = get_bits(>gb, 16);
>  nb_components = get_bits(>gb, 8);
> @@ -1600,7 +1640,18 @@ next_field:
>  for (i = 0; i < nb_components; i++)
>  s->last_dc[i] = (4 << s->bits);
>  
> -if (s->lossless) {
> +if (s->avctx->hwaccel) {
> +int bytes_to_start = get_bits_count(>gb) / 8;
> +av_assert0(bytes_to_start >= 0 &&
> +   s->raw_buffer_size >= bytes_to_start);
> +
> +ret = s->avctx->hwaccel->decode_slice(s->avctx,
> +  s->raw_buffer  + 
> bytes_to_start,
> +  s->raw_buffer_size - 
> bytes_to_start);
> +if (ret < 0)
> +return ret;
> +
> +} else if (s->lossless) {
>  av_assert0(s->picture_ptr == s->picture);
>  if (CONFIG_JPEGLS_DECODER && s->ls) {
>  //for () {
> @@ -2226,6 +2277,9 @@ int ff_mjpeg_decode_frame(AVCodecContext *avctx, void 
> *data, int *got_frame,
>  goto fail;
>  }
>  
> +s->raw_buffer  = buf_ptr;
> +s->raw_buffer_size = buf_end - buf_ptr;
> +
>  s->start_code = start_code;
>  if (s->avctx->debug & FF_DEBUG_STARTCODE)
>  av_log(avctx, AV_LOG_DEBUG, "startcode: %X\n", start_code);
> @@ -2349,6 +2403,13 @@ eoi_parser:
>  s->got_picture = 0;
>  goto the_end_no_picture;
>  }

Re: [FFmpeg-devel] [PATCH v2 1/2] avformat/hlsenc: Modularized playlist creation to allow reuse

2017-11-23 Thread Jeyapal, Karthick
I have rebased the below patch for latest master and have sent a new patch v3.

Regards,
Karthick

On 11/22/17, 2:50 PM, "Karthick J"  wrote:

---
 libavformat/hlsenc.c | 237 +++
 libavformat/hlsenc.h |  67 +++
 2 files changed, 193 insertions(+), 111 deletions(-)
 create mode 100644 libavformat/hlsenc.h

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 3c47ced..d5b1b98 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -45,6 +45,7 @@
 
 #include "avformat.h"
 #include "avio_internal.h"
+#include "hlsenc.h"
 #include "internal.h"
 #include "os_support.h"
 
@@ -73,35 +74,11 @@ typedef struct HLSSegment {
 struct HLSSegment *next;
 } HLSSegment;
 
-typedef enum HLSFlags {
-// Generate a single media file and use byte ranges in the playlist.
-HLS_SINGLE_FILE = (1 << 0),
-HLS_DELETE_SEGMENTS = (1 << 1),
-HLS_ROUND_DURATIONS = (1 << 2),
-HLS_DISCONT_START = (1 << 3),
-HLS_OMIT_ENDLIST = (1 << 4),
-HLS_SPLIT_BY_TIME = (1 << 5),
-HLS_APPEND_LIST = (1 << 6),
-HLS_PROGRAM_DATE_TIME = (1 << 7),
-HLS_SECOND_LEVEL_SEGMENT_INDEX = (1 << 8), // include segment index in 
segment filenames when use_localtime  e.g.: %%03d
-HLS_SECOND_LEVEL_SEGMENT_DURATION = (1 << 9), // include segment duration 
(microsec) in segment filenames when use_localtime  e.g.: %%09t
-HLS_SECOND_LEVEL_SEGMENT_SIZE = (1 << 10), // include segment size (bytes) 
in segment filenames when use_localtime  e.g.: %%014s
-HLS_TEMP_FILE = (1 << 11),
-HLS_PERIODIC_REKEY = (1 << 12),
-} HLSFlags;
-
 typedef enum {
 SEGMENT_TYPE_MPEGTS,
 SEGMENT_TYPE_FMP4,
 } SegmentType;
 
-typedef enum {
-PLAYLIST_TYPE_NONE,
-PLAYLIST_TYPE_EVENT,
-PLAYLIST_TYPE_VOD,
-PLAYLIST_TYPE_NB,
-} PlaylistType;
-
 typedef struct VariantStream {
 unsigned number;
 int64_t sequence;
@@ -206,6 +183,113 @@ typedef struct HLSContext {
 unsigned int master_publish_rate;
 } HLSContext;
 
+void ff_hls_write_playlist_version(AVIOContext *out, int version) {
+if (!out)
+return;
+avio_printf(out, "#EXTM3U\n");
+avio_printf(out, "#EXT-X-VERSION:%d\n", version);
+}
+
+void ff_hls_write_stream_info(AVStream *st, AVIOContext *out,
+  int bandwidth, char *filename) {
+if (!out || !filename)
+return;
+
+if (!bandwidth) {
+av_log(NULL, AV_LOG_WARNING,
+"Bandwidth info not available, set audio and video 
bitrates\n");
+return;
+}
+
+avio_printf(out, "#EXT-X-STREAM-INF:BANDWIDTH=%d", bandwidth);
+if (st && st->codecpar->width > 0 && st->codecpar->height > 0)
+avio_printf(out, ",RESOLUTION=%dx%d", st->codecpar->width,
+st->codecpar->height);
+avio_printf(out, "\n%s\n\n", filename);
+}
+
+void ff_hls_write_playlist_header(AVIOContext *out, int version, int 
allowcache,
+  int target_duration, int64_t sequence,
+  uint32_t playlist_type) {
+if (!out)
+return;
+ff_hls_write_playlist_version(out, version);
+if (allowcache == 0 || allowcache == 1) {
+avio_printf(out, "#EXT-X-ALLOW-CACHE:%s\n", allowcache == 0 ? "NO" : 
"YES");
+}
+avio_printf(out, "#EXT-X-TARGETDURATION:%d\n", target_duration);
+avio_printf(out, "#EXT-X-MEDIA-SEQUENCE:%"PRId64"\n", sequence);
+av_log(NULL, AV_LOG_VERBOSE, "EXT-X-MEDIA-SEQUENCE:%"PRId64"\n", sequence);
+
+if (playlist_type == PLAYLIST_TYPE_EVENT) {
+avio_printf(out, "#EXT-X-PLAYLIST-TYPE:EVENT\n");
+} else if (playlist_type == PLAYLIST_TYPE_VOD) {
+avio_printf(out, "#EXT-X-PLAYLIST-TYPE:VOD\n");
+}
+}
+
+void ff_hls_write_init_file(AVIOContext *out, char *filename,
+int byterange_mode, int64_t size, int64_t pos) {
+avio_printf(out, "#EXT-X-MAP:URI=\"%s\"", filename);
+if (byterange_mode) {
+avio_printf(out, ",BYTERANGE=\"%"PRId64"@%"PRId64"\"", size, pos);
+}
+avio_printf(out, "\n");
+}
+
+void ff_hls_write_file_entry(AVIOContext *out, int insert_discont,
+int byterange_mode, uint32_t flags, double 
duration,
+int64_t size, int64_t pos, //Used only if 
HLS_SINGLE_FILE flag is set
+char *baseurl, //Ignored if NULL
+char *filename, double *prog_date_time) {
+if (!out || !filename)
+return;
+
+if (insert_discont) {
+avio_printf(out, "#EXT-X-DISCONTINUITY\n");
+}
+if (flags & HLS_ROUND_DURATIONS)
+avio_printf(out, "#EXTINF:%ld,\n",  lrint(duration));
+else
+avio_printf(out, "#EXTINF:%f,\n", duration);
+if (byterange_mode)
+avio_printf(out, "#EXT-X-BYTERANGE:%"PRId64"@%"PRId64"\n", size, pos);
+
+if ((flags & HLS_PROGRAM_DATE_TIME) && prog_date_time) {
+time_t tt, wrongsecs;
+

Re: [FFmpeg-devel] [PATCH 2/2] avcodec/sbrdsp_fixed: Fix integer overflow

2017-11-23 Thread James Almer
On 11/22/2017 7:59 PM, Hendrik Leppkes wrote:
> On Wed, Nov 22, 2017 at 11:38 PM, Carl Eugen Hoyos  wrote:
>> 2017-11-22 21:00 GMT+01:00 Michael Niedermayer :
>>
>>> diff --git a/libavcodec/sbrdsp_fixed.c b/libavcodec/sbrdsp_fixed.c
>>> index a0ef6859f1..0db932a105 100644
>>> --- a/libavcodec/sbrdsp_fixed.c
>>> +++ b/libavcodec/sbrdsp_fixed.c
>>> @@ -133,7 +133,7 @@ static av_always_inline SoftFloat autocorr_calc(int64_t 
>>> accu)
>>>
>>>  round = 1U << (nz-1);
>>>  mant = (int)((accu + round) >> nz);
>>> -mant = (mant + 0x40)>>7;
>>> +mant = (mant + 0x40ll)>>7;
>>
>> LL?
>>
> 
> More correctly, shouldnt this use one of those fancy integer constant
> macros, like INT64_C(0x40)? (I don't actually know if those are
> supposed to work with hex constants, but the fact that they exist
> seems to indicate that LL is not entirely portable)
> 
> - Hendrik

LL/ULL are used plenty of times in the tree, so it's portable enough.
What i remember not working at least on old msvc was LLU.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH v3 1/2] avformat/hlsenc: Modularized playlist creation to allow reuse

2017-11-23 Thread 刘歧

> 在 2017年11月24日,11:55,Karthick J  写道:
> 
> ---
> libavformat/hlsenc.c | 238 +++
> libavformat/hlsenc.h |  68 +++
> 2 files changed, 194 insertions(+), 112 deletions(-)
> create mode 100644 libavformat/hlsenc.h
> 
> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> index 30ccf73..5c4f459 100644
> --- a/libavformat/hlsenc.c
> +++ b/libavformat/hlsenc.c
> @@ -45,6 +45,7 @@
> 
> #include "avformat.h"
> #include "avio_internal.h"
> +#include "hlsenc.h"
> #include "internal.h"
> #include "os_support.h"
> 
> @@ -73,36 +74,11 @@ typedef struct HLSSegment {
> struct HLSSegment *next;
> } HLSSegment;
> 
> -typedef enum HLSFlags {
> -// Generate a single media file and use byte ranges in the playlist.
> -HLS_SINGLE_FILE = (1 << 0),
> -HLS_DELETE_SEGMENTS = (1 << 1),
> -HLS_ROUND_DURATIONS = (1 << 2),
> -HLS_DISCONT_START = (1 << 3),
> -HLS_OMIT_ENDLIST = (1 << 4),
> -HLS_SPLIT_BY_TIME = (1 << 5),
> -HLS_APPEND_LIST = (1 << 6),
> -HLS_PROGRAM_DATE_TIME = (1 << 7),
> -HLS_SECOND_LEVEL_SEGMENT_INDEX = (1 << 8), // include segment index in 
> segment filenames when use_localtime  e.g.: %%03d
> -HLS_SECOND_LEVEL_SEGMENT_DURATION = (1 << 9), // include segment 
> duration (microsec) in segment filenames when use_localtime  e.g.: %%09t
> -HLS_SECOND_LEVEL_SEGMENT_SIZE = (1 << 10), // include segment size 
> (bytes) in segment filenames when use_localtime  e.g.: %%014s
> -HLS_TEMP_FILE = (1 << 11),
> -HLS_PERIODIC_REKEY = (1 << 12),
> -HLS_INDEPENDENT_SEGMENTS = (1 << 13),
> -} HLSFlags;
> -
> typedef enum {
> SEGMENT_TYPE_MPEGTS,
> SEGMENT_TYPE_FMP4,
> } SegmentType;
> 
> -typedef enum {
> -PLAYLIST_TYPE_NONE,
> -PLAYLIST_TYPE_EVENT,
> -PLAYLIST_TYPE_VOD,
> -PLAYLIST_TYPE_NB,
> -} PlaylistType;
> -
> typedef struct VariantStream {
> unsigned number;
> int64_t sequence;
> @@ -207,6 +183,113 @@ typedef struct HLSContext {
> unsigned int master_publish_rate;
> } HLSContext;
> 
> +void ff_hls_write_playlist_version(AVIOContext *out, int version) {
> +if (!out)
> +return;
> +avio_printf(out, "#EXTM3U\n");
> +avio_printf(out, "#EXT-X-VERSION:%d\n", version);
> +}
> +
> +void ff_hls_write_stream_info(AVStream *st, AVIOContext *out,
> +  int bandwidth, char *filename) {
> +if (!out || !filename)
> +return;
> +
> +if (!bandwidth) {
> +av_log(NULL, AV_LOG_WARNING,
> +"Bandwidth info not available, set audio and video 
> bitrates\n");
> +return;
> +}
> +
> +avio_printf(out, "#EXT-X-STREAM-INF:BANDWIDTH=%d", bandwidth);
> +if (st && st->codecpar->width > 0 && st->codecpar->height > 0)
> +avio_printf(out, ",RESOLUTION=%dx%d", st->codecpar->width,
> +st->codecpar->height);
> +avio_printf(out, "\n%s\n\n", filename);
> +}
> +
> +void ff_hls_write_playlist_header(AVIOContext *out, int version, int 
> allowcache,
> +  int target_duration, int64_t sequence,
> +  uint32_t playlist_type) {
> +if (!out)
> +return;
> +ff_hls_write_playlist_version(out, version);
> +if (allowcache == 0 || allowcache == 1) {
> +avio_printf(out, "#EXT-X-ALLOW-CACHE:%s\n", allowcache == 0 ? "NO" : 
> "YES");
> +}
> +avio_printf(out, "#EXT-X-TARGETDURATION:%d\n", target_duration);
> +avio_printf(out, "#EXT-X-MEDIA-SEQUENCE:%"PRId64"\n", sequence);
> +av_log(NULL, AV_LOG_VERBOSE, "EXT-X-MEDIA-SEQUENCE:%"PRId64"\n", 
> sequence);
> +
> +if (playlist_type == PLAYLIST_TYPE_EVENT) {
> +avio_printf(out, "#EXT-X-PLAYLIST-TYPE:EVENT\n");
> +} else if (playlist_type == PLAYLIST_TYPE_VOD) {
> +avio_printf(out, "#EXT-X-PLAYLIST-TYPE:VOD\n");
> +}
> +}
> +
> +void ff_hls_write_init_file(AVIOContext *out, char *filename,
> +int byterange_mode, int64_t size, int64_t pos) {
> +avio_printf(out, "#EXT-X-MAP:URI=\"%s\"", filename);
> +if (byterange_mode) {
> +avio_printf(out, ",BYTERANGE=\"%"PRId64"@%"PRId64"\"", size, pos);
> +}
> +avio_printf(out, "\n");
> +}
> +
> +void ff_hls_write_file_entry(AVIOContext *out, int insert_discont,
> +int byterange_mode, uint32_t flags, double 
> duration,
> +int64_t size, int64_t pos, //Used only if 
> HLS_SINGLE_FILE flag is set
> +char *baseurl, //Ignored if NULL
> +char *filename, double *prog_date_time) {
> +if (!out || !filename)
> +return;
> +
> +if (insert_discont) {
> +avio_printf(out, "#EXT-X-DISCONTINUITY\n");
> +}
> +if (flags & HLS_ROUND_DURATIONS)
> +avio_printf(out, "#EXTINF:%ld,\n",  lrint(duration));
> +else
> +avio_printf(out, "#EXTINF:%f,\n", duration);
> +if 

Re: [FFmpeg-devel] [PATCH v3 1/2] avformat/hlsenc: Modularized playlist creation to allow reuse

2017-11-23 Thread Jeyapal, Karthick
>On 11/24/17, 9:44 AM, "刘歧"  wrote:
>
>
>> 在 2017年11月24日,11:55,Karthick J  写道:
>> 
>> ---
>> libavformat/hlsenc.c | 238 
>> +++
>> libavformat/hlsenc.h |  68 +++
>> 2 files changed, 194 insertions(+), 112 deletions(-)
>> create mode 100644 libavformat/hlsenc.h
>[…]
>I suggest move the ff_ functions to a common file, because the hlsenc file 
>modify frequently,
>there have risk to be modify by other contributor, these functions maybe need 
>design clearly,
>it is used only by hlsenc and dashenc, i cannot sure it be used by other 
>module future, 
>so modify it is hard work for the modules after this commit.
>Move them to segment_common.c or a good filename.c maybe better than in hlsenc.
>What about your mind?
Thanks for the reply. 
I have segregated ff_ functions into a separate .c file as you suggested, in 
patchset v4.

>
>Thanks

regards,
Karthick

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


Re: [FFmpeg-devel] [PATCH] avformat/avienc: fix fields-per-frame value for interlaced video streams

2017-11-23 Thread Tobias Rapp

On 23.11.2017 00:10, Derek Buitenhuis wrote:

On 11/22/2017 10:52 PM, Carl Eugen Hoyos wrote:

start_line = fields * (i ^ (par->field_order == AV_FIELD_BB ||
par->field_order == AV_FIELD_BT));

Which are imo less ugly.


Can't agree.

It's needlessly less readable bit fiddling.


+1

It may save some lines by in my opinion the current code is more 
readable and maintainable in case there are changes to AVFieldOrder (see 
discussion at 
https://ffmpeg.org/pipermail/ffmpeg-devel/2017-September/215698.html).


Regards,
Tobias

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


[FFmpeg-devel] [PATCH 09/17] vaapi: Make the decode profile matching more explicit

2017-11-23 Thread Mark Thompson
Also fixes a bug where it could attempt to decode with an unsupported
codec if allow-profile-mismatch was set.
---
 libavcodec/vaapi_decode.c | 20 +---
 1 file changed, 9 insertions(+), 11 deletions(-)

diff --git a/libavcodec/vaapi_decode.c b/libavcodec/vaapi_decode.c
index d467bed874..d36ef906a2 100644
--- a/libavcodec/vaapi_decode.c
+++ b/libavcodec/vaapi_decode.c
@@ -287,8 +287,8 @@ static int vaapi_decode_make_config(AVCodecContext *avctx,
 VAStatus vas;
 int err, i, j;
 const AVCodecDescriptor *codec_desc;
-VAProfile profile, va_profile, *profile_list = NULL;
-int profile_count, exact_match, alt_profile;
+VAProfile *profile_list = NULL, matched_va_profile;
+int profile_count, exact_match, matched_ff_profile;
 const AVPixFmtDescriptor *sw_desc, *desc;
 
 AVHWDeviceContext*device = (AVHWDeviceContext*)device_ref->data;
@@ -317,7 +317,7 @@ static int vaapi_decode_make_config(AVCodecContext *avctx,
 goto fail;
 }
 
-profile = VAProfileNone;
+matched_va_profile = VAProfileNone;
 exact_match = 0;
 
 for (i = 0; i < FF_ARRAY_ELEMS(vaapi_profile_map); i++) {
@@ -326,23 +326,22 @@ static int vaapi_decode_make_config(AVCodecContext *avctx,
 continue;
 if (avctx->profile == vaapi_profile_map[i].codec_profile)
 profile_match = 1;
-profile = vaapi_profile_map[i].va_profile;
 for (j = 0; j < profile_count; j++) {
-if (profile == profile_list[j]) {
+if (vaapi_profile_map[i].va_profile == profile_list[j]) {
 exact_match = profile_match;
 break;
 }
 }
 if (j < profile_count) {
+matched_va_profile = vaapi_profile_map[i].va_profile;
+matched_ff_profile = vaapi_profile_map[i].codec_profile;
 if (exact_match)
 break;
-alt_profile = vaapi_profile_map[i].codec_profile;
-va_profile = vaapi_profile_map[i].va_profile;
 }
 }
 av_freep(_list);
 
-if (profile == VAProfileNone) {
+if (matched_va_profile == VAProfileNone) {
 av_log(avctx, AV_LOG_ERROR, "No support for codec %s "
"profile %d.\n", codec_desc->name, avctx->profile);
 err = AVERROR(ENOSYS);
@@ -356,8 +355,7 @@ static int vaapi_decode_make_config(AVCodecContext *avctx,
codec_desc->name, avctx->profile);
 av_log(avctx, AV_LOG_WARNING, "Using possibly-"
"incompatible profile %d instead.\n",
-   alt_profile);
-profile = va_profile;
+   matched_ff_profile);
 } else {
 av_log(avctx, AV_LOG_VERBOSE, "Codec %s profile %d not "
"supported for hardware decode.\n",
@@ -367,7 +365,7 @@ static int vaapi_decode_make_config(AVCodecContext *avctx,
 }
 }
 
-vas = vaCreateConfig(hwctx->display, profile,
+vas = vaCreateConfig(hwctx->display, matched_va_profile,
  VAEntrypointVLD, NULL, 0,
  va_config);
 if (vas != VA_STATUS_SUCCESS) {
-- 
2.11.0

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


[FFmpeg-devel] [PATCH 14/17] mjpegdec: Add hwaccel hooks

2017-11-23 Thread Mark Thompson
---
This works nicely on the Intel driver for YUV 4:2:2 (like you usually get from 
UVC webcams) with ffmpeg via hw_device_ctx, but YUV 4:2:0 requires trickier 
surface setup because it doesn't work on normal NV12 surfaces.  It can be used 
via hw_frames_ctx by making the right surfaces externally, but doesn't work by 
hw_device_ctx without additional hackery.

I will look into this further - it should be possible to propagate the layout 
requirements so that hw_device_ctx works for 4:2:0 as well.


 configure |   2 +
 libavcodec/Makefile   |   1 +
 libavcodec/hwaccels.h |   1 +
 libavcodec/mjpegdec.c |   6 ++
 libavcodec/vaapi_decode.c |   2 +
 libavcodec/vaapi_mjpeg.c  | 160 ++
 6 files changed, 172 insertions(+)
 create mode 100644 libavcodec/vaapi_mjpeg.c

diff --git a/configure b/configure
index b95a91cbf0..0a103b3f67 100755
--- a/configure
+++ b/configure
@@ -2699,6 +2699,8 @@ hevc_vdpau_hwaccel_deps="vdpau VdpPictureInfoHEVC"
 hevc_vdpau_hwaccel_select="hevc_decoder"
 hevc_videotoolbox_hwaccel_deps="videotoolbox"
 hevc_videotoolbox_hwaccel_select="hevc_decoder"
+mjpeg_vaapi_hwaccel_deps="vaapi"
+mjpeg_vaapi_hwaccel_select="mjpeg_decoder"
 mpeg_xvmc_hwaccel_deps="xvmc"
 mpeg_xvmc_hwaccel_select="mpeg2video_decoder"
 mpeg1_nvdec_hwaccel_deps="nvdec"
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 0ebd2820eb..640edfb590 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -849,6 +849,7 @@ OBJS-$(CONFIG_HEVC_NVDEC_HWACCEL) += nvdec_hevc.o
 OBJS-$(CONFIG_HEVC_QSV_HWACCEL)   += qsvdec_h2645.o
 OBJS-$(CONFIG_HEVC_VAAPI_HWACCEL) += vaapi_hevc.o
 OBJS-$(CONFIG_HEVC_VDPAU_HWACCEL) += vdpau_hevc.o
+OBJS-$(CONFIG_MJPEG_VAAPI_HWACCEL)+= vaapi_mjpeg.o
 OBJS-$(CONFIG_MPEG1_NVDEC_HWACCEL)+= nvdec_mpeg12.o
 OBJS-$(CONFIG_MPEG1_VDPAU_HWACCEL)+= vdpau_mpeg12.o
 OBJS-$(CONFIG_MPEG1_VIDEOTOOLBOX_HWACCEL) += videotoolbox.o
diff --git a/libavcodec/hwaccels.h b/libavcodec/hwaccels.h
index afe7289341..cefd2b15be 100644
--- a/libavcodec/hwaccels.h
+++ b/libavcodec/hwaccels.h
@@ -37,6 +37,7 @@ extern const AVHWAccel ff_hevc_nvdec_hwaccel;
 extern const AVHWAccel ff_hevc_vaapi_hwaccel;
 extern const AVHWAccel ff_hevc_vdpau_hwaccel;
 extern const AVHWAccel ff_hevc_videotoolbox_hwaccel;
+extern const AVHWAccel ff_mjpeg_vaapi_hwaccel;
 extern const AVHWAccel ff_mpeg1_nvdec_hwaccel;
 extern const AVHWAccel ff_mpeg1_vdpau_hwaccel;
 extern const AVHWAccel ff_mpeg1_videotoolbox_hwaccel;
diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index 846dec2f42..2b79cd21bb 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -652,6 +652,9 @@ unk_pixfmt:
 s->avctx->pix_fmt = s->hwaccel_pix_fmt;
 } else {
 enum AVPixelFormat pix_fmts[] = {
+#if CONFIG_MJPEG_VAAPI_HWACCEL
+AV_PIX_FMT_VAAPI,
+#endif
 s->avctx->pix_fmt,
 AV_PIX_FMT_NONE,
 };
@@ -2777,6 +2780,9 @@ AVCodec ff_mjpeg_decoder = {
 .caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE |
   FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
 .hw_configs = (const AVCodecHWConfigInternal*[]) {
+#if CONFIG_MJPEG_VAAPI_HWACCEL
+HWACCEL_VAAPI(mjpeg),
+#endif
 NULL
 },
 };
diff --git a/libavcodec/vaapi_decode.c b/libavcodec/vaapi_decode.c
index 572b3a40ac..b30d397113 100644
--- a/libavcodec/vaapi_decode.c
+++ b/libavcodec/vaapi_decode.c
@@ -253,6 +253,8 @@ static const struct {
 MAP(HEVC,HEVC_MAIN,   HEVCMain),
 MAP(HEVC,HEVC_MAIN_10,HEVCMain10  ),
 #endif
+MAP(MJPEG,   MJPEG_HUFFMAN_BASELINE_DCT,
+  JPEGBaseline),
 MAP(WMV3,VC1_SIMPLE,  VC1Simple   ),
 MAP(WMV3,VC1_MAIN,VC1Main ),
 MAP(WMV3,VC1_COMPLEX, VC1Advanced ),
diff --git a/libavcodec/vaapi_mjpeg.c b/libavcodec/vaapi_mjpeg.c
new file mode 100644
index 00..0277cb04f0
--- /dev/null
+++ b/libavcodec/vaapi_mjpeg.c
@@ -0,0 +1,160 @@
+/*
+ * 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 "hwaccel.h"
+#include "vaapi_decode.h"
+#include 

[FFmpeg-devel] [PATCH 14/17] mjpegdec: Add hwaccel hooks

2017-11-23 Thread Mark Thompson
Also adds some extra fields to the main context structure that may
be needed by a hwaccel decoder.
---
The YUVJ formats really mess with this.  This patch hacks them out so that the 
hwaccel works, suggestions welcome on what to actually do about them.


 libavcodec/mjpegdec.c | 70 +--
 libavcodec/mjpegdec.h | 11 
 2 files changed, 79 insertions(+), 2 deletions(-)

diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index f01d44a169..846dec2f42 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -36,6 +36,7 @@
 #include "avcodec.h"
 #include "blockdsp.h"
 #include "copy_block.h"
+#include "hwaccel.h"
 #include "idctdsp.h"
 #include "internal.h"
 #include "jpegtables.h"
@@ -147,6 +148,7 @@ av_cold int ff_mjpeg_decode_init(AVCodecContext *avctx)
 s->org_height= avctx->coded_height;
 avctx->chroma_sample_location = AVCHROMA_LOC_CENTER;
 avctx->colorspace = AVCOL_SPC_BT470BG;
+s->hwaccel_pix_fmt = s->hwaccel_sw_pix_fmt = AV_PIX_FMT_NONE;
 
 if ((ret = build_basic_mjpeg_vlc(s)) < 0)
 return ret;
@@ -279,6 +281,11 @@ int ff_mjpeg_decode_dht(MJpegDecodeContext *s)
  code_max + 1, 0, 0)) < 0)
 return ret;
 }
+
+for (i = 0; i < 16; i++)
+s->raw_huffman_lengths[class][index][i] = bits_table[i + 1];
+for (i = 0; i < 256; i++)
+s->raw_huffman_values[class][index][i] = val_table[i];
 }
 return 0;
 }
@@ -636,6 +643,26 @@ unk_pixfmt:
 return AVERROR_BUG;
 }
 
+if (s->avctx->pix_fmt == AV_PIX_FMT_YUVJ420P)
+s->avctx->pix_fmt = AV_PIX_FMT_YUV420P;
+if (s->avctx->pix_fmt == AV_PIX_FMT_YUVJ422P)
+s->avctx->pix_fmt = AV_PIX_FMT_YUV422P;
+
+if (s->avctx->pix_fmt == s->hwaccel_sw_pix_fmt) {
+s->avctx->pix_fmt = s->hwaccel_pix_fmt;
+} else {
+enum AVPixelFormat pix_fmts[] = {
+s->avctx->pix_fmt,
+AV_PIX_FMT_NONE,
+};
+s->hwaccel_pix_fmt = ff_get_format(s->avctx, pix_fmts);
+if (s->hwaccel_pix_fmt < 0)
+return AVERROR(EINVAL);
+
+s->hwaccel_sw_pix_fmt = s->avctx->pix_fmt;
+s->avctx->pix_fmt = s->hwaccel_pix_fmt;
+}
+
 if (s->avctx->skip_frame == AVDISCARD_ALL) {
 s->picture_ptr->pict_type = AV_PICTURE_TYPE_I;
 s->picture_ptr->key_frame = 1;
@@ -683,6 +710,19 @@ unk_pixfmt:
 }
 memset(s->coefs_finished, 0, sizeof(s->coefs_finished));
 }
+
+if (s->avctx->hwaccel) {
+s->hwaccel_picture_private =
+av_mallocz(s->avctx->hwaccel->frame_priv_data_size);
+if (!s->hwaccel_picture_private)
+return AVERROR(ENOMEM);
+
+ret = s->avctx->hwaccel->start_frame(s->avctx, s->raw_buffer,
+ s->raw_buffer_size);
+if (ret < 0)
+return ret;
+}
+
 return 0;
 }
 
@@ -1510,7 +1550,7 @@ int ff_mjpeg_decode_sos(MJpegDecodeContext *s, const 
uint8_t *mb_bitmask,
 }
 }
 
-av_assert0(s->picture_ptr->data[0]);
+//av_assert0(s->picture_ptr->data[0]);
 /* XXX: verify len field validity */
 len = get_bits(>gb, 16);
 nb_components = get_bits(>gb, 8);
@@ -1600,7 +1640,18 @@ next_field:
 for (i = 0; i < nb_components; i++)
 s->last_dc[i] = (4 << s->bits);
 
-if (s->lossless) {
+if (s->avctx->hwaccel) {
+int bytes_to_start = get_bits_count(>gb) / 8;
+av_assert0(bytes_to_start >= 0 &&
+   s->raw_buffer_size >= bytes_to_start);
+
+ret = s->avctx->hwaccel->decode_slice(s->avctx,
+  s->raw_buffer  + 
bytes_to_start,
+  s->raw_buffer_size - 
bytes_to_start);
+if (ret < 0)
+return ret;
+
+} else if (s->lossless) {
 av_assert0(s->picture_ptr == s->picture);
 if (CONFIG_JPEGLS_DECODER && s->ls) {
 //for () {
@@ -2226,6 +2277,9 @@ int ff_mjpeg_decode_frame(AVCodecContext *avctx, void 
*data, int *got_frame,
 goto fail;
 }
 
+s->raw_buffer  = buf_ptr;
+s->raw_buffer_size = buf_end - buf_ptr;
+
 s->start_code = start_code;
 if (s->avctx->debug & FF_DEBUG_STARTCODE)
 av_log(avctx, AV_LOG_DEBUG, "startcode: %X\n", start_code);
@@ -2349,6 +2403,13 @@ eoi_parser:
 s->got_picture = 0;
 goto the_end_no_picture;
 }
+if (s->avctx->hwaccel) {
+ret = s->avctx->hwaccel->end_frame(s->avctx);
+if (ret < 0)
+return ret;
+
+av_freep(>hwaccel_picture_private);
+}
 if ((ret = av_frame_ref(frame, s->picture_ptr)) < 0)
 return ret;
 *got_frame = 1;
@@ -2673,6 +2734,8 @@ av_cold int ff_mjpeg_decode_end(AVCodecContext 

[FFmpeg-devel] [PATCH 10/17] vp8: Add hwaccel hooks

2017-11-23 Thread Mark Thompson
Also adds some extra fields to the main context structure that may
be needed by a hwaccel decoder.

The current behaviour of the WebP decoder is maintained by adding an
additional field to the VP8 decoder private context to indicate that
it is actually being used as WebP (no hwaccel is supported for that
case).
---
 libavcodec/vp8.c  | 206 --
 libavcodec/vp8.h  |  33 +
 libavcodec/webp.c |   1 +
 3 files changed, 172 insertions(+), 68 deletions(-)

diff --git a/libavcodec/vp8.c b/libavcodec/vp8.c
index 7841a9d964..31cd6a0d81 100644
--- a/libavcodec/vp8.c
+++ b/libavcodec/vp8.c
@@ -27,6 +27,7 @@
 #include "libavutil/imgutils.h"
 
 #include "avcodec.h"
+#include "hwaccel.h"
 #include "internal.h"
 #include "mathops.h"
 #include "rectangle.h"
@@ -72,16 +73,30 @@ static int vp8_alloc_frame(VP8Context *s, VP8Frame *f, int 
ref)
 if ((ret = ff_thread_get_buffer(s->avctx, >tf,
 ref ? AV_GET_BUFFER_FLAG_REF : 0)) < 0)
 return ret;
-if (!(f->seg_map = av_buffer_allocz(s->mb_width * s->mb_height))) {
-ff_thread_release_buffer(s->avctx, >tf);
-return AVERROR(ENOMEM);
+if (!(f->seg_map = av_buffer_allocz(s->mb_width * s->mb_height)))
+goto fail;
+if (s->avctx->hwaccel) {
+const AVHWAccel *hwaccel = s->avctx->hwaccel;
+if (hwaccel->frame_priv_data_size) {
+f->hwaccel_priv_buf = 
av_buffer_allocz(hwaccel->frame_priv_data_size);
+if (!f->hwaccel_priv_buf)
+goto fail;
+f->hwaccel_picture_private = f->hwaccel_priv_buf->data;
+}
 }
 return 0;
+
+fail:
+av_buffer_unref(>seg_map);
+ff_thread_release_buffer(s->avctx, >tf);
+return AVERROR(ENOMEM);
 }
 
 static void vp8_release_frame(VP8Context *s, VP8Frame *f)
 {
 av_buffer_unref(>seg_map);
+av_buffer_unref(>hwaccel_priv_buf);
+f->hwaccel_picture_private = NULL;
 ff_thread_release_buffer(s->avctx, >tf);
 }
 
@@ -99,6 +114,12 @@ static int vp8_ref_frame(VP8Context *s, VP8Frame *dst, 
VP8Frame *src)
 vp8_release_frame(s, dst);
 return AVERROR(ENOMEM);
 }
+if (src->hwaccel_picture_private) {
+dst->hwaccel_priv_buf = av_buffer_ref(src->hwaccel_priv_buf);
+if (!dst->hwaccel_priv_buf)
+return AVERROR(ENOMEM);
+dst->hwaccel_picture_private = dst->hwaccel_priv_buf->data;
+}
 
 return 0;
 }
@@ -140,7 +161,7 @@ static VP8Frame *vp8_find_free_buffer(VP8Context *s)
 av_log(s->avctx, AV_LOG_FATAL, "Ran out of free frames!\n");
 abort();
 }
-if (frame->tf.f->data[0])
+if (frame->tf.f->buf[0])
 vp8_release_frame(s, frame);
 
 return frame;
@@ -218,8 +239,9 @@ static void parse_segment_info(VP8Context *s)
 int i;
 
 s->segmentation.update_map = vp8_rac_get(c);
+s->segmentation.update_feature_data = vp8_rac_get(c);
 
-if (vp8_rac_get(c)) { // update segment feature data
+if (s->segmentation.update_feature_data) {
 s->segmentation.absolute_vals = vp8_rac_get(c);
 
 for (i = 0; i < 4; i++)
@@ -274,6 +296,7 @@ static int setup_partitions(VP8Context *s, const uint8_t 
*buf, int buf_size)
 int size = AV_RL24(sizes + 3 * i);
 if (buf_size - size < 0)
 return -1;
+s->coeff_partition_size[i] = size;
 
 ret = ff_vp56_init_range_decoder(>coeff_partition[i], buf, size);
 if (ret < 0)
@@ -281,7 +304,11 @@ static int setup_partitions(VP8Context *s, const uint8_t 
*buf, int buf_size)
 buf  += size;
 buf_size -= size;
 }
-return ff_vp56_init_range_decoder(>coeff_partition[i], buf, buf_size);
+
+s->coeff_partition_size[i] = buf_size;
+ff_vp56_init_range_decoder(>coeff_partition[i], buf, buf_size);
+
+return 0;
 }
 
 static void vp7_get_quants(VP8Context *s)
@@ -308,28 +335,28 @@ static void vp8_get_quants(VP8Context *s)
 VP56RangeCoder *c = >c;
 int i, base_qi;
 
-int yac_qi = vp8_rac_get_uint(c, 7);
-int ydc_delta  = vp8_rac_get_sint(c, 4);
-int y2dc_delta = vp8_rac_get_sint(c, 4);
-int y2ac_delta = vp8_rac_get_sint(c, 4);
-int uvdc_delta = vp8_rac_get_sint(c, 4);
-int uvac_delta = vp8_rac_get_sint(c, 4);
+s->quant.yac_qi = vp8_rac_get_uint(c, 7);
+s->quant.ydc_delta  = vp8_rac_get_sint(c, 4);
+s->quant.y2dc_delta = vp8_rac_get_sint(c, 4);
+s->quant.y2ac_delta = vp8_rac_get_sint(c, 4);
+s->quant.uvdc_delta = vp8_rac_get_sint(c, 4);
+s->quant.uvac_delta = vp8_rac_get_sint(c, 4);
 
 for (i = 0; i < 4; i++) {
 if (s->segmentation.enabled) {
 base_qi = s->segmentation.base_quant[i];
 if (!s->segmentation.absolute_vals)
-base_qi += yac_qi;
+base_qi += s->quant.yac_qi;
 } else
-base_qi = yac_qi;
+base_qi = s->quant.yac_qi;
 
-s->qmat[i].luma_qmul[0]= 

[FFmpeg-devel] [PATCH 17/17] hwcontext_vaapi: Do not assume that sw_format is transferable

2017-11-23 Thread Mark Thompson
Drivers can support a format for surfaces without also supporting it for
images, so we can't assume that sw_format is usable for transfer.  This
would previously hit an assert in cases where it isn't.
---
 libavutil/hwcontext_vaapi.c | 21 ++---
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c
index 2f47162a0d..7ec18db56b 100644
--- a/libavutil/hwcontext_vaapi.c
+++ b/libavutil/hwcontext_vaapi.c
@@ -627,24 +627,31 @@ static int vaapi_transfer_get_formats(AVHWFramesContext 
*hwfc,
   enum AVPixelFormat **formats)
 {
 VAAPIDeviceContext *ctx = hwfc->device_ctx->internal->priv;
-enum AVPixelFormat *pix_fmts, preferred_format;
-int i, k;
+enum AVPixelFormat *pix_fmts;
+int i, k, sw_format_available;
 
-preferred_format = hwfc->sw_format;
+sw_format_available = 0;
+for (i = 0; i < ctx->nb_formats; i++) {
+if (ctx->formats[i].pix_fmt == hwfc->sw_format)
+sw_format_available = 1;
+}
 
 pix_fmts = av_malloc((ctx->nb_formats + 1) * sizeof(*pix_fmts));
 if (!pix_fmts)
 return AVERROR(ENOMEM);
 
-pix_fmts[0] = preferred_format;
-k = 1;
+if (sw_format_available) {
+pix_fmts[0] = hwfc->sw_format;
+k = 1;
+} else {
+k = 0;
+}
 for (i = 0; i < ctx->nb_formats; i++) {
-if (ctx->formats[i].pix_fmt == preferred_format)
+if (ctx->formats[i].pix_fmt == hwfc->sw_format)
 continue;
 av_assert0(k < ctx->nb_formats);
 pix_fmts[k++] = ctx->formats[i].pix_fmt;
 }
-av_assert0(k == ctx->nb_formats);
 pix_fmts[k] = AV_PIX_FMT_NONE;
 
 *formats = pix_fmts;
-- 
2.11.0

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


[FFmpeg-devel] [PATCH 03/17] lavc: Use hardware config information in ff_get_format()

2017-11-23 Thread Mark Thompson
This removes the dependency that hardware pixel formats previously had on
AVHWAccel instances, meaning only those which actually do something need
exist after this patch.

Also updates avcodec_default_get_format() to be able to choose hardware
formats if either a matching device has been supplied or no additional
external configuration is required, and avcodec_get_hw_frames_parameters()
to use the hardware config rather than searching the old hwaccel list.

The FF_CODEC_CAP_HWACCEL_REQUIRE_CLASS mechanism is deleted because it
no longer does anything (the codec already contains the pointers to the
matching hwaccels).
---
 libavcodec/avcodec.h  |   7 --
 libavcodec/cuviddec.c |   2 -
 libavcodec/decode.c   | 289 +++---
 libavcodec/internal.h |  11 +-
 4 files changed, 212 insertions(+), 97 deletions(-)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index e2dc97d62f..a78c69a708 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -3652,13 +3652,6 @@ typedef struct AVHWAccel {
  * that avctx->hwaccel_priv_data is invalid.
  */
 int (*frame_params)(AVCodecContext *avctx, AVBufferRef *hw_frames_ctx);
-
-/**
- * Some hwaccels are ambiguous if only the id and pix_fmt fields are used.
- * If non-NULL, the associated AVCodec must have
- * FF_CODEC_CAP_HWACCEL_REQUIRE_CLASS set.
- */
-const AVClass *decoder_class;
 } AVHWAccel;
 
 /**
diff --git a/libavcodec/cuviddec.c b/libavcodec/cuviddec.c
index 3bd2409ea2..33e9140f89 100644
--- a/libavcodec/cuviddec.c
+++ b/libavcodec/cuviddec.c
@@ -1120,7 +1120,6 @@ static const AVCodecHWConfigInternal *cuvid_hw_configs[] 
= {
 .type   = AVMEDIA_TYPE_VIDEO, \
 .id = AV_CODEC_ID_##X, \
 .pix_fmt= AV_PIX_FMT_CUDA, \
-.decoder_class  = ##_cuvid_class, \
 }; \
 AVCodec ff_##x##_cuvid_decoder = { \
 .name   = #x "_cuvid", \
@@ -1135,7 +1134,6 @@ static const AVCodecHWConfigInternal *cuvid_hw_configs[] 
= {
 .receive_frame  = cuvid_output_frame, \
 .flush  = cuvid_flush, \
 .capabilities   = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AVOID_PROBING, \
-.caps_internal  = FF_CODEC_CAP_HWACCEL_REQUIRE_CLASS, \
 .pix_fmts   = (const enum AVPixelFormat[]){ AV_PIX_FMT_CUDA, \
 AV_PIX_FMT_NV12, \
 AV_PIX_FMT_P010, \
diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index a7f1e23fc2..dd6fce86eb 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -40,6 +40,7 @@
 #include "avcodec.h"
 #include "bytestream.h"
 #include "decode.h"
+#include "hwaccel.h"
 #include "internal.h"
 #include "thread.h"
 
@@ -1077,33 +1078,67 @@ int avcodec_decode_subtitle2(AVCodecContext *avctx, 
AVSubtitle *sub,
 return ret;
 }
 
-static int is_hwaccel_pix_fmt(enum AVPixelFormat pix_fmt)
+enum AVPixelFormat avcodec_default_get_format(struct AVCodecContext *avctx,
+  const enum AVPixelFormat *fmt)
 {
-const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
-return desc->flags & AV_PIX_FMT_FLAG_HWACCEL;
-}
-
-enum AVPixelFormat avcodec_default_get_format(struct AVCodecContext *s, const 
enum AVPixelFormat *fmt)
-{
-while (*fmt != AV_PIX_FMT_NONE && is_hwaccel_pix_fmt(*fmt))
-++fmt;
-return fmt[0];
-}
-
-static AVHWAccel *find_hwaccel(AVCodecContext *avctx,
-   enum AVPixelFormat pix_fmt)
-{
-AVHWAccel *hwaccel = NULL;
-const AVClass *av_class =
-(avctx->codec->caps_internal & FF_CODEC_CAP_HWACCEL_REQUIRE_CLASS)
-? avctx->codec->priv_class : NULL;
-
-while ((hwaccel = av_hwaccel_next(hwaccel))) {
-if (hwaccel->decoder_class == av_class && hwaccel->id == 
avctx->codec_id
-&& hwaccel->pix_fmt == pix_fmt)
-return hwaccel;
+const AVPixFmtDescriptor *desc;
+const AVCodecHWConfig *config;
+int i, n;
+
+// If a device was supplied when the codec was opened, assume that the
+// user wants to use it.
+if (avctx->hw_device_ctx && avctx->codec->hw_configs) {
+AVHWDeviceContext *device_ctx =
+(AVHWDeviceContext*)avctx->hw_device_ctx->data;
+for (i = 0;; i++) {
+config = >codec->hw_configs[i]->public;
+if (!config)
+break;
+if (!(config->methods &
+  AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX))
+continue;
+if (device_ctx->type != config->device_type)
+continue;
+for (n = 0; fmt[n] != AV_PIX_FMT_NONE; n++) {
+if (config->pix_fmt == fmt[n])
+return fmt[n];
+}
+}
+}
+// No device or other setup, so we have to choose from things which
+// don't any other external information.
+
+// If 

[FFmpeg-devel] [PATCH 02/17] lavc: Add hardware config metadata for decoders supporting hardware output

2017-11-23 Thread Mark Thompson
This includes a pointer to the associated hwaccel for decoders using
hwaccels - these will be used later to implement the hwaccel setup
without needing a global list.

Also added is a new file listing all hwaccels as external declarations -
this will be used later to generate the hwaccel list at configure time.
---
 libavcodec/cuviddec.c  | 15 ++
 libavcodec/h263dec.c   | 13 
 libavcodec/h264dec.c   | 25 
 libavcodec/hevcdec.c   | 25 
 libavcodec/hwaccel.h   | 50 +++
 libavcodec/hwaccels.h  | 74 ++
 libavcodec/mediacodecdec.c | 18 +++
 libavcodec/mmaldec.c   |  7 +
 libavcodec/mpeg12dec.c | 45 +++-
 libavcodec/mpeg4videodec.c | 16 ++
 libavcodec/qsvdec.c| 13 
 libavcodec/qsvdec.h|  3 ++
 libavcodec/qsvdec_h2645.c  |  2 ++
 libavcodec/qsvdec_other.c  |  3 ++
 libavcodec/vc1dec.c| 43 +++
 libavcodec/vp9.c   | 19 
 16 files changed, 370 insertions(+), 1 deletion(-)
 create mode 100644 libavcodec/hwaccels.h

diff --git a/libavcodec/cuviddec.c b/libavcodec/cuviddec.c
index 806dab2074..3bd2409ea2 100644
--- a/libavcodec/cuviddec.c
+++ b/libavcodec/cuviddec.c
@@ -32,6 +32,7 @@
 
 #include "avcodec.h"
 #include "decode.h"
+#include "hwaccel.h"
 #include "internal.h"
 
 typedef struct CuvidContext
@@ -1094,6 +1095,19 @@ static const AVOption options[] = {
 { NULL }
 };
 
+static const AVCodecHWConfigInternal *cuvid_hw_configs[] = {
+&(const AVCodecHWConfigInternal) {
+.public = {
+.pix_fmt = AV_PIX_FMT_CUDA,
+.methods = AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX |
+   AV_CODEC_HW_CONFIG_METHOD_INTERNAL,
+.device_type = AV_HWDEVICE_TYPE_CUDA
+},
+.hwaccel = NULL,
+},
+NULL
+};
+
 #define DEFINE_CUVID_CODEC(x, X) \
 static const AVClass x##_cuvid_class = { \
 .class_name = #x "_cuvid", \
@@ -1127,6 +1141,7 @@ static const AVOption options[] = {
 AV_PIX_FMT_P010, \
 AV_PIX_FMT_P016, \
 AV_PIX_FMT_NONE }, \
+.hw_configs = cuvid_hw_configs, \
 };
 
 #if CONFIG_HEVC_CUVID_DECODER
diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c
index b222de793b..5608b63245 100644
--- a/libavcodec/h263dec.c
+++ b/libavcodec/h263dec.c
@@ -33,6 +33,7 @@
 #include "flv.h"
 #include "h263.h"
 #include "h263_parser.h"
+#include "hwaccel.h"
 #include "internal.h"
 #include "mpeg_er.h"
 #include "mpeg4video.h"
@@ -759,4 +760,16 @@ AVCodec ff_h263p_decoder = {
 .flush  = ff_mpeg_flush,
 .max_lowres = 3,
 .pix_fmts   = ff_h263_hwaccel_pixfmt_list_420,
+.hw_configs = (const AVCodecHWConfigInternal*[]) {
+#if CONFIG_H263_VAAPI_HWACCEL
+HWACCEL_VAAPI(h263),
+#endif
+#if CONFIG_MPEG4_VDPAU_HWACCEL
+HWACCEL_VDPAU(mpeg4),
+#endif
+#if CONFIG_H263_VIDEOTOOLBOX_HWACCEL
+HWACCEL_VIDEOTOOLBOX(h263),
+#endif
+NULL
+},
 };
diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c
index be187eb5f4..b03024d4a3 100644
--- a/libavcodec/h264dec.c
+++ b/libavcodec/h264dec.c
@@ -47,6 +47,7 @@
 #include "h264_mvpred.h"
 #include "h264_ps.h"
 #include "golomb.h"
+#include "hwaccel.h"
 #include "mathops.h"
 #include "me_cmp.h"
 #include "mpegutils.h"
@@ -1059,6 +1060,30 @@ AVCodec ff_h264_decoder = {
 .capabilities  = /*AV_CODEC_CAP_DRAW_HORIZ_BAND |*/ 
AV_CODEC_CAP_DR1 |
  AV_CODEC_CAP_DELAY | AV_CODEC_CAP_SLICE_THREADS |
  AV_CODEC_CAP_FRAME_THREADS,
+.hw_configs= (const AVCodecHWConfigInternal*[]) {
+#if CONFIG_H264_DXVA2_HWACCEL
+   HWACCEL_DXVA2(h264),
+#endif
+#if CONFIG_H264_D3D11VA_HWACCEL
+   HWACCEL_D3D11VA(h264),
+#endif
+#if CONFIG_H264_D3D11VA2_HWACCEL
+   HWACCEL_D3D11VA2(h264),
+#endif
+#if CONFIG_H264_NVDEC_HWACCEL
+   HWACCEL_NVDEC(h264),
+#endif
+#if CONFIG_H264_VAAPI_HWACCEL
+   HWACCEL_VAAPI(h264),
+#endif
+#if CONFIG_H264_VDPAU_HWACCEL
+   HWACCEL_VDPAU(h264),
+#endif
+#if CONFIG_H264_VIDEOTOOLBOX_HWACCEL
+   HWACCEL_VIDEOTOOLBOX(h264),
+#endif
+   NULL
+   },
 .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | 
FF_CODEC_CAP_EXPORTS_CROPPING,
 .flush = flush_dpb,
 .init_thread_copy  = ONLY_IF_THREADS_ENABLED(decode_init_thread_copy),
diff --git a/libavcodec/hevcdec.c 

Re: [FFmpeg-devel] [PATCH 2/3] avcodec/libx264:setting profile and level in avcodec context

2017-11-23 Thread Jeyapal, Karthick


On 11/23/17, 8:34 PM, "Carl Eugen Hoyos"  wrote:

>2017-11-23 13:56 GMT+01:00 Jeyapal, Karthick :
>>
>> On 11/23/17, 5:33 PM, "Carl Eugen Hoyos"  wrote:
>>
>>>2017-11-23 12:47 GMT+01:00 Jeyapal, Karthick :
 On 11/23/17, 4:21 PM, "Carl Eugen Hoyos"  wrote:

>2017-11-23 4:37 GMT+01:00  :

>> +s = x264_encoder_headers(x4->enc, , );
>> +if (avctx->profile == FF_PROFILE_UNKNOWN)
>> +avctx->profile = nal->p_payload[5];
>> +if (avctx->level == FF_LEVEL_UNKNOWN)
>> +avctx->level = nal->p_payload[7];
>
>Why are these conditional?
 We didn’t want to overwrite profile and level, if user had already set it.
>>>
>>>So if x264 changes these values because of contradicting user
>>>requests, we write the wrong values into the hls header?
>>
>> Yes, that is true.
>
>> We were afraid to set profile and level unconditionally, because we
>> thought it could get rejected by maintainers
>
>Very smart, you have learned quickly!
Oh yeah :) Quite a learning experience working with you folks!
>(I wish that wouldn't be the message we send to new contributors...)
>
>> (due to that comment in avcodec.h).
>
>I sent a patch.
Thanks.
>
>> Now, if you suggest us to remove those conditions, we would be
>> happy to do it.
>
>I believe other encoders already overwrite it and I believe in this
>case it would be a particularly bad idea not to overwrite it.
Sure. Will do it.

Regards,
Karthick


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


Re: [FFmpeg-devel] [PATCH 2/2] avformat/hlsenc: Refactor an inconsistent variable name

2017-11-23 Thread Jeyapal, Karthick
Thanks for pushing this patchset.

Regards,
Karthick

On 11/22/17, 1:43 PM, "刘歧"  wrote:


> 在 2017年11月22日,16:08,Karthick J  写道:
> 
> ---
> libavformat/hlsenc.c | 18 +-
> 1 file changed, 9 insertions(+), 9 deletions(-)
> 
> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> index 525605b..611cc99 100644
> --- a/libavformat/hlsenc.c
> +++ b/libavformat/hlsenc.c
> @@ -1074,7 +1074,7 @@ static int create_master_playlist(AVFormatContext *s,
> AVDictionary *options = NULL;
> unsigned int i, j;
> int m3u8_name_size, ret, bandwidth;
> -char *m3U8_rel_name;
> +char *m3u8_rel_name;
> 
> input_vs->m3u8_created = 1;
> if (!hls->master_m3u8_created) {
> @@ -1108,14 +1108,14 @@ static int create_master_playlist(AVFormatContext *s,
> vs = &(hls->var_streams[i]);
> 
> m3u8_name_size = strlen(vs->m3u8_name) + 1;
> -m3U8_rel_name = av_malloc(m3u8_name_size);
> -if (!m3U8_rel_name) {
> +m3u8_rel_name = av_malloc(m3u8_name_size);
> +if (!m3u8_rel_name) {
> ret = AVERROR(ENOMEM);
> goto fail;
> }
> -av_strlcpy(m3U8_rel_name, vs->m3u8_name, m3u8_name_size);
> +av_strlcpy(m3u8_rel_name, vs->m3u8_name, m3u8_name_size);
> ret = get_relative_url(hls->master_m3u8_url, vs->m3u8_name,
> -   m3U8_rel_name, m3u8_name_size);
> +   m3u8_rel_name, m3u8_name_size);
> if (ret < 0) {
> av_log(NULL, AV_LOG_ERROR, "Unable to find relative URL\n");
> goto fail;
> @@ -1145,7 +1145,7 @@ static int create_master_playlist(AVFormatContext *s,
> if (!bandwidth) {
> av_log(NULL, AV_LOG_WARNING,
> "Bandwidth info not available, set audio and video 
> bitrates\n");
> -av_freep(_rel_name);
> +av_freep(_rel_name);
> continue;
> }
> 
> @@ -1153,14 +1153,14 @@ static int create_master_playlist(AVFormatContext *s,
> if (vid_st && vid_st->codecpar->width > 0 && vid_st->codecpar->height 
> > 0)
> avio_printf(master_pb, ",RESOLUTION=%dx%d", 
> vid_st->codecpar->width,
> vid_st->codecpar->height);
> -avio_printf(master_pb, "\n%s\n\n", m3U8_rel_name);
> +avio_printf(master_pb, "\n%s\n\n", m3u8_rel_name);
> 
> -av_freep(_rel_name);
> +av_freep(_rel_name);
> }
> fail:
> if(ret >=0)
> hls->master_m3u8_created = 1;
> -av_freep(_rel_name);
> +av_freep(_rel_name);
> ff_format_io_close(s, _pb);
> return ret;
> }
> -- 
> 1.9.1
> 
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

patchset LGTM



Thanks





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


[FFmpeg-devel] [PATCH 08/17] ffmpeg: Use codec hardware config to configure hwaccels

2017-11-23 Thread Mark Thompson
Removes specific support for all hwaccels supported by the generic code
(DXVA2, D3D11VA, NVDEC, VAAPI, VDPAU and videotoolbox).
---
 fftools/ffmpeg.c |  77 +++-
 fftools/ffmpeg.h |  10 +--
 fftools/ffmpeg_hw.c  | 244 +++
 fftools/ffmpeg_opt.c |  55 ++--
 4 files changed, 250 insertions(+), 136 deletions(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 0c16e75ab0..6aff3366c5 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -2792,45 +2792,77 @@ fail:
 av_freep();
 }
 
-static const HWAccel *get_hwaccel(enum AVPixelFormat pix_fmt, enum HWAccelID 
selected_hwaccel_id)
-{
-int i;
-for (i = 0; hwaccels[i].name; i++)
-if (hwaccels[i].pix_fmt == pix_fmt &&
-(!selected_hwaccel_id || selected_hwaccel_id == HWACCEL_AUTO || 
hwaccels[i].id == selected_hwaccel_id))
-return [i];
-return NULL;
-}
-
 static enum AVPixelFormat get_format(AVCodecContext *s, const enum 
AVPixelFormat *pix_fmts)
 {
 InputStream *ist = s->opaque;
 const enum AVPixelFormat *p;
 int ret;
 
-for (p = pix_fmts; *p != -1; p++) {
+for (p = pix_fmts; *p != AV_PIX_FMT_NONE; p++) {
 const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(*p);
-const HWAccel *hwaccel;
+const AVCodecHWConfig  *config = NULL;
+int i;
 
 if (!(desc->flags & AV_PIX_FMT_FLAG_HWACCEL))
 break;
 
-hwaccel = get_hwaccel(*p, ist->hwaccel_id);
-if (!hwaccel ||
-(ist->active_hwaccel_id && ist->active_hwaccel_id != hwaccel->id) 
||
-(ist->hwaccel_id != HWACCEL_AUTO && ist->hwaccel_id != 
hwaccel->id))
-continue;
+if (ist->hwaccel_id == HWACCEL_GENERIC ||
+ist->hwaccel_id == HWACCEL_AUTO) {
+for (i = 0;; i++) {
+config = avcodec_get_hw_config(s->codec, i);
+if (!config)
+break;
+if (!(config->methods &
+  AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX))
+continue;
+if (config->pix_fmt == *p)
+break;
+}
+}
+if (config) {
+if (config->device_type != ist->hwaccel_device_type) {
+// Different hwaccel offered, ignore.
+continue;
+}
 
-ret = hwaccel->init(s);
-if (ret < 0) {
-if (ist->hwaccel_id == hwaccel->id) {
+ret = hwaccel_decode_init(s);
+if (ret < 0) {
+if (ist->hwaccel_id == HWACCEL_GENERIC) {
+av_log(NULL, AV_LOG_FATAL,
+   "%s hwaccel requested for input stream #%d:%d, "
+   "but cannot be initialized.\n",
+   av_hwdevice_get_type_name(config->device_type),
+   ist->file_index, ist->st->index);
+return AV_PIX_FMT_NONE;
+}
+continue;
+}
+} else {
+const HWAccel *hwaccel = NULL;
+int i;
+for (i = 0; hwaccels[i].name; i++) {
+if (hwaccels[i].pix_fmt == *p) {
+hwaccel = [i];
+break;
+}
+}
+if (!hwaccel) {
+// No hwaccel supporting this pixfmt.
+continue;
+}
+if (hwaccel->id != ist->hwaccel_id) {
+// Does not match requested hwaccel.
+continue;
+}
+
+ret = hwaccel->init(s);
+if (ret < 0) {
 av_log(NULL, AV_LOG_FATAL,
"%s hwaccel requested for input stream #%d:%d, "
"but cannot be initialized.\n", hwaccel->name,
ist->file_index, ist->st->index);
 return AV_PIX_FMT_NONE;
 }
-continue;
 }
 
 if (ist->hw_frames_ctx) {
@@ -2839,8 +2871,7 @@ static enum AVPixelFormat get_format(AVCodecContext *s, 
const enum AVPixelFormat
 return AV_PIX_FMT_NONE;
 }
 
-ist->active_hwaccel_id = hwaccel->id;
-ist->hwaccel_pix_fmt   = *p;
+ist->hwaccel_pix_fmt = *p;
 break;
 }
 
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index e0977e1bf1..8bb5bae862 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -61,14 +61,9 @@
 enum HWAccelID {
 HWACCEL_NONE = 0,
 HWACCEL_AUTO,
-HWACCEL_VDPAU,
-HWACCEL_DXVA2,
-HWACCEL_VIDEOTOOLBOX,
+HWACCEL_GENERIC,
 HWACCEL_QSV,
-HWACCEL_VAAPI,
 HWACCEL_CUVID,
-HWACCEL_D3D11VA,
-HWACCEL_NVDEC,
 };
 
 typedef struct HWAccel {
@@ -76,7 +71,6 @@ typedef struct HWAccel {
 int (*init)(AVCodecContext *s);
 enum HWAccelID id;
 enum AVPixelFormat pix_fmt;
-enum AVHWDeviceType device_type;
 } HWAccel;
 
 typedef 

[FFmpeg-devel] [PATCH 11/17] vaapi: Add VP8 decode hwaccel

2017-11-23 Thread Mark Thompson
---
 configure  |   3 +
 libavcodec/Makefile|   1 +
 libavcodec/hwaccels.h  |   1 +
 libavcodec/vaapi_vp8.c | 237 +
 libavcodec/vp8.c   |   6 ++
 5 files changed, 248 insertions(+)
 create mode 100644 libavcodec/vaapi_vp8.c

diff --git a/configure b/configure
index cce523a450..b95a91cbf0 100755
--- a/configure
+++ b/configure
@@ -2746,6 +2746,8 @@ vc1_vaapi_hwaccel_deps="vaapi"
 vc1_vaapi_hwaccel_select="vc1_decoder"
 vc1_vdpau_hwaccel_deps="vdpau"
 vc1_vdpau_hwaccel_select="vc1_decoder"
+vp8_vaapi_hwaccel_deps="vaapi VAPictureParameterBufferVP8"
+vp8_vaapi_hwaccel_select="vp8_decoder"
 vp9_d3d11va_hwaccel_deps="d3d11va DXVA_PicParams_VP9"
 vp9_d3d11va_hwaccel_select="vp9_decoder"
 vp9_d3d11va2_hwaccel_deps="d3d11va DXVA_PicParams_VP9"
@@ -5718,6 +5720,7 @@ check_type "windows.h d3d11.h" "ID3D11VideoContext"
 check_type "d3d9.h dxva2api.h" DXVA2_ConfigPictureDecode -D_WIN32_WINNT=0x0602
 
 check_type "va/va.h va/va_dec_hevc.h" "VAPictureParameterBufferHEVC"
+check_type "va/va.h va/va_dec_vp8.h" "VAPictureParameterBufferVP8"
 check_struct "va/va.h" "VADecPictureParameterBufferVP9" bit_depth
 check_type "va/va.h va/va_vpp.h" "VAProcPipelineParameterBuffer"
 check_type "va/va.h va/va_enc_h264.h" "VAEncPictureParameterBufferH264"
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 2af957ab72..0ebd2820eb 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -871,6 +871,7 @@ OBJS-$(CONFIG_VC1_NVDEC_HWACCEL)  += nvdec_vc1.o
 OBJS-$(CONFIG_VC1_QSV_HWACCEL)+= qsvdec_other.o
 OBJS-$(CONFIG_VC1_VAAPI_HWACCEL)  += vaapi_vc1.o
 OBJS-$(CONFIG_VC1_VDPAU_HWACCEL)  += vdpau_vc1.o
+OBJS-$(CONFIG_VP8_VAAPI_HWACCEL)  += vaapi_vp8.o
 OBJS-$(CONFIG_VP9_D3D11VA_HWACCEL)+= dxva2_vp9.o
 OBJS-$(CONFIG_VP9_DXVA2_HWACCEL)  += dxva2_vp9.o
 OBJS-$(CONFIG_VP9_NVDEC_HWACCEL)  += nvdec_vp9.o
diff --git a/libavcodec/hwaccels.h b/libavcodec/hwaccels.h
index 8a3c29e435..afe7289341 100644
--- a/libavcodec/hwaccels.h
+++ b/libavcodec/hwaccels.h
@@ -59,6 +59,7 @@ extern const AVHWAccel ff_vc1_dxva2_hwaccel;
 extern const AVHWAccel ff_vc1_nvdec_hwaccel;
 extern const AVHWAccel ff_vc1_vaapi_hwaccel;
 extern const AVHWAccel ff_vc1_vdpau_hwaccel;
+extern const AVHWAccel ff_vp8_vaapi_hwaccel;
 extern const AVHWAccel ff_vp9_d3d11va_hwaccel;
 extern const AVHWAccel ff_vp9_d3d11va2_hwaccel;
 extern const AVHWAccel ff_vp9_dxva2_hwaccel;
diff --git a/libavcodec/vaapi_vp8.c b/libavcodec/vaapi_vp8.c
new file mode 100644
index 00..2426b30f13
--- /dev/null
+++ b/libavcodec/vaapi_vp8.c
@@ -0,0 +1,237 @@
+/*
+ * 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 "hwaccel.h"
+#include "vaapi_decode.h"
+#include "vp8.h"
+
+static VASurfaceID vaapi_vp8_surface_id(VP8Frame *vf)
+{
+if (vf)
+return ff_vaapi_get_surface_id(vf->tf.f);
+else
+return VA_INVALID_SURFACE;
+}
+
+static int vaapi_vp8_start_frame(AVCodecContext  *avctx,
+ av_unused const uint8_t *buffer,
+ av_unused uint32_t   size)
+{
+const VP8Context *s = avctx->priv_data;
+VAAPIDecodePicture *pic = 
s->framep[VP56_FRAME_CURRENT]->hwaccel_picture_private;
+VAPictureParameterBufferVP8 pp;
+VAProbabilityDataBufferVP8 prob;
+VAIQMatrixBufferVP8 quant;
+int err, i, j, k;
+
+pic->output_surface = vaapi_vp8_surface_id(s->framep[VP56_FRAME_CURRENT]);
+
+pp = (VAPictureParameterBufferVP8) {
+.frame_width = avctx->width,
+.frame_height= avctx->height,
+
+.last_ref_frame  = 
vaapi_vp8_surface_id(s->framep[VP56_FRAME_PREVIOUS]),
+.golden_ref_frame= 
vaapi_vp8_surface_id(s->framep[VP56_FRAME_GOLDEN]),
+.alt_ref_frame   = 
vaapi_vp8_surface_id(s->framep[VP56_FRAME_GOLDEN2]),
+.out_of_loop_frame   = VA_INVALID_SURFACE,
+
+.pic_fields.bits = {
+.key_frame   = !s->keyframe,
+.version = s->profile,
+
+.segmentation_enabled= s->segmentation.enabled,
+  

[FFmpeg-devel] [PATCH 06/17] lavc: Delete all fake hwaccels

2017-11-23 Thread Mark Thompson
They are now unused.
---
 configure | 32 +
 libavcodec/cuviddec.c |  6 --
 libavcodec/mediacodec.c   |  2 +-
 libavcodec/mediacodecdec_common.c | 42 ---
 libavcodec/mmaldec.c  | 28 --
 libavcodec/qsvdec_h2645.c | 18 -
 libavcodec/qsvdec_other.c | 27 -
 7 files changed, 6 insertions(+), 149 deletions(-)

diff --git a/configure b/configure
index d74bd06be5..cce523a450 100755
--- a/configure
+++ b/configure
@@ -2670,25 +2670,20 @@ h263_vaapi_hwaccel_deps="vaapi"
 h263_vaapi_hwaccel_select="h263_decoder"
 h263_videotoolbox_hwaccel_deps="videotoolbox"
 h263_videotoolbox_hwaccel_select="h263_decoder"
-h264_cuvid_hwaccel_select="h264_cuvid_decoder"
 h264_d3d11va_hwaccel_deps="d3d11va"
 h264_d3d11va_hwaccel_select="h264_decoder"
 h264_d3d11va2_hwaccel_deps="d3d11va"
 h264_d3d11va2_hwaccel_select="h264_decoder"
 h264_dxva2_hwaccel_deps="dxva2"
 h264_dxva2_hwaccel_select="h264_decoder"
-h264_mediacodec_hwaccel_deps="mediacodec"
-h264_mmal_hwaccel_deps="mmal"
 h264_nvdec_hwaccel_deps="nvdec"
 h264_nvdec_hwaccel_select="h264_decoder"
-h264_qsv_hwaccel_deps="libmfx"
 h264_vaapi_hwaccel_deps="vaapi"
 h264_vaapi_hwaccel_select="h264_decoder"
 h264_vdpau_hwaccel_deps="vdpau"
 h264_vdpau_hwaccel_select="h264_decoder"
 h264_videotoolbox_hwaccel_deps="videotoolbox"
 h264_videotoolbox_hwaccel_select="h264_decoder"
-hevc_cuvid_hwaccel_select="hevc_cuvid_decoder"
 hevc_d3d11va_hwaccel_deps="d3d11va DXVA_PicParams_HEVC"
 hevc_d3d11va_hwaccel_select="hevc_decoder"
 hevc_mediacodec_hwaccel_deps="mediacodec"
@@ -2698,17 +2693,14 @@ hevc_dxva2_hwaccel_deps="dxva2 DXVA_PicParams_HEVC"
 hevc_dxva2_hwaccel_select="hevc_decoder"
 hevc_nvdec_hwaccel_deps="nvdec"
 hevc_nvdec_hwaccel_select="hevc_decoder"
-hevc_qsv_hwaccel_deps="libmfx"
 hevc_vaapi_hwaccel_deps="vaapi VAPictureParameterBufferHEVC"
 hevc_vaapi_hwaccel_select="hevc_decoder"
 hevc_vdpau_hwaccel_deps="vdpau VdpPictureInfoHEVC"
 hevc_vdpau_hwaccel_select="hevc_decoder"
 hevc_videotoolbox_hwaccel_deps="videotoolbox"
 hevc_videotoolbox_hwaccel_select="hevc_decoder"
-mjpeg_cuvid_hwaccel_select="mjpeg_cuvid_decoder"
 mpeg_xvmc_hwaccel_deps="xvmc"
 mpeg_xvmc_hwaccel_select="mpeg2video_decoder"
-mpeg1_cuvid_hwaccel_select="mpeg1_cuvid_decoder"
 mpeg1_nvdec_hwaccel_deps="nvdec"
 mpeg1_nvdec_hwaccel_select="mpeg1video_decoder"
 mpeg1_vdpau_hwaccel_deps="vdpau"
@@ -2717,18 +2709,14 @@ mpeg1_videotoolbox_hwaccel_deps="videotoolbox"
 mpeg1_videotoolbox_hwaccel_select="mpeg1video_decoder"
 mpeg1_xvmc_hwaccel_deps="xvmc"
 mpeg1_xvmc_hwaccel_select="mpeg1video_decoder"
-mpeg2_cuvid_hwaccel_select="mpeg2_cuvid_decoder"
 mpeg2_d3d11va_hwaccel_deps="d3d11va"
 mpeg2_d3d11va_hwaccel_select="mpeg2video_decoder"
 mpeg2_d3d11va2_hwaccel_deps="d3d11va"
 mpeg2_d3d11va2_hwaccel_select="mpeg2video_decoder"
 mpeg2_dxva2_hwaccel_deps="dxva2"
 mpeg2_dxva2_hwaccel_select="mpeg2video_decoder"
-mpeg2_mediacodec_hwaccel_deps="mediacodec"
-mpeg2_mmal_hwaccel_deps="mmal"
 mpeg2_nvdec_hwaccel_deps="nvdec"
 mpeg2_nvdec_hwaccel_select="mpeg2video_decoder"
-mpeg2_qsv_hwaccel_deps="libmfx"
 mpeg2_vaapi_hwaccel_deps="vaapi"
 mpeg2_vaapi_hwaccel_select="mpeg2video_decoder"
 mpeg2_vdpau_hwaccel_deps="vdpau"
@@ -2737,9 +2725,6 @@ mpeg2_videotoolbox_hwaccel_deps="videotoolbox"
 mpeg2_videotoolbox_hwaccel_select="mpeg2video_decoder"
 mpeg2_xvmc_hwaccel_deps="xvmc"
 mpeg2_xvmc_hwaccel_select="mpeg2video_decoder"
-mpeg4_cuvid_hwaccel_select="mpeg4_cuvid_decoder"
-mpeg4_mediacodec_hwaccel_deps="mediacodec"
-mpeg4_mmal_hwaccel_deps="mmal"
 mpeg4_nvdec_hwaccel_deps="nvdec"
 mpeg4_nvdec_hwaccel_select="mpeg4_decoder"
 mpeg4_vaapi_hwaccel_deps="vaapi"
@@ -2755,25 +2740,18 @@ vc1_d3d11va2_hwaccel_deps="d3d11va"
 vc1_d3d11va2_hwaccel_select="vc1_decoder"
 vc1_dxva2_hwaccel_deps="dxva2"
 vc1_dxva2_hwaccel_select="vc1_decoder"
-vc1_mmal_hwaccel_deps="mmal"
 vc1_nvdec_hwaccel_deps="nvdec"
 vc1_nvdec_hwaccel_select="vc1_decoder"
-vc1_qsv_hwaccel_deps="libmfx"
 vc1_vaapi_hwaccel_deps="vaapi"
 vc1_vaapi_hwaccel_select="vc1_decoder"
 vc1_vdpau_hwaccel_deps="vdpau"
 vc1_vdpau_hwaccel_select="vc1_decoder"
-vp8_cuvid_hwaccel_select="vp8_cuvid_decoder"
-vp9_cuvid_hwaccel_select="vp9_cuvid_decoder"
-vp8_mediacodec_hwaccel_deps="mediacodec"
-vp8_qsv_hwaccel_deps="libmfx"
 vp9_d3d11va_hwaccel_deps="d3d11va DXVA_PicParams_VP9"
 vp9_d3d11va_hwaccel_select="vp9_decoder"
 vp9_d3d11va2_hwaccel_deps="d3d11va DXVA_PicParams_VP9"
 vp9_d3d11va2_hwaccel_select="vp9_decoder"
 vp9_dxva2_hwaccel_deps="dxva2 DXVA_PicParams_VP9"
 vp9_dxva2_hwaccel_select="vp9_decoder"
-vp9_mediacodec_hwaccel_deps="mediacodec"
 vp9_nvdec_hwaccel_deps="nvdec"
 vp9_nvdec_hwaccel_select="vp9_decoder"
 vp9_vaapi_hwaccel_deps="vaapi VADecPictureParameterBufferVP9_bit_depth"
@@ -2814,7 +2792,7 @@ h264_mediacodec_decoder_select="h264_mp4toannexb_bsf 
h264_parser"
 

[FFmpeg-devel] [PATCH 07/17] lavc: Mark all AVHWAccel structures as const

2017-11-23 Thread Mark Thompson
---
 libavcodec/avcodec.h|  2 +-
 libavcodec/decode.c |  2 +-
 libavcodec/dxva2_h264.c |  6 +--
 libavcodec/dxva2_hevc.c |  6 +--
 libavcodec/dxva2_mpeg2.c|  6 +--
 libavcodec/dxva2_vc1.c  | 12 +++---
 libavcodec/dxva2_vp9.c  |  6 +--
 libavcodec/hwaccels.h   | 98 ++---
 libavcodec/mpegvideo_xvmc.c |  4 +-
 libavcodec/nvdec_h264.c |  2 +-
 libavcodec/nvdec_hevc.c |  2 +-
 libavcodec/nvdec_mpeg12.c   |  2 +-
 libavcodec/nvdec_vc1.c  |  4 +-
 libavcodec/nvdec_vp9.c  |  2 +-
 libavcodec/vaapi_h264.c |  2 +-
 libavcodec/vaapi_hevc.c |  2 +-
 libavcodec/vaapi_mpeg2.c|  2 +-
 libavcodec/vaapi_mpeg4.c|  4 +-
 libavcodec/vaapi_vc1.c  |  4 +-
 libavcodec/vaapi_vp9.c  |  2 +-
 libavcodec/vdpau_h264.c |  2 +-
 libavcodec/vdpau_hevc.c |  2 +-
 libavcodec/vdpau_mpeg12.c   |  4 +-
 libavcodec/vdpau_mpeg4.c|  2 +-
 libavcodec/vdpau_vc1.c  |  4 +-
 libavcodec/videotoolbox.c   | 12 +++---
 26 files changed, 98 insertions(+), 98 deletions(-)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 1ae0344bb2..0972df0bde 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -2635,7 +2635,7 @@ typedef struct AVCodecContext {
  * - encoding: unused.
  * - decoding: Set by libavcodec
  */
-struct AVHWAccel *hwaccel;
+const struct AVHWAccel *hwaccel;
 
 /**
  * Hardware accelerator context.
diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index dd6fce86eb..3feaa6c426 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -1252,7 +1252,7 @@ static int hwaccel_init(AVCodecContext *avctx,
 return AVERROR(ENOMEM);
 }
 
-avctx->hwaccel = (AVHWAccel*)hwaccel;
+avctx->hwaccel = hwaccel;
 err = hwaccel->init(avctx);
 if (err < 0) {
 av_log(avctx, AV_LOG_ERROR, "Failed setup for format %s: "
diff --git a/libavcodec/dxva2_h264.c b/libavcodec/dxva2_h264.c
index ee35b20e82..a4278c80b5 100644
--- a/libavcodec/dxva2_h264.c
+++ b/libavcodec/dxva2_h264.c
@@ -518,7 +518,7 @@ static int dxva2_h264_end_frame(AVCodecContext *avctx)
 }
 
 #if CONFIG_H264_DXVA2_HWACCEL
-AVHWAccel ff_h264_dxva2_hwaccel = {
+const AVHWAccel ff_h264_dxva2_hwaccel = {
 .name   = "h264_dxva2",
 .type   = AVMEDIA_TYPE_VIDEO,
 .id = AV_CODEC_ID_H264,
@@ -535,7 +535,7 @@ AVHWAccel ff_h264_dxva2_hwaccel = {
 #endif
 
 #if CONFIG_H264_D3D11VA_HWACCEL
-AVHWAccel ff_h264_d3d11va_hwaccel = {
+const AVHWAccel ff_h264_d3d11va_hwaccel = {
 .name   = "h264_d3d11va",
 .type   = AVMEDIA_TYPE_VIDEO,
 .id = AV_CODEC_ID_H264,
@@ -552,7 +552,7 @@ AVHWAccel ff_h264_d3d11va_hwaccel = {
 #endif
 
 #if CONFIG_H264_D3D11VA2_HWACCEL
-AVHWAccel ff_h264_d3d11va2_hwaccel = {
+const AVHWAccel ff_h264_d3d11va2_hwaccel = {
 .name   = "h264_d3d11va2",
 .type   = AVMEDIA_TYPE_VIDEO,
 .id = AV_CODEC_ID_H264,
diff --git a/libavcodec/dxva2_hevc.c b/libavcodec/dxva2_hevc.c
index 542afc383a..0ae07d304f 100644
--- a/libavcodec/dxva2_hevc.c
+++ b/libavcodec/dxva2_hevc.c
@@ -422,7 +422,7 @@ static int dxva2_hevc_end_frame(AVCodecContext *avctx)
 }
 
 #if CONFIG_HEVC_DXVA2_HWACCEL
-AVHWAccel ff_hevc_dxva2_hwaccel = {
+const AVHWAccel ff_hevc_dxva2_hwaccel = {
 .name   = "hevc_dxva2",
 .type   = AVMEDIA_TYPE_VIDEO,
 .id = AV_CODEC_ID_HEVC,
@@ -439,7 +439,7 @@ AVHWAccel ff_hevc_dxva2_hwaccel = {
 #endif
 
 #if CONFIG_HEVC_D3D11VA_HWACCEL
-AVHWAccel ff_hevc_d3d11va_hwaccel = {
+const AVHWAccel ff_hevc_d3d11va_hwaccel = {
 .name   = "hevc_d3d11va",
 .type   = AVMEDIA_TYPE_VIDEO,
 .id = AV_CODEC_ID_HEVC,
@@ -456,7 +456,7 @@ AVHWAccel ff_hevc_d3d11va_hwaccel = {
 #endif
 
 #if CONFIG_HEVC_D3D11VA2_HWACCEL
-AVHWAccel ff_hevc_d3d11va2_hwaccel = {
+const AVHWAccel ff_hevc_d3d11va2_hwaccel = {
 .name   = "hevc_d3d11va2",
 .type   = AVMEDIA_TYPE_VIDEO,
 .id = AV_CODEC_ID_HEVC,
diff --git a/libavcodec/dxva2_mpeg2.c b/libavcodec/dxva2_mpeg2.c
index df5fe59a7d..a57778b427 100644
--- a/libavcodec/dxva2_mpeg2.c
+++ b/libavcodec/dxva2_mpeg2.c
@@ -317,7 +317,7 @@ static int dxva2_mpeg2_end_frame(AVCodecContext *avctx)
 }
 
 #if CONFIG_MPEG2_DXVA2_HWACCEL
-AVHWAccel ff_mpeg2_dxva2_hwaccel = {
+const AVHWAccel ff_mpeg2_dxva2_hwaccel = {
 .name   = "mpeg2_dxva2",
 .type   = AVMEDIA_TYPE_VIDEO,
 .id = AV_CODEC_ID_MPEG2VIDEO,
@@ -334,7 +334,7 @@ AVHWAccel ff_mpeg2_dxva2_hwaccel = {
 #endif
 
 #if CONFIG_MPEG2_D3D11VA_HWACCEL
-AVHWAccel ff_mpeg2_d3d11va_hwaccel = {
+const AVHWAccel ff_mpeg2_d3d11va_hwaccel = {
 .name   = "mpeg2_d3d11va",
 .type   = AVMEDIA_TYPE_VIDEO,
 .id = AV_CODEC_ID_MPEG2VIDEO,
@@ -351,7 +351,7 @@ AVHWAccel ff_mpeg2_d3d11va_hwaccel = {
 #endif
 
 #if 

[FFmpeg-devel] [PATCH] hwcontext_d3d11va: properly reset values after release/close

2017-11-23 Thread Jan Ekström
Makes the uninit function re-entrable, which can be a common case
when an API user first tries to initialize its context, fails, and
then finally unrefs the AVHWDevice.

Fixes a crash reported by sm2345 on IRC.
---
 libavutil/hwcontext_d3d11va.c | 21 -
 1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/libavutil/hwcontext_d3d11va.c b/libavutil/hwcontext_d3d11va.c
index 65dd6651fc..845a4a45fe 100644
--- a/libavutil/hwcontext_d3d11va.c
+++ b/libavutil/hwcontext_d3d11va.c
@@ -458,20 +458,31 @@ static void d3d11va_device_uninit(AVHWDeviceContext 
*hwdev)
 {
 AVD3D11VADeviceContext *device_hwctx = hwdev->hwctx;
 
-if (device_hwctx->device)
+if (device_hwctx->device) {
 ID3D11Device_Release(device_hwctx->device);
+device_hwctx->device = NULL;
+}
 
-if (device_hwctx->device_context)
+if (device_hwctx->device_context) {
 ID3D11DeviceContext_Release(device_hwctx->device_context);
+device_hwctx->device_context = NULL;
+}
 
-if (device_hwctx->video_device)
+if (device_hwctx->video_device) {
 ID3D11VideoDevice_Release(device_hwctx->video_device);
+device_hwctx->video_device = NULL;
+}
 
-if (device_hwctx->video_context)
+if (device_hwctx->video_context) {
 ID3D11VideoContext_Release(device_hwctx->video_context);
+device_hwctx->video_context = NULL;
+}
 
-if (device_hwctx->lock == d3d11va_default_lock)
+if (device_hwctx->lock == d3d11va_default_lock) {
 CloseHandle(device_hwctx->lock_ctx);
+device_hwctx->lock_ctx = INVALID_HANDLE_VALUE;
+device_hwctx->lock = NULL;
+}
 }
 
 static int d3d11va_device_create(AVHWDeviceContext *ctx, const char *device,
-- 
2.14.3

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


Re: [FFmpeg-devel] [PATCH]lavc/avcodec: Allow libavcodec to overwrite profile and level

2017-11-23 Thread Jeyapal, Karthick


On 11/24/17, 5:17 AM, "Carl Eugen Hoyos"  wrote:

>2017-11-23 22:58 GMT+01:00 Michael Niedermayer :
>> On Thu, Nov 23, 2017 at 04:01:06PM +0100, Carl Eugen Hoyos wrote:
>>> Hi!
>>>
>>> The (external) encoders may overwrite level and profile because of
>>> requested encoding properties, allowing libavcodec to (also) overwrite
>>> them in the context makes sense (and is already done in some cases
>>> afaict).
>>>
>>> Please comment, Carl Eugen
>>
>> If a user needs to generate a file with a specific profile/level
>> for example because its for broadcast, some specification or a hw
>> decoder.
>> How could he after this patch ensure that exactly the needed profile
>> is used?
There is no way of ensuring the same even without this patch.

>Afair, x264 does change profile and / or level depending on properties
>set by the user. Currently there is no way for the libavcodec user to
>know that libx264 changed something.
>With this change the user can know that he does not get the
>requested values.
>
>Or am I wrong and libx264 never overwrites requested values
>for level and / or profile?
>

I just tested x264 by giving contradicting profiles and levels. 
Following are the results:
Case 1:
Input : 1080p30, 420p
Config : Set level wrongly to 1.1
Output : Throws some warnings, but level is still written wrongly as 1.1 is the 
SPS header.
Impact of overwrite : None. Both the user set value and header’s value are same.

Case 2:1080p30, 422p
Config : Set profile wrongly to baseline
Output : Throws errors, doesn’t encode
Impact of overwrite : None. 

Case 3:1080p30, 420p
Config : Set profile wrongly to high422
Output : No warnings or errors. Automatically switches to high profile. SPS 
header also has high profile.
Impact of overwrite : User will get to know the correct profile being encoded.

Regards,
Karthick



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


Re: [FFmpeg-devel] [PATCH v3] avformat/hlsenc: Added option to add EXT-X-INDEPENDENT-SEGMENTS tag

2017-11-23 Thread Jeyapal, Karthick
On 11/24/17, 4:31 AM, "Steven Liu"  wrote:

>Pushed
Thanks.
>
>
>Thanks

regards,
Karthick


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


[FFmpeg-devel] [PATCH 2/2 v2] avformat/flacenc: add flac_init() and flac_deinit()

2017-11-23 Thread James Almer
Signed-off-by: James Almer 
---
Simpler/smaller diff.

 libavformat/flacenc.c | 50 +-
 1 file changed, 33 insertions(+), 17 deletions(-)

diff --git a/libavformat/flacenc.c b/libavformat/flacenc.c
index 84da54a1df..d5fcf96b6b 100644
--- a/libavformat/flacenc.c
+++ b/libavformat/flacenc.c
@@ -197,11 +197,11 @@ static int flac_finish_header(struct AVFormatContext *s)
 return 0;
 }
 
-static int flac_write_header(struct AVFormatContext *s)
+static int flac_init(struct AVFormatContext *s)
 {
 AVCodecParameters *par;
 FlacMuxerContext *c = s->priv_data;
-int ret, i;
+int i;
 
 c->audio_stream_idx = -1;
 for (i = 0; i < s->nb_streams; i++) {
@@ -233,14 +233,6 @@ static int flac_write_header(struct AVFormatContext *s)
 if (c->nb_pics && !(c->pics = av_calloc(c->nb_pics, sizeof(AVPacket
 return AVERROR(ENOMEM);
 
-if (!c->write_header)
-return 0;
-
-ret = ff_flac_write_header(s->pb, par->extradata,
-   par->extradata_size, 0);
-if (ret)
-return ret;
-
 /* add the channel layout tag */
 if (par->channel_layout &&
 !(par->channel_layout & ~0x3ULL) &&
@@ -258,6 +250,23 @@ static int flac_write_header(struct AVFormatContext *s)
 }
 }
 
+return 0;
+}
+
+static int flac_write_header(struct AVFormatContext *s)
+{
+FlacMuxerContext *c = s->priv_data;
+AVCodecParameters *par = s->streams[c->audio_stream_idx]->codecpar;
+int ret;
+
+if (!c->write_header)
+return 0;
+
+ret = ff_flac_write_header(s->pb, par->extradata,
+   par->extradata_size, 0);
+if (ret < 0)
+return ret;
+
 if (!c->waiting_pics)
 ret = flac_finish_header(s);
 
@@ -313,7 +322,6 @@ static int flac_write_trailer(struct AVFormatContext *s)
 FlacMuxerContext *c = s->priv_data;
 uint8_t *streaminfo = c->streaminfo ? c->streaminfo :
   
s->streams[c->audio_stream_idx]->codecpar->extradata;
-int i;
 
 if (c->waiting_pics) {
 av_log(s, AV_LOG_WARNING, "No packets were sent for some of the "
@@ -321,10 +329,6 @@ static int flac_write_trailer(struct AVFormatContext *s)
 flac_queue_flush(s);
 }
 
-for (i = 0; i < c->nb_pics; i++)
-av_packet_unref(>pics[i]);
-av_freep(>pics);
-
 if (!c->write_header || !streaminfo)
 return 0;
 
@@ -339,11 +343,21 @@ static int flac_write_trailer(struct AVFormatContext *s)
 av_log(s, AV_LOG_WARNING, "unable to rewrite FLAC header.\n");
 }
 
-av_freep(>streaminfo);
-
 return 0;
 }
 
+static void flac_deinit(struct AVFormatContext *s)
+{
+FlacMuxerContext *c = s->priv_data;
+int i;
+
+for (i = 0; i < c->nb_pics; i++)
+av_packet_unref(>pics[i]);
+av_freep(>pics);
+
+av_freep(>streaminfo);
+}
+
 static int flac_write_packet(struct AVFormatContext *s, AVPacket *pkt)
 {
 FlacMuxerContext *c = s->priv_data;
@@ -420,9 +434,11 @@ AVOutputFormat ff_flac_muxer = {
 .extensions= "flac",
 .audio_codec   = AV_CODEC_ID_FLAC,
 .video_codec   = AV_CODEC_ID_PNG,
+.init  = flac_init,
 .write_header  = flac_write_header,
 .write_packet  = flac_write_packet,
 .write_trailer = flac_write_trailer,
+.deinit= flac_deinit,
 .flags = AVFMT_NOTIMESTAMPS,
 .priv_class= _muxer_class,
 };
-- 
2.15.0

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


[FFmpeg-devel] [PATCH v4 1/2] avformat/hlsenc: Modularized playlist creation to allow reuse

2017-11-23 Thread Karthick J
---
 libavformat/Makefile  |   2 +-
 libavformat/hlsenc.c  | 115 +++
 libavformat/hlsplaylist.c | 136 ++
 libavformat/hlsplaylist.h |  51 +
 4 files changed, 209 insertions(+), 95 deletions(-)
 create mode 100644 libavformat/hlsplaylist.c
 create mode 100644 libavformat/hlsplaylist.h

diff --git a/libavformat/Makefile b/libavformat/Makefile
index b1e7b19..fd8b9f9 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -215,7 +215,7 @@ OBJS-$(CONFIG_HDS_MUXER) += hdsenc.o
 OBJS-$(CONFIG_HEVC_DEMUXER)  += hevcdec.o rawdec.o
 OBJS-$(CONFIG_HEVC_MUXER)+= rawenc.o
 OBJS-$(CONFIG_HLS_DEMUXER)   += hls.o
-OBJS-$(CONFIG_HLS_MUXER) += hlsenc.o
+OBJS-$(CONFIG_HLS_MUXER) += hlsenc.o hlsplaylist.o
 OBJS-$(CONFIG_HNM_DEMUXER)   += hnm.o
 OBJS-$(CONFIG_ICO_DEMUXER)   += icodec.o
 OBJS-$(CONFIG_ICO_MUXER) += icoenc.o
diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 30ccf73..7c759a8 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -45,6 +45,7 @@
 
 #include "avformat.h"
 #include "avio_internal.h"
+#include "hlsplaylist.h"
 #include "internal.h"
 #include "os_support.h"
 
@@ -96,13 +97,6 @@ typedef enum {
 SEGMENT_TYPE_FMP4,
 } SegmentType;
 
-typedef enum {
-PLAYLIST_TYPE_NONE,
-PLAYLIST_TYPE_EVENT,
-PLAYLIST_TYPE_VOD,
-PLAYLIST_TYPE_NB,
-} PlaylistType;
-
 typedef struct VariantStream {
 unsigned number;
 int64_t sequence;
@@ -1023,19 +1017,6 @@ static void hls_free_segments(HLSSegment *p)
 }
 }
 
-static void write_m3u8_head_block(HLSContext *hls, AVIOContext *out, int 
version,
-  int target_duration, int64_t sequence)
-{
-avio_printf(out, "#EXTM3U\n");
-avio_printf(out, "#EXT-X-VERSION:%d\n", version);
-if (hls->allowcache == 0 || hls->allowcache == 1) {
-avio_printf(out, "#EXT-X-ALLOW-CACHE:%s\n", hls->allowcache == 0 ? 
"NO" : "YES");
-}
-avio_printf(out, "#EXT-X-TARGETDURATION:%d\n", target_duration);
-avio_printf(out, "#EXT-X-MEDIA-SEQUENCE:%"PRId64"\n", sequence);
-av_log(hls, AV_LOG_VERBOSE, "EXT-X-MEDIA-SEQUENCE:%"PRId64"\n", sequence);
-}
-
 static void hls_rename_temp_file(AVFormatContext *s, AVFormatContext *oc)
 {
 size_t len = strlen(oc->filename);
@@ -1101,8 +1082,7 @@ static int create_master_playlist(AVFormatContext *s,
 goto fail;
 }
 
-avio_printf(master_pb, "#EXTM3U\n");
-avio_printf(master_pb, "#EXT-X-VERSION:%d\n", hls->version);
+ff_hls_write_playlist_version(master_pb, hls->version);
 
 /* For variant streams with video add #EXT-X-STREAM-INF tag with 
attributes*/
 for (i = 0; i < hls->nb_varstreams; i++) {
@@ -1143,18 +1123,7 @@ static int create_master_playlist(AVFormatContext *s,
 bandwidth += aud_st->codecpar->bit_rate;
 bandwidth += bandwidth / 10;
 
-if (!bandwidth) {
-av_log(NULL, AV_LOG_WARNING,
-"Bandwidth info not available, set audio and video 
bitrates\n");
-av_freep(_rel_name);
-continue;
-}
-
-avio_printf(master_pb, "#EXT-X-STREAM-INF:BANDWIDTH=%d", bandwidth);
-if (vid_st && vid_st->codecpar->width > 0 && vid_st->codecpar->height 
> 0)
-avio_printf(master_pb, ",RESOLUTION=%dx%d", 
vid_st->codecpar->width,
-vid_st->codecpar->height);
-avio_printf(master_pb, "\n%s\n\n", m3u8_rel_name);
+ff_hls_write_stream_info(vid_st, master_pb, bandwidth, m3u8_rel_name);
 
 av_freep(_rel_name);
 }
@@ -1183,6 +1152,7 @@ static int hls_window(AVFormatContext *s, int last, 
VariantStream *vs)
 char *iv_string = NULL;
 AVDictionary *options = NULL;
 double prog_date_time = vs->initial_prog_date_time;
+double *prog_date_time_p = (hls->flags & HLS_PROGRAM_DATE_TIME) ? 
_date_time : NULL;
 int byterange_mode = (hls->flags & HLS_SINGLE_FILE) || (hls->max_seg_size 
> 0);
 
 hls->version = 3;
@@ -1213,12 +1183,8 @@ static int hls_window(AVFormatContext *s, int last, 
VariantStream *vs)
 }
 
 vs->discontinuity_set = 0;
-write_m3u8_head_block(hls, out, hls->version, target_duration, sequence);
-if (hls->pl_type == PLAYLIST_TYPE_EVENT) {
-avio_printf(out, "#EXT-X-PLAYLIST-TYPE:EVENT\n");
-} else if (hls->pl_type == PLAYLIST_TYPE_VOD) {
-avio_printf(out, "#EXT-X-PLAYLIST-TYPE:VOD\n");
-}
+ff_hls_write_playlist_header(out, hls->version, hls->allowcache,
+ target_duration, sequence, hls->pl_type);
 
 if((hls->flags & HLS_DISCONT_START) && sequence==hls->start_sequence && 
vs->discontinuity_set==0 ){
 avio_printf(out, "#EXT-X-DISCONTINUITY\n");
@@ -1238,74 +1204,35 @@ static int hls_window(AVFormatContext *s, int last, 
VariantStream *vs)
   

Re: [FFmpeg-devel] [PATCH] avformat/avienc: fix fields-per-frame value for interlaced video streams

2017-11-23 Thread Carl Eugen Hoyos
2017-11-23 9:40 GMT+01:00 Tobias Rapp :
> On 22.11.2017 23:52, Carl Eugen Hoyos wrote:
>>
>> 2017-11-22 16:41 GMT+01:00 Tobias Rapp :
>>>
>>> Writes one set of field framing information for progressive streams and
>>> two sets for interlaced streams. Fixes ticket #6383.
>>>
>>> Unfortunately the OpenDML v1.02 document is not very specific what value
>>> to use for start_line when frame data is not coming from a capturing
>>> device, so this is just using 0/1 depending on the field order as a
>>> best-effort guess.
>>
>>
>> I believe your approach is sane but the only available examples
>> may indicate that it should be set to something like height / 2 ;-(

> I can use height/2 for start_line offset instead of 1

I tried hard not to imply that I would prefer this.

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


Re: [FFmpeg-devel] [PATCH]lavf/matroskaenc: Do not write 0 duration for subtitles

2017-11-23 Thread Jerome Martinez

On 12/11/2017 03:12, Carl Eugen Hoyos wrote:

The matroska spec says blockduration == 0 means the frame is not a
keyframe.  Since all subtitles are "keyframes", 0 blockduration should
not be written.


As I understand from discussion on CELLAR mailing-list:
- if is not expected to have a frame with block duration of 0, in a 
perfect world the previous frame should have the right duration and the 
player should hide the previous frame after blockduration of the 
previous frame.
- as a workaround, it would make sense to put an empty frame with 
"unlimited" duration, so no blockduration, as implemented in the patch.


The only issue is in the case someone puts a "not empty" frame with a 
duration of 0, this patch would change the behavior (from nothing 
displayed to the frame displayed) but as it is not expected to have a 
duration of 0 when something is displayed, this is not a real use case IMO.


Suggestion of changes for this patch:
- Remove the outdated part about specs. A duration of 0 is not coherent, 
that's all.
- Add a comment (in the code?) stipulating that duration of 0 is a 
special case which means "up to the next frame".


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


[FFmpeg-devel] [PATCH v2] avformat/hlsenc: Added option to add EXT-X-INDEPENDENT-SEGMENTS tag

2017-11-23 Thread Karthick J
---
 doc/muxers.texi  |  4 
 libavformat/hlsenc.c | 17 +
 2 files changed, 21 insertions(+)

diff --git a/doc/muxers.texi b/doc/muxers.texi
index 0bb8ad2..9d9ca31 100644
--- a/doc/muxers.texi
+++ b/doc/muxers.texi
@@ -737,6 +737,10 @@ The file specified by @code{hls_key_info_file} will be 
checked periodically and
 detect updates to the encryption info. Be sure to replace this file atomically,
 including the file containing the AES encryption key.
 
+@item independent_segments
+Add the @code{#EXT-X-INDEPENDENT-SEGMENTS} to playlists that has video segments
+and when all the segments of that playlist are guaranteed to start with a Key 
frame.
+
 @item split_by_time
 Allow segments to start on frames other than keyframes. This improves
 behavior on some players when the time between keyframes is inconsistent,
diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 3c47ced..bad5e14 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -88,6 +88,7 @@ typedef enum HLSFlags {
 HLS_SECOND_LEVEL_SEGMENT_SIZE = (1 << 10), // include segment size (bytes) 
in segment filenames when use_localtime  e.g.: %%014s
 HLS_TEMP_FILE = (1 << 11),
 HLS_PERIODIC_REKEY = (1 << 12),
+HLS_INDEPENDENT_SEGMENTS = (1 << 13),
 } HLSFlags;
 
 typedef enum {
@@ -1191,6 +1192,10 @@ static int hls_window(AVFormatContext *s, int last, 
VariantStream *vs)
 sequence = 0;
 }
 
+if (hls->flags & HLS_INDEPENDENT_SEGMENTS) {
+hls->version = 6;
+}
+
 if (hls->segment_type == SEGMENT_TYPE_FMP4) {
 hls->version = 7;
 }
@@ -1220,6 +1225,9 @@ static int hls_window(AVFormatContext *s, int last, 
VariantStream *vs)
 avio_printf(out, "#EXT-X-DISCONTINUITY\n");
 vs->discontinuity_set = 1;
 }
+if (vs->has_video && (hls->flags & HLS_INDEPENDENT_SEGMENTS)) {
+avio_printf(out, "#EXT-X-INDEPENDENT-SEGMENTS\n");
+}
 for (en = vs->segments; en; en = en->next) {
 if ((hls->encrypt || hls->key_info_file) && (!key_uri || 
strcmp(en->key_uri, key_uri) ||
 av_strcasecmp(en->iv_string, iv_string))) {
@@ -1732,6 +1740,14 @@ static int hls_write_header(AVFormatContext *s)
 vs->start_pts  = AV_NOPTS_VALUE;
 vs->current_segment_final_filename_fmt[0] = '\0';
 
+if (hls->flags & HLS_SPLIT_BY_TIME) {
+// Independent segments cannot be guaranteed when splitting by time
+hls->flags &= ~HLS_INDEPENDENT_SEGMENTS;
+av_log(s, AV_LOG_WARNING,
+   "'split_by_time' and 'independent_segments' cannot be enabled 
together. "
+   "Disabling 'independent_segments' flag\n");
+}
+
 if (hls->flags & HLS_PROGRAM_DATE_TIME) {
 time_t now0;
 time();
@@ -2323,6 +2339,7 @@ static const AVOption options[] = {
 {"second_level_segment_duration", "include segment duration in segment 
filenames when use_localtime", 0, AV_OPT_TYPE_CONST, {.i64 = 
HLS_SECOND_LEVEL_SEGMENT_DURATION }, 0, UINT_MAX,   E, "flags"},
 {"second_level_segment_size", "include segment size in segment filenames 
when use_localtime", 0, AV_OPT_TYPE_CONST, {.i64 = 
HLS_SECOND_LEVEL_SEGMENT_SIZE }, 0, UINT_MAX,   E, "flags"},
 {"periodic_rekey", "reload keyinfo file periodically for re-keying", 0, 
AV_OPT_TYPE_CONST, {.i64 = HLS_PERIODIC_REKEY }, 0, UINT_MAX,   E, "flags"},
+{"independent_segments", "add EXT-X-INDEPENDENT-SEGMENTS, whenever 
applicable", 0, AV_OPT_TYPE_CONST, { .i64 = HLS_INDEPENDENT_SEGMENTS }, 0, 
UINT_MAX, E, "flags"},
 {"use_localtime", "set filename expansion with strftime at segment 
creation", OFFSET(use_localtime), AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, E },
 {"use_localtime_mkdir", "create last directory component in 
strftime-generated filename", OFFSET(use_localtime_mkdir), AV_OPT_TYPE_BOOL, 
{.i64 = 0 }, 0, 1, E },
 {"hls_playlist_type", "set the HLS playlist type", OFFSET(pl_type), 
AV_OPT_TYPE_INT, {.i64 = PLAYLIST_TYPE_NONE }, 0, PLAYLIST_TYPE_NB-1, E, 
"pl_type" },
-- 
1.9.1

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


Re: [FFmpeg-devel] [PATCH] avformat/hlsenc: Added option to add EXT-X-INDEPENDENT-SEGMENTS tag

2017-11-23 Thread Carl Eugen Hoyos
2017-11-23 6:05 GMT+01:00 Karthick J :

> +if (hls->flags & HLS_SPLIT_BY_TIME) {
> +// Independent segments cannot be guaranteed when splitting by time
> +hls->flags &= ~HLS_INDEPENDENT_SEGMENTS;

Shouldn't this show a warning?

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


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

2017-11-23 Thread Carl Eugen Hoyos
2017-11-23 2:15 GMT+01:00 Marton Balint :

> All your points apply to Nvidia external headers as well

The Nvidia driver works on Linux where self-compilation is
at least not unusual.

Self compiled binaries by Windows users are very rare,
the one script that is typically used in that already rare
case could easily download the necessary header.

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


Re: [FFmpeg-devel] [PATCH v2] avformat/hlsenc: Added option to add EXT-X-INDEPENDENT-SEGMENTS tag

2017-11-23 Thread Carl Eugen Hoyos
2017-11-23 12:21 GMT+01:00 Karthick J :

> +if (hls->flags & HLS_SPLIT_BY_TIME) {
> +// Independent segments cannot be guaranteed when splitting by time
> +hls->flags &= ~HLS_INDEPENDENT_SEGMENTS;
> +av_log(s, AV_LOG_WARNING,
> +   "'split_by_time' and 'independent_segments' cannot be enabled 
> together. "
> +   "Disabling 'independent_segments' flag\n");
> +}

I did not read the code (so this comment may be wrong) but I would
have expected "if (flags & BY_TIME && flags & INDEPENDENT)".

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


[FFmpeg-devel] [PATCH v3] avformat/hlsenc: Added option to add EXT-X-INDEPENDENT-SEGMENTS tag

2017-11-23 Thread Karthick J
---
 doc/muxers.texi  |  4 
 libavformat/hlsenc.c | 17 +
 2 files changed, 21 insertions(+)

diff --git a/doc/muxers.texi b/doc/muxers.texi
index 0bb8ad2..9d9ca31 100644
--- a/doc/muxers.texi
+++ b/doc/muxers.texi
@@ -737,6 +737,10 @@ The file specified by @code{hls_key_info_file} will be 
checked periodically and
 detect updates to the encryption info. Be sure to replace this file atomically,
 including the file containing the AES encryption key.
 
+@item independent_segments
+Add the @code{#EXT-X-INDEPENDENT-SEGMENTS} to playlists that has video segments
+and when all the segments of that playlist are guaranteed to start with a Key 
frame.
+
 @item split_by_time
 Allow segments to start on frames other than keyframes. This improves
 behavior on some players when the time between keyframes is inconsistent,
diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 3c47ced..3010714 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -88,6 +88,7 @@ typedef enum HLSFlags {
 HLS_SECOND_LEVEL_SEGMENT_SIZE = (1 << 10), // include segment size (bytes) 
in segment filenames when use_localtime  e.g.: %%014s
 HLS_TEMP_FILE = (1 << 11),
 HLS_PERIODIC_REKEY = (1 << 12),
+HLS_INDEPENDENT_SEGMENTS = (1 << 13),
 } HLSFlags;
 
 typedef enum {
@@ -1191,6 +1192,10 @@ static int hls_window(AVFormatContext *s, int last, 
VariantStream *vs)
 sequence = 0;
 }
 
+if (hls->flags & HLS_INDEPENDENT_SEGMENTS) {
+hls->version = 6;
+}
+
 if (hls->segment_type == SEGMENT_TYPE_FMP4) {
 hls->version = 7;
 }
@@ -1220,6 +1225,9 @@ static int hls_window(AVFormatContext *s, int last, 
VariantStream *vs)
 avio_printf(out, "#EXT-X-DISCONTINUITY\n");
 vs->discontinuity_set = 1;
 }
+if (vs->has_video && (hls->flags & HLS_INDEPENDENT_SEGMENTS)) {
+avio_printf(out, "#EXT-X-INDEPENDENT-SEGMENTS\n");
+}
 for (en = vs->segments; en; en = en->next) {
 if ((hls->encrypt || hls->key_info_file) && (!key_uri || 
strcmp(en->key_uri, key_uri) ||
 av_strcasecmp(en->iv_string, iv_string))) {
@@ -1732,6 +1740,14 @@ static int hls_write_header(AVFormatContext *s)
 vs->start_pts  = AV_NOPTS_VALUE;
 vs->current_segment_final_filename_fmt[0] = '\0';
 
+if (hls->flags & HLS_SPLIT_BY_TIME && hls->flags & 
HLS_INDEPENDENT_SEGMENTS) {
+// Independent segments cannot be guaranteed when splitting by time
+hls->flags &= ~HLS_INDEPENDENT_SEGMENTS;
+av_log(s, AV_LOG_WARNING,
+   "'split_by_time' and 'independent_segments' cannot be enabled 
together. "
+   "Disabling 'independent_segments' flag\n");
+}
+
 if (hls->flags & HLS_PROGRAM_DATE_TIME) {
 time_t now0;
 time();
@@ -2323,6 +2339,7 @@ static const AVOption options[] = {
 {"second_level_segment_duration", "include segment duration in segment 
filenames when use_localtime", 0, AV_OPT_TYPE_CONST, {.i64 = 
HLS_SECOND_LEVEL_SEGMENT_DURATION }, 0, UINT_MAX,   E, "flags"},
 {"second_level_segment_size", "include segment size in segment filenames 
when use_localtime", 0, AV_OPT_TYPE_CONST, {.i64 = 
HLS_SECOND_LEVEL_SEGMENT_SIZE }, 0, UINT_MAX,   E, "flags"},
 {"periodic_rekey", "reload keyinfo file periodically for re-keying", 0, 
AV_OPT_TYPE_CONST, {.i64 = HLS_PERIODIC_REKEY }, 0, UINT_MAX,   E, "flags"},
+{"independent_segments", "add EXT-X-INDEPENDENT-SEGMENTS, whenever 
applicable", 0, AV_OPT_TYPE_CONST, { .i64 = HLS_INDEPENDENT_SEGMENTS }, 0, 
UINT_MAX, E, "flags"},
 {"use_localtime", "set filename expansion with strftime at segment 
creation", OFFSET(use_localtime), AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, E },
 {"use_localtime_mkdir", "create last directory component in 
strftime-generated filename", OFFSET(use_localtime_mkdir), AV_OPT_TYPE_BOOL, 
{.i64 = 0 }, 0, 1, E },
 {"hls_playlist_type", "set the HLS playlist type", OFFSET(pl_type), 
AV_OPT_TYPE_INT, {.i64 = PLAYLIST_TYPE_NONE }, 0, PLAYLIST_TYPE_NB-1, E, 
"pl_type" },
-- 
1.9.1

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


Re: [FFmpeg-devel] [PATCH 1/3] avformat/hlsenc:addition of #EXT-X-MEDIA tag and AUDIO attribute

2017-11-23 Thread Carl Eugen Hoyos
2017-11-23 4:37 GMT+01:00  :

> +av_strlcpy(m3U8_rel_name, vs->m3u8_name, m3u8_name_size);
> +ret = get_relative_url(hls->master_m3u8_url, vs->m3u8_name,
> +   m3U8_rel_name, m3u8_name_size);
> +if (ret < 0) {
> +av_log(NULL, AV_LOG_ERROR, "Unable to find relative URL\n");

Needs a context.

(Isn't there a patch to fix the variable name?)

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


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

2017-11-23 Thread Carl Eugen Hoyos
2017-11-22 23:36 GMT+01:00 Timo Rothenpieler :

> Also, I don't see a problem with including this AMD header. It very much
> increases the accessibility and maintainability

> (no need to watch out for potential breaking upstream changes, however
> likely that might be).

If we integrate the header, would that mean that FFmpeg developers have
to watch out more for potential upstream break or less?
(I believe a different answer than yours is at least possible.)

> Having those vendor-specific hwaccels enabled in otherwise generic
> builds gives a lot of people easy access, or access at all.

Could you elaborate?
Who exactly would get access in this case?

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


Re: [FFmpeg-devel] [PATCH] avformat/hlsenc: Added option to add EXT-X-INDEPENDENT-SEGMENTS tag

2017-11-23 Thread Jeyapal, Karthick
On 11/23/17, 4:13 PM, "Carl Eugen Hoyos"  wrote:
>
>2017-11-23 6:05 GMT+01:00 Karthick J :
>
>> +if (hls->flags & HLS_SPLIT_BY_TIME) {
>> +// Independent segments cannot be guaranteed when splitting by time
>> +hls->flags &= ~HLS_INDEPENDENT_SEGMENTS;
>
>Shouldn't this show a warning?
Thanks for your comments.
I have added the warning in the new patch v2 as you have rightly suggested.
>
>Carl Eugen

regards,
Karthick


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


Re: [FFmpeg-devel] [PATCH 3/3] avformat/hlsenc:addition of CODECS attribute in the master playlist

2017-11-23 Thread Jeyapal, Karthick
>From: Aman Gupta 

>On Wed, Nov 22, 2017 at 7:38 PM  wrote:
>>From: Vishwanath Dixit 
>>
>>Signed-off-by: Karthick J 
>
>LGTM.
>
>Have you looked at adding HEVC support?

Thanks for the reply. 
From our side, there are no immediate plans to add HEVC support.
But after this patch, it should be very simple to add the same.

Regards,
Karthick


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


Re: [FFmpeg-devel] [PATCH 2/3] avcodec/libx264:setting profile and level in avcodec context

2017-11-23 Thread Carl Eugen Hoyos
2017-11-23 4:37 GMT+01:00  :

> +s = x264_encoder_headers(x4->enc, , );
> +if (avctx->profile == FF_PROFILE_UNKNOWN)
> +avctx->profile = nal->p_payload[5];
> +if (avctx->level == FF_LEVEL_UNKNOWN)
> +avctx->level = nal->p_payload[7];

Why are these conditional?

(Do we really guarantee that our profile and level
fields contain the exact same values as the nal
payload?)

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


Re: [FFmpeg-devel] [PATCH] Refactor Developer Docs, update dev list section

2017-11-23 Thread Jim DeLaHunt


On 2017-11-22 15:40, Carl Eugen Hoyos wrote:

2017-11-23 0:39 GMT+01:00 Derek Buitenhuis :

On 11/22/2017 11:34 PM, Carl Eugen Hoyos wrote:

Please understand I am against removing the paragraph from the
documentation because I believe it is a good idea if developers
are subscribed to -cvslog.


Carl Eugen: Thank you for responding clearly to the policy question I 
asked.


You think it is a good idea for "developers" are subscribed to -cvslog. 
Others on this list clearly are comfortable with some contributors, 
maybe not the maintainers but just contributors of new features and bug 
fixes, not being subscribed to cvs-log. We could perhaps clarify this 
policy, if all of you who have that authority would care to have that 
discussion and come to a consensus.


Personally, as a new contributor, I think a policy of requiring new 
contributors, and those who "just want to send a patch here and there", 
to subscribe to -cvslog is ridiculous. The message volume on -devel is 
already torrential. The message volume on -cvslog would be about double 
that. And, from what I see in the archives, I don't understand how the 
traffic on -cvslog would add value beyond what I already file unread on 
-devel.


My opinion as someone considering whether to spend effort fixing what 
look to me like shallow bugs in the FFmpeg documentation, or investing 
my effort in another project, is that requiring me to subscribe to 
-cvslog would be a reason to give up on trying to comply with the FFmpeg 
project's demands. The ratio of gratification to effort would be too 
discouraging.  But, I'm just a newbie, and this policy decision is yours 
to make, not mine.



Perhaps it can be reworded a bit to say it's encouraged for the
cited reasons, but not mandatory if you just want to send a patch
here and there?

If that really helps anybody, please do so!


OK, I will modify the patch to include a new @Subheading describing 
subscription to ffmpeg-devel as in the current patch, and retaining a 
reworded version of the current @Subheading describing subscription to 
ffmpeg-cvslog as "encouraged for the cited reasons, but not mandatory if 
you just want to send a patch here and there" as Derek puts it. I won't 
get to that edit until the weekend.


Derek, thank you for your intervention.

Best regards,
 —Jim DeLaHunt, Vancouver, B.C.

--
--Jim DeLaHunt, j...@jdlh.com http://blog.jdlh.com/ (http://jdlh.com/)
  multilingual websites consultant

  355-1027 Davie St, Vancouver BC V6E 4L2, Canada
 Canada mobile +1-604-376-8953

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


Re: [FFmpeg-devel] [PATCH 3/3] avformat/hlsenc:addition of CODECS attribute in the master playlist

2017-11-23 Thread Carl Eugen Hoyos
2017-11-23 4:37 GMT+01:00  :
> From: Vishwanath Dixit 
>
> Signed-off-by: Karthick J 
> ---
>  libavformat/hlsenc.c | 67 
> +++-
>  1 file changed, 66 insertions(+), 1 deletion(-)
>
> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> index 9fed6a3..32246c4 100644
> --- a/libavformat/hlsenc.c
> +++ b/libavformat/hlsenc.c
> @@ -1065,6 +1065,52 @@ static int get_relative_url(const char *master_url, 
> const char *media_url,
>  return 0;
>  }
>
> +static void get_codec_str(AVStream *vid_st, AVStream *aud_st, char *vcodec,
> +  char *acodec, int vcodec_len, int acodec_len) {

> +if (vcodec_len > 0)
> +vcodec[0] = '\0';
> +else
> +return;
> +
> +if (acodec_len > 0)
> +acodec[0] = '\0';
> +else
> +return;

What are these supposed to do?
Actually: Please add a line below to avoid these.

> +
> +if (!vid_st && !aud_st) {
> +av_log(NULL, AV_LOG_WARNING, "Atleast one stream shoud be valid\n");
> +return;
> +}

This looks like the wrong place for such a check.

> +
> +if (vid_st && vid_st->codecpar->profile != FF_PROFILE_UNKNOWN &&
> +vid_st->codecpar->level != FF_LEVEL_UNKNOWN &&
> +vid_st->codecpar->codec_id == AV_CODEC_ID_H264) {
> +snprintf(vcodec, vcodec_len, "avc1.%02x00%02x",
> +vid_st->codecpar->profile, vid_st->codecpar->level);
> +}

The rfc does not specify a string for unknown profile?

> +
> +if (aud_st) {
> +if (aud_st->codecpar->codec_id == AV_CODEC_ID_MP2) {
> +snprintf(acodec, acodec_len, "mp4a.40.33");
> +} else if (aud_st->codecpar->codec_id == AV_CODEC_ID_MP3) {
> +snprintf(acodec, acodec_len, "mp4a.40.34");
> +} else if (aud_st->codecpar->codec_id == AV_CODEC_ID_AAC) {

> +/* TODO : For HE-AAC, HE-AACv2, the last digit needs to be set 
> to 5 and 29 respectively */

Yes.
Is this the only special case already known?

> +snprintf(acodec, acodec_len, "mp4a.40.2");
> +} else if (aud_st->codecpar->codec_id == AV_CODEC_ID_AC3) {
> +snprintf(acodec, acodec_len, "mp4a.A5");
> +} else if (aud_st->codecpar->codec_id == AV_CODEC_ID_EAC3) {
> +snprintf(acodec, acodec_len, "mp4a.A6");
> +}
> +}
> +
> +// either provide codec string for both active streams or for none
> +if (vid_st && aud_st && (!strlen(vcodec) || !strlen(acodec))) {
> +acodec[0] = vcodec[0] = '\0';
> +av_log(NULL, AV_LOG_INFO, "Codec string not available for audio or 
> video stream\n");
> +}

This needs a context and maybe a higher verbosity.

> +}
> +
>  static int create_master_playlist(AVFormatContext *s,
>VariantStream * const input_vs)
>  {
> @@ -1075,7 +1121,7 @@ static int create_master_playlist(AVFormatContext *s,
>  AVDictionary *options = NULL;
>  unsigned int i, j;
>  int m3u8_name_size, ret, bandwidth;
> -char *m3U8_rel_name;
> +char *m3U8_rel_name, vcodec[32], acodec[32];

I suspect you should initialize the first byte here to
avoid the check on top.

>
>  input_vs->m3u8_created = 1;
>  if (!hls->master_m3u8_created) {
> @@ -1203,6 +1249,25 @@ static int create_master_playlist(AVFormatContext *s,
>  avio_printf(master_pb, ",RESOLUTION=%dx%d", 
> vid_st->codecpar->width,
>  vid_st->codecpar->height);
>
> +get_codec_str(vid_st, aud_st, vcodec, acodec, sizeof(vcodec),
> +  sizeof(acodec));

Imo, use defines instead of sizeof() here.

> +if (strlen(vcodec) || strlen(acodec))

Even if not speed-critical code, checking the first byte
may be simpler.

Using "{" here simplifies the code below.

> +avio_printf(master_pb, ",CODECS=\"");
> +
> +if (strlen(vcodec)) {
> +avio_printf(master_pb, "%s", vcodec);
> +
> +if (strlen(acodec))
> +avio_printf(master_pb, ",");
> +}
> +
> +if (strlen(acodec))
> +avio_printf(master_pb, "%s", acodec);
> +
> +if (strlen(vcodec) || strlen(acodec))
> +avio_printf(master_pb, "\"");

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


[FFmpeg-devel] [PATCH]ffmpeg: Improve warnings if av_buffersrc_add_frame*() fail

2017-11-23 Thread Carl Eugen Hoyos
Hi!

Attached patch implements more verbose warnings as suggested by Nicolas.

Please comment, Carl Eugen
From 5ec3b8bdb776d9c14127017cd9e3077503be2bea Mon Sep 17 00:00:00 2001
From: Carl Eugen Hoyos 
Date: Thu, 23 Nov 2017 12:05:51 +0100
Subject: [PATCH] ffmpeg: Improve warnings if av_buffersrc_add_frame*() fail.

Suggested-by: Nicolas
---
 fftools/ffmpeg.c |7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 0c16e75..3ce8833 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -229,7 +229,8 @@ static void sub2video_push_ref(InputStream *ist, int64_t pts)
AV_BUFFERSRC_FLAG_KEEP_REF |
AV_BUFFERSRC_FLAG_PUSH);
 if (ret != AVERROR_EOF && ret < 0)
-av_log(NULL, AV_LOG_WARNING, "Error while add the frame to buffer source(%s).\n",
+av_log(ist->filters[i]->filter, AV_LOG_WARNING,
+   "Failed to add a subtitle video frame to the buffer source: %s\n",
av_err2str(ret));
 }
 }
@@ -307,7 +308,9 @@ static void sub2video_flush(InputStream *ist)
 for (i = 0; i < ist->nb_filters; i++) {
 ret = av_buffersrc_add_frame(ist->filters[i]->filter, NULL);
 if (ret != AVERROR_EOF && ret < 0)
-av_log(NULL, AV_LOG_WARNING, "Flush the frame error.\n");
+av_log(ist->filters[i]->filter, AV_LOG_WARNING,
+   "Failed to add a subtitle video frame to the buffer source: %s\n",
+   av_err2str(ret));
 }
 }
 
-- 
1.7.10.4

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


Re: [FFmpeg-devel] [PATCH v2] avformat/hlsenc: Added option to add EXT-X-INDEPENDENT-SEGMENTS tag

2017-11-23 Thread Jeyapal, Karthick


On 11/23/17, 4:56 PM, "Carl Eugen Hoyos"  wrote:
>
>2017-11-23 12:21 GMT+01:00 Karthick J :
>
>> +if (hls->flags & HLS_SPLIT_BY_TIME) {
>> +// Independent segments cannot be guaranteed when splitting by time
>> +hls->flags &= ~HLS_INDEPENDENT_SEGMENTS;
>> +av_log(s, AV_LOG_WARNING,
>> +   "'split_by_time' and 'independent_segments' cannot be 
>> enabled together. "
>> +   "Disabling 'independent_segments' flag\n");
>> +}
>
>I did not read the code (so this comment may be wrong) but I would
>have expected "if (flags & BY_TIME && flags & INDEPENDENT)".
Oops. My mistake. Have corrected it in PATCH v3.
>
>Carl Eugen

regards,
Karthick


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


Re: [FFmpeg-devel] [PATCH 2/3] avcodec/libx264:setting profile and level in avcodec context

2017-11-23 Thread Jeyapal, Karthick
On 11/23/17, 4:21 PM, "Carl Eugen Hoyos"  wrote:

>2017-11-23 4:37 GMT+01:00  :
>
>> +s = x264_encoder_headers(x4->enc, , );
>> +if (avctx->profile == FF_PROFILE_UNKNOWN)
>> +avctx->profile = nal->p_payload[5];
>> +if (avctx->level == FF_LEVEL_UNKNOWN)
>> +avctx->level = nal->p_payload[7];
>
>Why are these conditional?
We didn’t want to overwrite profile and level, if user had already set it.
Comments in avcodec.h mentioned, ‘encoding: Set by user’, for profile and level.
>
>(Do we really guarantee that our profile and level
>fields contain the exact same values as the nal
>payload?)
There is no guarantee. 
But instead of unknown profile and level, setting profile and level whenever 
possible could enhance feature-set of certain muxers, like hlsenc.
>
>Carl Eugen

regards,
Karthick


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


Re: [FFmpeg-devel] [PATCH 2/3] avcodec/libx264:setting profile and level in avcodec context

2017-11-23 Thread Carl Eugen Hoyos
2017-11-23 12:47 GMT+01:00 Jeyapal, Karthick :
> On 11/23/17, 4:21 PM, "Carl Eugen Hoyos"  wrote:
>
>>2017-11-23 4:37 GMT+01:00  :
>>
>>> +s = x264_encoder_headers(x4->enc, , );
>>> +if (avctx->profile == FF_PROFILE_UNKNOWN)
>>> +avctx->profile = nal->p_payload[5];
>>> +if (avctx->level == FF_LEVEL_UNKNOWN)
>>> +avctx->level = nal->p_payload[7];
>>
>>Why are these conditional?
> We didn’t want to overwrite profile and level, if user had already set it.

So if x264 changes these values because of contradicting user
requests, we write the wrong values into the hls header?

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


Re: [FFmpeg-devel] [PATCH] avformat/hlsenc: Added option to add EXT-X-INDEPENDENT-SEGMENTS tag

2017-11-23 Thread Aman Gupta
On Wed, Nov 22, 2017 at 9:06 PM Karthick J  wrote:

> ---
>  doc/muxers.texi  |  4 
>  libavformat/hlsenc.c | 14 ++
>  2 files changed, 18 insertions(+)
>
> diff --git a/doc/muxers.texi b/doc/muxers.texi
> index 0bb8ad2..9d9ca31 100644
> --- a/doc/muxers.texi
> +++ b/doc/muxers.texi
> @@ -737,6 +737,10 @@ The file specified by @code{hls_key_info_file} will
> be checked periodically and
>  detect updates to the encryption info. Be sure to replace this file
> atomically,
>  including the file containing the AES encryption key.
>
> +@item independent_segments
> +Add the @code{#EXT-X-INDEPENDENT-SEGMENTS} to playlists that has video
> segments
> +and when all the segments of that playlist are guaranteed to start with a
> Key frame.
> +
>  @item split_by_time
>  Allow segments to start on frames other than keyframes. This improves
>  behavior on some players when the time between keyframes is inconsistent,
> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> index 3c47ced..5fc355a 100644
> --- a/libavformat/hlsenc.c
> +++ b/libavformat/hlsenc.c
> @@ -88,6 +88,7 @@ typedef enum HLSFlags {
>  HLS_SECOND_LEVEL_SEGMENT_SIZE = (1 << 10), // include segment size
> (bytes) in segment filenames when use_localtime  e.g.: %%014s
>  HLS_TEMP_FILE = (1 << 11),
>  HLS_PERIODIC_REKEY = (1 << 12),
> +HLS_INDEPENDENT_SEGMENTS = (1 << 13),
>  } HLSFlags;
>
>  typedef enum {
> @@ -1191,6 +1192,10 @@ static int hls_window(AVFormatContext *s, int last,
> VariantStream *vs)
>  sequence = 0;
>  }
>
> +if (hls->flags & HLS_INDEPENDENT_SEGMENTS) {
> +hls->version = 6;
> +}
> +
>  if (hls->segment_type == SEGMENT_TYPE_FMP4) {
>  hls->version = 7;
>  }
> @@ -1220,6 +1225,9 @@ static int hls_window(AVFormatContext *s, int last,
> VariantStream *vs)
>  avio_printf(out, "#EXT-X-DISCONTINUITY\n");
>  vs->discontinuity_set = 1;
>  }
> +if (vs->has_video && (hls->flags & HLS_INDEPENDENT_SEGMENTS)) {
> +avio_printf(out, "#EXT-X-INDEPENDENT-SEGMENTS\n");
> +}
>  for (en = vs->segments; en; en = en->next) {
>  if ((hls->encrypt || hls->key_info_file) && (!key_uri ||
> strcmp(en->key_uri, key_uri) ||
>  av_strcasecmp(en->iv_string,
> iv_string))) {
> @@ -1732,6 +1740,11 @@ static int hls_write_header(AVFormatContext *s)
>  vs->start_pts  = AV_NOPTS_VALUE;
>  vs->current_segment_final_filename_fmt[0] = '\0';
>
> +if (hls->flags & HLS_SPLIT_BY_TIME) {
> +// Independent segments cannot be guaranteed when splitting by
> time
> +hls->flags &= ~HLS_INDEPENDENT_SEGMENTS;
> +}
> +
>  if (hls->flags & HLS_PROGRAM_DATE_TIME) {
>  time_t now0;
>  time();
> @@ -2323,6 +2336,7 @@ static const AVOption options[] = {
>  {"second_level_segment_duration", "include segment duration in
> segment filenames when use_localtime", 0, AV_OPT_TYPE_CONST, {.i64 =
> HLS_SECOND_LEVEL_SEGMENT_DURATION }, 0, UINT_MAX,   E, "flags"},
>  {"second_level_segment_size", "include segment size in segment
> filenames when use_localtime", 0, AV_OPT_TYPE_CONST, {.i64 =
> HLS_SECOND_LEVEL_SEGMENT_SIZE }, 0, UINT_MAX,   E, "flags"},
>  {"periodic_rekey", "reload keyinfo file periodically for re-keying",
> 0, AV_OPT_TYPE_CONST, {.i64 = HLS_PERIODIC_REKEY }, 0, UINT_MAX,   E,
> "flags"},
> +{"independent_segments", "add EXT-X-INDEPENDENT-SEGMENTS, whenever
> applicable", 0, AV_OPT_TYPE_CONST, { .i64 = HLS_INDEPENDENT_SEGMENTS }, 0,
> UINT_MAX, E, "flags"},


LGTM


>  {"use_localtime", "set filename expansion with strftime at segment
> creation", OFFSET(use_localtime), AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, E },
>  {"use_localtime_mkdir", "create last directory component in
> strftime-generated filename", OFFSET(use_localtime_mkdir),
> AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, E },
>  {"hls_playlist_type", "set the HLS playlist type", OFFSET(pl_type),
> AV_OPT_TYPE_INT, {.i64 = PLAYLIST_TYPE_NONE }, 0, PLAYLIST_TYPE_NB-1, E,
> "pl_type" },
> --
> 1.9.1
>
> ___
> 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] avformat/avienc: fix fields-per-frame value for interlaced video streams

2017-11-23 Thread Tobias Rapp

On 22.11.2017 23:52, Carl Eugen Hoyos wrote:

2017-11-22 16:41 GMT+01:00 Tobias Rapp :

Writes one set of field framing information for progressive streams and
two sets for interlaced streams. Fixes ticket #6383.

Unfortunately the OpenDML v1.02 document is not very specific what value
to use for start_line when frame data is not coming from a capturing
device, so this is just using 0/1 depending on the field order as a
best-effort guess.


I believe your approach is sane but the only available examples
may indicate that it should be set to something like height / 2 ;-(


Indeed my main problem is that I have not found some real-world example 
file with two sets of field framing information. I scanned the files at 
http://streams.videolan.org/samples/ but out of >900 AVI files only 
about 40 files contain a vprp chunk but none contains two fields.


I have found two files that have FieldPerFrame=2 (indicating an 
interlaced video stream) but they contain a truncated vprp chunk (no 
field framing information):

http://streams.videolan.org/samples/V-codecs/MJPEGs/matrox-capture.avi
http://streams.videolan.org/samples/avi/TRA3106.avi

As this clearly doesn't match the specs I didn't want to follow these 
two examples.


I can use height/2 for start_line offset instead of 1 if that sounds 
better, to me it would look like an indication that the fields are 
stored separated, but no strong opinion from my side.


Regards,
Tobias

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


Re: [FFmpeg-devel] [PATCH 3/3] avformat/hlsenc:addition of CODECS attribute in the master playlist

2017-11-23 Thread Aman Gupta
On Wed, Nov 22, 2017 at 7:38 PM  wrote:

> From: Vishwanath Dixit 
>
> Signed-off-by: Karthick J 
> ---
>  libavformat/hlsenc.c | 67
> +++-
>  1 file changed, 66 insertions(+), 1 deletion(-)
>
> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> index 9fed6a3..32246c4 100644
> --- a/libavformat/hlsenc.c
> +++ b/libavformat/hlsenc.c
> @@ -1065,6 +1065,52 @@ static int get_relative_url(const char *master_url,
> const char *media_url,
>  return 0;
>  }
>
> +static void get_codec_str(AVStream *vid_st, AVStream *aud_st, char
> *vcodec,
> +  char *acodec, int vcodec_len, int acodec_len) {
> +if (vcodec_len > 0)
> +vcodec[0] = '\0';
> +else
> +return;
> +
> +if (acodec_len > 0)
> +acodec[0] = '\0';
> +else
> +return;
> +
> +if (!vid_st && !aud_st) {
> +av_log(NULL, AV_LOG_WARNING, "Atleast one stream shoud be
> valid\n");
> +return;
> +}
> +
> +if (vid_st && vid_st->codecpar->profile != FF_PROFILE_UNKNOWN &&
> +vid_st->codecpar->level != FF_LEVEL_UNKNOWN &&
> +vid_st->codecpar->codec_id == AV_CODEC_ID_H264) {
> +snprintf(vcodec, vcodec_len, "avc1.%02x00%02x",
> +vid_st->codecpar->profile, vid_st->codecpar->level);
> +}
> +
> +if (aud_st) {
> +if (aud_st->codecpar->codec_id == AV_CODEC_ID_MP2) {
> +snprintf(acodec, acodec_len, "mp4a.40.33");
> +} else if (aud_st->codecpar->codec_id == AV_CODEC_ID_MP3) {
> +snprintf(acodec, acodec_len, "mp4a.40.34");
> +} else if (aud_st->codecpar->codec_id == AV_CODEC_ID_AAC) {
> +/* TODO : For HE-AAC, HE-AACv2, the last digit needs to be
> set to 5 and 29 respectively */
> +snprintf(acodec, acodec_len, "mp4a.40.2");
> +} else if (aud_st->codecpar->codec_id == AV_CODEC_ID_AC3) {
> +snprintf(acodec, acodec_len, "mp4a.A5");
> +} else if (aud_st->codecpar->codec_id == AV_CODEC_ID_EAC3) {
> +snprintf(acodec, acodec_len, "mp4a.A6");
> +}
> +}
> +
> +// either provide codec string for both active streams or for none
> +if (vid_st && aud_st && (!strlen(vcodec) || !strlen(acodec))) {
> +acodec[0] = vcodec[0] = '\0';
> +av_log(NULL, AV_LOG_INFO, "Codec string not available for audio
> or video stream\n");
> +}
> +}
> +
>  static int create_master_playlist(AVFormatContext *s,
>VariantStream * const input_vs)
>  {
> @@ -1075,7 +1121,7 @@ static int create_master_playlist(AVFormatContext *s,
>  AVDictionary *options = NULL;
>  unsigned int i, j;
>  int m3u8_name_size, ret, bandwidth;
> -char *m3U8_rel_name;
> +char *m3U8_rel_name, vcodec[32], acodec[32];
>
>  input_vs->m3u8_created = 1;
>  if (!hls->master_m3u8_created) {
> @@ -1203,6 +1249,25 @@ static int create_master_playlist(AVFormatContext
> *s,
>  avio_printf(master_pb, ",RESOLUTION=%dx%d",
> vid_st->codecpar->width,
>  vid_st->codecpar->height);
>
> +get_codec_str(vid_st, aud_st, vcodec, acodec, sizeof(vcodec),
> +  sizeof(acodec));
> +
> +if (strlen(vcodec) || strlen(acodec))
> +avio_printf(master_pb, ",CODECS=\"");
> +
> +if (strlen(vcodec)) {
> +avio_printf(master_pb, "%s", vcodec);
> +
> +if (strlen(acodec))
> +avio_printf(master_pb, ",");
> +}
> +
> +if (strlen(acodec))
> +avio_printf(master_pb, "%s", acodec);
> +
> +if (strlen(vcodec) || strlen(acodec))
> +avio_printf(master_pb, "\"");
> +
>  if (vs->agroup && aud_st)
>  avio_printf(master_pb, ",AUDIO=\"group_%s\"", vs->agroup);


LGTM.

Have you looked at adding HEVC support?


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


[FFmpeg-devel] [PATCH]lavc/avcodec: Allow libavcodec to overwrite profile and level

2017-11-23 Thread Carl Eugen Hoyos
Hi!

The (external) encoders may overwrite level and profile because of
requested encoding properties, allowing libavcodec to (also) overwrite
them in the context makes sense (and is already done in some cases
afaict).

Please comment, Carl Eugen
From c6a84f9d8b511a9f4db541f0271748ae5257a0ae Mon Sep 17 00:00:00 2001
From: Carl Eugen Hoyos 
Date: Thu, 23 Nov 2017 15:58:33 +0100
Subject: [PATCH] lavc/avcodec: Allow lavc to overwrite
 AVCodecContext->profile and level.

This makes more sense and is already done in some cases.
---
 libavcodec/avcodec.h |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 4cd72b5..dd12353 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -2800,7 +2800,7 @@ typedef struct AVCodecContext {
 
 /**
  * profile
- * - encoding: Set by user.
+ * - encoding: Set by user, may be overwritten by libavcodec.
  * - decoding: Set by libavcodec.
  */
  int profile;
@@ -2898,7 +2898,7 @@ typedef struct AVCodecContext {
 
 /**
  * level
- * - encoding: Set by user.
+ * - encoding: Set by user, may be overwritten by libavcodec.
  * - decoding: Set by libavcodec.
  */
  int level;
-- 
1.7.10.4

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


Re: [FFmpeg-devel] [PATCH]ffmpeg: Improve warnings if av_buffersrc_add_frame*() fail

2017-11-23 Thread Derek Buitenhuis
On 11/23/2017 11:09 AM, Carl Eugen Hoyos wrote:
> Hi!
> 
> Attached patch implements more verbose warnings as suggested by Nicolas.
> 
> Please comment, Carl Eugen

OK.

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


Re: [FFmpeg-devel] [PATCH 2/3] avcodec/libx264:setting profile and level in avcodec context

2017-11-23 Thread Carl Eugen Hoyos
2017-11-23 13:56 GMT+01:00 Jeyapal, Karthick :
>
> On 11/23/17, 5:33 PM, "Carl Eugen Hoyos"  wrote:
>
>>2017-11-23 12:47 GMT+01:00 Jeyapal, Karthick :
>>> On 11/23/17, 4:21 PM, "Carl Eugen Hoyos"  wrote:
>>>
2017-11-23 4:37 GMT+01:00  :
>>>
> +s = x264_encoder_headers(x4->enc, , );
> +if (avctx->profile == FF_PROFILE_UNKNOWN)
> +avctx->profile = nal->p_payload[5];
> +if (avctx->level == FF_LEVEL_UNKNOWN)
> +avctx->level = nal->p_payload[7];

Why are these conditional?
>>> We didn’t want to overwrite profile and level, if user had already set it.
>>
>>So if x264 changes these values because of contradicting user
>>requests, we write the wrong values into the hls header?
>
> Yes, that is true.

> We were afraid to set profile and level unconditionally, because we
> thought it could get rejected by maintainers

Very smart, you have learned quickly!
(I wish that wouldn't be the message we send to new contributors...)

> (due to that comment in avcodec.h).

I sent a patch.

> Now, if you suggest us to remove those conditions, we would be
> happy to do it.

I believe other encoders already overwrite it and I believe in this
case it would be a particularly bad idea not to overwrite it.

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


Re: [FFmpeg-devel] [PATCH]ffmpeg: Improve warnings if av_buffersrc_add_frame*() fail

2017-11-23 Thread Nicolas George
Carl Eugen Hoyos (2017-11-23):
> Hi!
> 
> Attached patch implements more verbose warnings as suggested by Nicolas.
> 
> Please comment, Carl Eugen

> From 5ec3b8bdb776d9c14127017cd9e3077503be2bea Mon Sep 17 00:00:00 2001
> From: Carl Eugen Hoyos 
> Date: Thu, 23 Nov 2017 12:05:51 +0100
> Subject: [PATCH] ffmpeg: Improve warnings if av_buffersrc_add_frame*() fail.
> 
> Suggested-by: Nicolas
> ---
>  fftools/ffmpeg.c |7 +--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
> index 0c16e75..3ce8833 100644
> --- a/fftools/ffmpeg.c
> +++ b/fftools/ffmpeg.c
> @@ -229,7 +229,8 @@ static void sub2video_push_ref(InputStream *ist, int64_t 
> pts)
> AV_BUFFERSRC_FLAG_KEEP_REF |
> AV_BUFFERSRC_FLAG_PUSH);
>  if (ret != AVERROR_EOF && ret < 0)
> -av_log(NULL, AV_LOG_WARNING, "Error while add the frame to 
> buffer source(%s).\n",
> +av_log(ist->filters[i]->filter, AV_LOG_WARNING,
> +   "Failed to add a subtitle video frame to the buffer 
> source: %s\n",

This part LGTM. But "buffer source" is not meant for end-users. "... to
the filter graph"?

> av_err2str(ret));
>  }
>  }
> @@ -307,7 +308,9 @@ static void sub2video_flush(InputStream *ist)
>  for (i = 0; i < ist->nb_filters; i++) {
>  ret = av_buffersrc_add_frame(ist->filters[i]->filter, NULL);
>  if (ret != AVERROR_EOF && ret < 0)

> -av_log(NULL, AV_LOG_WARNING, "Flush the frame error.\n");
> +av_log(ist->filters[i]->filter, AV_LOG_WARNING,
> +   "Failed to add a subtitle video frame to the buffer 
> source: %s\n",
> +   av_err2str(ret));

This one looks wrong: there is no frame added, the error message you
remove is more accurate.

>  }
>  }
>  

Sorry to have been unresponsive on this issues the last few days.

Regards,

-- 
  Nicolas George


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


Re: [FFmpeg-devel] [PATCH 1/3] avformat/hlsenc:addition of #EXT-X-MEDIA tag and AUDIO attribute

2017-11-23 Thread Moritz Barsnick
On Thu, Nov 23, 2017 at 11:47:30 +0100, Carl Eugen Hoyos wrote:
> (Isn't there a patch to fix the variable name?)
Still pending:
https://patchwork.ffmpeg.org/patch/6257/
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 1/3] Revert "udp: fix compilation when HAVE_PTHREAD_CANCEL isnt defined"

2017-11-23 Thread Derek Buitenhuis
On 11/22/2017 4:41 PM, Paul B Mahol wrote:
> LGTM

Pushed.

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


Re: [FFmpeg-devel] [PATCH 2/3] avcodec/libx264:setting profile and level in avcodec context

2017-11-23 Thread Jeyapal, Karthick

On 11/23/17, 5:33 PM, "Carl Eugen Hoyos"  wrote:

>2017-11-23 12:47 GMT+01:00 Jeyapal, Karthick :
>> On 11/23/17, 4:21 PM, "Carl Eugen Hoyos"  wrote:
>>
>>>2017-11-23 4:37 GMT+01:00  :
>>
 +s = x264_encoder_headers(x4->enc, , );
 +if (avctx->profile == FF_PROFILE_UNKNOWN)
 +avctx->profile = nal->p_payload[5];
 +if (avctx->level == FF_LEVEL_UNKNOWN)
 +avctx->level = nal->p_payload[7];
>>>
>>>Why are these conditional?
>> We didn’t want to overwrite profile and level, if user had already set it.
>
>So if x264 changes these values because of contradicting user
>requests, we write the wrong values into the hls header?

Yes, that is true. 
We were afraid to set profile and level unconditionally, because we thought it 
could get rejected by maintainers(due to that comment in avcodec.h).
Now, if you suggest us to remove those conditions, we would be happy to do it. 
Please advise.

Thanks and regards,
Karthick



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


Re: [FFmpeg-devel] [PATCH] avfilter/drawbox: rename variable for maximum thickness

2017-11-23 Thread Gyan Doshi


On 11/20/2017 3:59 PM, Gyan Doshi wrote:
At present, the value name 'max' for maximum thickness in drawbox (and 
drawgrid) filter leads to a parse error if the thickness expression 
contains 'max(val1,val2)' i.e.


     [Eval @ ...] Invalid chars '(20,30)' at the end of expression 
'max(20,30)'


Renamed to 'fill'; tested & documented.


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


[FFmpeg-devel] [PATCH] doc/filters.texi: explain infinite looping

2017-11-23 Thread Werner Robitza
Explain how to achieve infinite looping with the loop / aloop filters.

Signed-off-by: Werner Robitza 
---
 doc/filters.texi | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index 04a8139c6d..b8a4d032e0 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -1144,7 +1144,7 @@ The filter accepts the following options:
 
 @table @option
 @item loop
-Set the number of loops.
+Set the number of loops. Setting this value to -1 will result in infinite 
loops.
 
 @item size
 Set maximal number of samples.
@@ -9991,7 +9991,7 @@ The filter accepts the following options:
 
 @table @option
 @item loop
-Set the number of loops.
+Set the number of loops. Setting this value to -1 will result in infinite 
loops.
 
 @item size
 Set maximal size in number of frames.
-- 
2.15.0

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


Re: [FFmpeg-devel] [PATCH]lavf/matroskaenc: Do not write 0 duration for subtitles

2017-11-23 Thread John Stebbins
On 11/23/2017 03:04 AM, Jerome Martinez wrote:
> On 12/11/2017 03:12, Carl Eugen Hoyos wrote:
>> The matroska spec says blockduration == 0 means the frame is not a
>> keyframe.  Since all subtitles are "keyframes", 0 blockduration should
>> not be written.
> As I understand from discussion on CELLAR mailing-list:
> - if is not expected to have a frame with block duration of 0, in a 
> perfect world the previous frame should have the right duration and the 
> player should hide the previous frame after blockduration of the 
> previous frame.
> - as a workaround, it would make sense to put an empty frame with 
> "unlimited" duration, so no blockduration, as implemented in the patch.
>
> The only issue is in the case someone puts a "not empty" frame with a 
> duration of 0, this patch would change the behavior (from nothing 
> displayed to the frame displayed) but as it is not expected to have a 
> duration of 0 when something is displayed, this is not a real use case IMO.
>
> Suggestion of changes for this patch:
> - Remove the outdated part about specs. A duration of 0 is not coherent, 
> that's all.
> - Add a comment (in the code?) stipulating that duration of 0 is a 
> special case which means "up to the next frame".
>
>

The use case this patch was created for is PGS subtitles that use an "empty" 
PGS subtitle to mark the end of the
previous subtitle.  An "empty" PGS subtitle is not a packet of 0 length.  It is 
a PGS subtitle that has zero composition
objects.  So a non-empty frame of 0 duration gets written to mark the end of 
the previous PGS.   It's not practical to
know the duration of the previous subtitle before writing it because you can't 
know it till you have seen this empty
PGS.  Once you've seen the empty PGS, it is often too late to properly 
interleave the previous PGS in the output file.

Your suggestion (0 means up to next frame) however works I believe.  I.e. 
display the "empty" PGS up to the next frame.

-- 
John  GnuPG fingerprint: D0EC B3DB C372 D1F1 0B01  83F0 49F1 D7B2 60D4 D0F7




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


Re: [FFmpeg-devel] [PATCH] doc/filters.texi: explain infinite looping

2017-11-23 Thread Lou Logan
On Thu, Nov 23, 2017, at 03:16 AM, Werner Robitza wrote:
> Explain how to achieve infinite looping with the loop / aloop filters.
> 
> Signed-off-by: Werner Robitza 
> ---
>  doc/filters.texi | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

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


Re: [FFmpeg-devel] avcodec/x86/exrdsp : use ymm constant for pb_80 instead of vbroadcasti128

2017-11-23 Thread Martin Vignali
2017-11-22 18:21 GMT+01:00 James Almer :

> On 11/21/2017 6:09 PM, Martin Vignali wrote:
> > Hello,
> >
> > After patch by James Almer
> > (pb_80 now fit an ymm)
> >
> > The two mode (SSE, AVX2) for constant loading can be remove
> >
> > speed seems to be similar to me
> >
> > Martin
>
> LGTM.
>
>
Pushed, Thanks.

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


Re: [FFmpeg-devel] [mov] Fix trampling of ctts during seeks when sidx support is enabled.

2017-11-23 Thread John Stebbins
On 11/22/2017 05:26 PM, Carl Eugen Hoyos wrote:
> 2017-11-23 1:30 GMT+01:00 John Stebbins :
>> On 11/22/2017 02:36 PM, Carl Eugen Hoyos wrote:
>>> 2017-08-24 0:39 GMT+02:00 Dale Curtis :
>>>
 -sc->ctts_data[ctts_count].count= count;
 -sc->ctts_data[ctts_count].duration = duration;
 -ctts_count++;
 +/* Expand entries such that we have a 1-1 mapping with samples. */
 +for (j = 0; j < count; j++)
 +add_ctts_entry(>ctts_data, _count, 
 >ctts_allocated_size, 1, duration);
>>> count is a 32bit value read from the file, so this hunk makes
>>> the demuxer allocate huge amount of memories for some
>>> files.
>>>
>>> Is there an upper limit for count?
>> In practice, if a valid mp4 blows up due to this ctts allocation,
>> it's also going to blow up when AVIndexEntries is allocated
>> for the samples.
>> An invalid mp4 can do anything of course.
> This is about invalid files allocating >1GB.
>
>

Ah, ok.  The practical limit would be the number of samples (sc->sample_count). 
 But you can't be certain this is set
before the ctts box is parsed (the value is determined when parsing stsz box).  
You can be certain it is set before
mov_build_index is called.  So perhaps revert this part and then add code to 
mov_build_index to expand the ctts_data
entries there.  This would solve the invalid mp4 alloc issues while still 
preserving the fix for trampling of ctts.

-- 
John  GnuPG fingerprint: D0EC B3DB C372 D1F1 0B01  83F0 49F1 D7B2 60D4 D0F7




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


Re: [FFmpeg-devel] [PATCH 3/3] avformat/opensrt: add Haivision Open SRT protocol

2017-11-23 Thread Nicolas George
nablet developer (2017-11-20):
> regarding re-using functions from network.c (like ff_network_wait_fd, 
> ff_accept, etc)
> is suggested approach acceptable? is it okay to define such socket_api 
> structure and pass to
> network.c calls?

I do not think so. These functions are very specific to the quirks of
the BSD socket API, and not very well designed at that. I would say to
only use them if you actually have a file descriptor. Hopefully, the
library should provide better base APIs, like operations with a timeout.

Regards,

-- 
  Nicolas George


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


Re: [FFmpeg-devel] [PATCH]lavc/avcodec: Allow libavcodec to overwrite profile and level

2017-11-23 Thread Michael Niedermayer
On Thu, Nov 23, 2017 at 04:01:06PM +0100, Carl Eugen Hoyos wrote:
> Hi!
> 
> The (external) encoders may overwrite level and profile because of
> requested encoding properties, allowing libavcodec to (also) overwrite
> them in the context makes sense (and is already done in some cases
> afaict).
> 
> Please comment, Carl Eugen

If a user needs to generate a file with a specific profile/level
for example because its for broadcast, some specification or a hw
decoder.
How could he after this patch ensure that exactly the needed profile
is used?

[...]

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


[FFmpeg-devel] [PATCH 2/2] avformat/flacenc: add flac_init() and flac_deinit()

2017-11-23 Thread James Almer
Signed-off-by: James Almer 
---
 libavformat/flacenc.c | 58 +--
 1 file changed, 38 insertions(+), 20 deletions(-)

diff --git a/libavformat/flacenc.c b/libavformat/flacenc.c
index 84da54a1df..7c94670f1d 100644
--- a/libavformat/flacenc.c
+++ b/libavformat/flacenc.c
@@ -197,11 +197,11 @@ static int flac_finish_header(struct AVFormatContext *s)
 return 0;
 }
 
-static int flac_write_header(struct AVFormatContext *s)
+static int flac_init(struct AVFormatContext *s)
 {
 AVCodecParameters *par;
 FlacMuxerContext *c = s->priv_data;
-int ret, i;
+int i;
 
 c->audio_stream_idx = -1;
 for (i = 0; i < s->nb_streams; i++) {
@@ -229,17 +229,6 @@ static int flac_write_header(struct AVFormatContext *s)
 av_log(s, AV_LOG_ERROR, "No audio stream present.\n");
 return AVERROR(EINVAL);
 }
-c->waiting_pics = c->nb_pics = s->nb_streams - 1;
-if (c->nb_pics && !(c->pics = av_calloc(c->nb_pics, sizeof(AVPacket
-return AVERROR(ENOMEM);
-
-if (!c->write_header)
-return 0;
-
-ret = ff_flac_write_header(s->pb, par->extradata,
-   par->extradata_size, 0);
-if (ret)
-return ret;
 
 /* add the channel layout tag */
 if (par->channel_layout &&
@@ -258,6 +247,28 @@ static int flac_write_header(struct AVFormatContext *s)
 }
 }
 
+c->waiting_pics = c->nb_pics = s->nb_streams - 1;
+if (c->nb_pics && !(c->pics = av_calloc(c->nb_pics, sizeof(AVPacket
+return AVERROR(ENOMEM);
+
+
+return 0;
+}
+
+static int flac_write_header(struct AVFormatContext *s)
+{
+FlacMuxerContext *c = s->priv_data;
+AVCodecParameters *par = s->streams[c->audio_stream_idx]->codecpar;
+int ret;
+
+if (!c->write_header)
+return 0;
+
+ret = ff_flac_write_header(s->pb, par->extradata,
+   par->extradata_size, 0);
+if (ret)
+return ret;
+
 if (!c->waiting_pics)
 ret = flac_finish_header(s);
 
@@ -313,7 +324,6 @@ static int flac_write_trailer(struct AVFormatContext *s)
 FlacMuxerContext *c = s->priv_data;
 uint8_t *streaminfo = c->streaminfo ? c->streaminfo :
   
s->streams[c->audio_stream_idx]->codecpar->extradata;
-int i;
 
 if (c->waiting_pics) {
 av_log(s, AV_LOG_WARNING, "No packets were sent for some of the "
@@ -321,10 +331,6 @@ static int flac_write_trailer(struct AVFormatContext *s)
 flac_queue_flush(s);
 }
 
-for (i = 0; i < c->nb_pics; i++)
-av_packet_unref(>pics[i]);
-av_freep(>pics);
-
 if (!c->write_header || !streaminfo)
 return 0;
 
@@ -339,11 +345,21 @@ static int flac_write_trailer(struct AVFormatContext *s)
 av_log(s, AV_LOG_WARNING, "unable to rewrite FLAC header.\n");
 }
 
-av_freep(>streaminfo);
-
 return 0;
 }
 
+static void flac_deinit(struct AVFormatContext *s)
+{
+FlacMuxerContext *c = s->priv_data;
+int i;
+
+for (i = 0; i < c->nb_pics; i++)
+av_packet_unref(>pics[i]);
+av_freep(>pics);
+
+av_freep(>streaminfo);
+}
+
 static int flac_write_packet(struct AVFormatContext *s, AVPacket *pkt)
 {
 FlacMuxerContext *c = s->priv_data;
@@ -420,9 +436,11 @@ AVOutputFormat ff_flac_muxer = {
 .extensions= "flac",
 .audio_codec   = AV_CODEC_ID_FLAC,
 .video_codec   = AV_CODEC_ID_PNG,
+.init  = flac_init,
 .write_header  = flac_write_header,
 .write_packet  = flac_write_packet,
 .write_trailer = flac_write_trailer,
+.deinit= flac_deinit,
 .flags = AVFMT_NOTIMESTAMPS,
 .priv_class= _muxer_class,
 };
-- 
2.15.0

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


[FFmpeg-devel] [PATCH] avfilter: add lv2 wrapper filter

2017-11-23 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 configure|   4 +
 doc/filters.texi |  37 
 libavfilter/Makefile |   1 +
 libavfilter/af_lv2.c | 552 +++
 libavfilter/allfilters.c |   1 +
 5 files changed, 595 insertions(+)
 create mode 100644 libavfilter/af_lv2.c

diff --git a/configure b/configure
index 3ec6407fb2..84c965ce4a 100755
--- a/configure
+++ b/configure
@@ -283,6 +283,7 @@ External library support:
   --enable-libzimg enable z.lib, needed for zscale filter [no]
   --enable-libzmq  enable message passing via libzmq [no]
   --enable-libzvbi enable teletext support via libzvbi [no]
+  --enable-lv2 enable LV2 audio filtering [no]
   --disable-lzma   disable lzma [autodetect]
   --enable-decklinkenable Blackmagic DeckLink I/O support [no]
   --enable-libndi_newtek   enable Newteck NDI I/O support [no]
@@ -1631,6 +1632,7 @@ EXTERNAL_LIBRARY_LIST="
 libzimg
 libzmq
 libzvbi
+lv2
 mediacodec
 openal
 opengl
@@ -3229,6 +3231,7 @@ hqdn3d_filter_deps="gpl"
 interlace_filter_deps="gpl"
 kerndeint_filter_deps="gpl"
 ladspa_filter_deps="ladspa libdl"
+lv2_filter_deps="lilv"
 mcdeint_filter_deps="avcodec gpl"
 movie_filter_deps="avcodec avformat"
 mpdecimate_filter_deps="gpl"
@@ -5829,6 +5832,7 @@ enabled gmp   && require gmp gmp.h mpz_export 
-lgmp
 enabled gnutls&& require_pkg_config gnutls gnutls gnutls/gnutls.h 
gnutls_global_init
 enabled jni   && { [ $target_os = "android" ] && check_header 
jni.h && enabled pthreads || die "ERROR: jni not found"; }
 enabled ladspa&& require_header ladspa.h
+enabled lv2   && require_pkg_config lilv lilv-0 
"lilv-0/lilv/lilv.h" lilv_world_new
 enabled libiec61883   && require libiec61883 libiec61883/iec61883.h 
iec61883_cmp_connect -lraw1394 -lavc1394 -lrom1394 -liec61883
 enabled libass&& require_pkg_config libass libass ass/ass.h 
ass_library_init
 enabled libbluray && require_pkg_config libbluray libbluray 
libbluray/bluray.h bd_open
diff --git a/doc/filters.texi b/doc/filters.texi
index 04a8139c6d..d0b053a266 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -3280,6 +3280,43 @@ lowpass=c=LFE
 @end example
 @end itemize
 
+@section LV2
+
+Load a LV2 plugin.
+
+To enable compilation of this filter you need to configure FFmpeg with
+@code{--enable-lv2}.
+
+@table @option
+@item plugin, p
+Specifies the plugin URI.
+
+@item controls, c
+Set the '|' separated list of controls which are zero or more floating point
+values that determine the behavior of the loaded plugin (for example delay,
+threshold or gain).
+If @option{controls} is set to @code{help}, all available controls and
+their valid ranges are printed.
+
+@item sample_rate, s
+Specify the sample rate, default to 44100. Only used if plugin have
+zero inputs.
+
+@item nb_samples, n
+Set the number of samples per channel per each output frame, default
+is 1024. Only used if plugin have zero inputs.
+
+@item duration, d
+Set the minimum duration of the sourced audio. See
+@ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) 
manual,ffmpeg-utils}
+for the accepted syntax.
+Note that the resulting duration may be greater than the specified duration,
+as the generated audio is always cut at the end of a complete frame.
+If not specified, or the expressed duration is negative, the audio is
+supposed to be generated forever.
+Only used if plugin have zero inputs.
+@end table
+
 @section mcompand
 Multiband Compress or expand the audio's dynamic range.
 
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 89737b5ad0..d1924ebfdd 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -101,6 +101,7 @@ OBJS-$(CONFIG_JOIN_FILTER)   += af_join.o
 OBJS-$(CONFIG_LADSPA_FILTER) += af_ladspa.o
 OBJS-$(CONFIG_LOUDNORM_FILTER)   += af_loudnorm.o ebur128.o
 OBJS-$(CONFIG_LOWPASS_FILTER)+= af_biquads.o
+OBJS-$(CONFIG_LV2_FILTER)+= af_lv2.o
 OBJS-$(CONFIG_MCOMPAND_FILTER)   += af_mcompand.o
 OBJS-$(CONFIG_PAN_FILTER)+= af_pan.o
 OBJS-$(CONFIG_REPLAYGAIN_FILTER) += af_replaygain.o
diff --git a/libavfilter/af_lv2.c b/libavfilter/af_lv2.c
new file mode 100644
index 00..bf6c51b07d
--- /dev/null
+++ b/libavfilter/af_lv2.c
@@ -0,0 +1,552 @@
+/*
+ * Copyright (c) 2017 Paul B Mahol
+ * Copyright (c) 2007-2016 David Robillard 
+ *
+ * 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 

Re: [FFmpeg-devel] [PATCH] avfilter: add lv2 wrapper filter

2017-11-23 Thread James Almer
On 11/23/2017 6:16 PM, Paul B Mahol wrote:
> Signed-off-by: Paul B Mahol 
> ---
>  configure|   4 +
>  doc/filters.texi |  37 
>  libavfilter/Makefile |   1 +
>  libavfilter/af_lv2.c | 552 
> +++
>  libavfilter/allfilters.c |   1 +
>  5 files changed, 595 insertions(+)
>  create mode 100644 libavfilter/af_lv2.c
> 
> diff --git a/configure b/configure
> index 3ec6407fb2..84c965ce4a 100755
> --- a/configure
> +++ b/configure
> @@ -283,6 +283,7 @@ External library support:
>--enable-libzimg enable z.lib, needed for zscale filter [no]
>--enable-libzmq  enable message passing via libzmq [no]
>--enable-libzvbi enable teletext support via libzvbi [no]
> +  --enable-lv2 enable LV2 audio filtering [no]
>--disable-lzma   disable lzma [autodetect]
>--enable-decklinkenable Blackmagic DeckLink I/O support [no]
>--enable-libndi_newtek   enable Newteck NDI I/O support [no]
> @@ -1631,6 +1632,7 @@ EXTERNAL_LIBRARY_LIST="
>  libzimg
>  libzmq
>  libzvbi
> +lv2
>  mediacodec
>  openal
>  opengl
> @@ -3229,6 +3231,7 @@ hqdn3d_filter_deps="gpl"
>  interlace_filter_deps="gpl"
>  kerndeint_filter_deps="gpl"
>  ladspa_filter_deps="ladspa libdl"
> +lv2_filter_deps="lilv"

This should be

lv2_filter_deps="lv2"

>  mcdeint_filter_deps="avcodec gpl"
>  movie_filter_deps="avcodec avformat"
>  mpdecimate_filter_deps="gpl"
> @@ -5829,6 +5832,7 @@ enabled gmp   && require gmp gmp.h 
> mpz_export -lgmp
>  enabled gnutls&& require_pkg_config gnutls gnutls 
> gnutls/gnutls.h gnutls_global_init
>  enabled jni   && { [ $target_os = "android" ] && check_header 
> jni.h && enabled pthreads || die "ERROR: jni not found"; }
>  enabled ladspa&& require_header ladspa.h
> +enabled lv2   && require_pkg_config lilv lilv-0 
> "lilv-0/lilv/lilv.h" lilv_world_new

And this should be

require_pkg_config lv2 lilv-0 "lilv-0/lilv/lilv.h" lilv_world_new

>  enabled libiec61883   && require libiec61883 libiec61883/iec61883.h 
> iec61883_cmp_connect -lraw1394 -lavc1394 -lrom1394 -liec61883
>  enabled libass&& require_pkg_config libass libass ass/ass.h 
> ass_library_init
>  enabled libbluray && require_pkg_config libbluray libbluray 
> libbluray/bluray.h bd_open
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 2/2] avcodec/sbrdsp_fixed: Fix integer overflow

2017-11-23 Thread Michael Niedermayer
On Wed, Nov 22, 2017 at 11:59:30PM +0100, Hendrik Leppkes wrote:
> On Wed, Nov 22, 2017 at 11:38 PM, Carl Eugen Hoyos  wrote:
> > 2017-11-22 21:00 GMT+01:00 Michael Niedermayer :
> >
> >> diff --git a/libavcodec/sbrdsp_fixed.c b/libavcodec/sbrdsp_fixed.c
> >> index a0ef6859f1..0db932a105 100644
> >> --- a/libavcodec/sbrdsp_fixed.c
> >> +++ b/libavcodec/sbrdsp_fixed.c
> >> @@ -133,7 +133,7 @@ static av_always_inline SoftFloat 
> >> autocorr_calc(int64_t accu)
> >>
> >>  round = 1U << (nz-1);
> >>  mant = (int)((accu + round) >> nz);
> >> -mant = (mant + 0x40)>>7;
> >> +mant = (mant + 0x40ll)>>7;
> >
> > LL?

I can change it to LL if preferred, i guess ill do that, LL seems more
common in our source


> >
> 
> More correctly, shouldnt this use one of those fancy integer constant
> macros, like INT64_C(0x40)? (I don't actually know if those are
> supposed to work with hex constants, but the fact that they exist
> seems to indicate that LL is not entirely portable)

we use both LL and ll already, so there should be no issue that we
arent already affected by since "forever"

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Democracy is the form of government in which you can choose your dictator


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


[FFmpeg-devel] [PATCH 1/2] lavf/flacenc: support writing attached pictures

2017-11-23 Thread James Almer
From: Rodger Combs 

Signed-off-by: James Almer 
---
Should be good to commit now.

 libavformat/flacenc.c | 286 +++---
 1 file changed, 250 insertions(+), 36 deletions(-)

diff --git a/libavformat/flacenc.c b/libavformat/flacenc.c
index b894f9ef61..84da54a1df 100644
--- a/libavformat/flacenc.c
+++ b/libavformat/flacenc.c
@@ -21,10 +21,13 @@
 
 #include "libavutil/channel_layout.h"
 #include "libavutil/opt.h"
+#include "libavutil/pixdesc.h"
 #include "libavcodec/flac.h"
 #include "avformat.h"
 #include "avio_internal.h"
 #include "flacenc.h"
+#include "id3v2.h"
+#include "internal.h"
 #include "vorbiscomment.h"
 #include "libavcodec/bytestream.h"
 
@@ -33,8 +36,16 @@ typedef struct FlacMuxerContext {
 const AVClass *class;
 int write_header;
 
+int audio_stream_idx;
+AVPacket *pics;
+int nb_pics, waiting_pics;
+/* audio packets are queued here until we get all the attached pictures */
+AVPacketList *queue, *queue_end;
+
 /* updated streaminfo sent by the encoder at the end */
 uint8_t *streaminfo;
+
+unsigned attached_types;
 } FlacMuxerContext;
 
 static int flac_write_block_padding(AVIOContext *pb, unsigned int 
n_padding_bytes,
@@ -74,31 +85,157 @@ static int flac_write_block_comment(AVIOContext *pb, 
AVDictionary **m,
 return 0;
 }
 
-static int flac_write_header(struct AVFormatContext *s)
+static int flac_write_picture(struct AVFormatContext *s, AVPacket *pkt)
 {
-int ret;
-int padding = s->metadata_header_padding;
-AVCodecParameters *par = s->streams[0]->codecpar;
-FlacMuxerContext *c   = s->priv_data;
-
-if (!c->write_header)
+FlacMuxerContext *c = s->priv_data;
+AVIOContext *pb = s->pb;
+const AVPixFmtDescriptor *pixdesc;
+const CodecMime *mime = ff_id3v2_mime_tags;
+AVDictionaryEntry *e;
+const char *mimetype = NULL, *desc = "";
+const AVStream *st = s->streams[pkt->stream_index];
+int i, mimelen, desclen, type = 0;
+
+if (!pkt->data)
 return 0;
 
-if (s->nb_streams > 1) {
-av_log(s, AV_LOG_ERROR, "only one stream is supported\n");
+while (mime->id != AV_CODEC_ID_NONE) {
+if (mime->id == st->codecpar->codec_id) {
+mimetype = mime->str;
+break;
+}
+mime++;
+}
+if (!mimetype) {
+av_log(s, AV_LOG_ERROR, "No mimetype is known for stream %d, cannot "
+   "write an attached picture.\n", st->index);
+return AVERROR(EINVAL);
+}
+mimelen = strlen(mimetype);
+
+/* get the picture type */
+e = av_dict_get(st->metadata, "comment", NULL, 0);
+for (i = 0; e && i < FF_ARRAY_ELEMS(ff_id3v2_picture_types); i++) {
+if (!av_strcasecmp(e->value, ff_id3v2_picture_types[i])) {
+type = i;
+break;
+}
+}
+
+if ((c->attached_types & (1 << type)) & 0x6) {
+av_log(s, AV_LOG_ERROR, "Duplicate attachment for type '%s'\n", 
ff_id3v2_picture_types[type]);
 return AVERROR(EINVAL);
 }
-if (par->codec_id != AV_CODEC_ID_FLAC) {
-av_log(s, AV_LOG_ERROR, "unsupported codec\n");
+
+if (type == 1 && (st->codecpar->codec_id != AV_CODEC_ID_PNG ||
+  st->codecpar->width != 32 ||
+  st->codecpar->height != 32)) {
+av_log(s, AV_LOG_ERROR, "File icon attachment must be a 32x32 PNG");
 return AVERROR(EINVAL);
 }
 
+c->attached_types |= (1 << type);
+
+/* get the description */
+if ((e = av_dict_get(st->metadata, "title", NULL, 0)))
+desc = e->value;
+desclen = strlen(desc);
+
+avio_w8(pb, 0x06);
+avio_wb24(pb, 4 + 4 + mimelen + 4 + desclen + 4 + 4 + 4 + 4 + 4 + 
pkt->size);
+
+avio_wb32(pb, type);
+
+avio_wb32(pb, mimelen);
+avio_write(pb, mimetype, mimelen);
+
+avio_wb32(pb, desclen);
+avio_write(pb, desc, desclen);
+
+avio_wb32(pb, st->codecpar->width);
+avio_wb32(pb, st->codecpar->height);
+if ((pixdesc = av_pix_fmt_desc_get(st->codecpar->format)))
+avio_wb32(pb, av_get_bits_per_pixel(pixdesc));
+else
+avio_wb32(pb, 0);
+avio_wb32(pb, 0);
+
+avio_wb32(pb, pkt->size);
+avio_write(pb, pkt->data, pkt->size);
+return 0;
+}
+
+static int flac_finish_header(struct AVFormatContext *s)
+{
+FlacMuxerContext *c = s->priv_data;
+int i, ret, padding = s->metadata_header_padding;
 if (padding < 0)
 padding = 8192;
 /* The FLAC specification states that 24 bits are used to represent the
  * size of a metadata block so we must clip this value to 2^24-1. */
 padding = av_clip_uintp2(padding, 24);
 
+for (i = 0; i < c->nb_pics; i++) {
+ret = flac_write_picture(s, >pics[i]);
+av_packet_unref(>pics[i]);
+if (ret)
+return ret;
+}
+
+ret = flac_write_block_comment(s->pb, >metadata, !padding,
+   

[FFmpeg-devel] [PATCH] ffmpeg libopusdec: fix missing include file in libopusdec.c

2017-11-23 Thread Mikulas Patocka
This patch fixes the following error when compiling mplayer with libopus.

libavcodec/libopusdec.c: In function 'libopus_decode_init':
libavcodec/libopusdec.c:130:27: error: implicit declaration of function 
'ff_exp10'; did you mean 'ff_exp2fi'? [-Werror=implicit-function-declaration]
 double gain_lin = ff_exp10(gain_db / (20.0 * 256));
   ^~~~
   ff_exp2fi

Signed-off-by: Mikulas Patocka 

---
 libavcodec/libopusdec.c |1 +
 1 file changed, 1 insertion(+)

Index: ffmpeg/libavcodec/libopusdec.c
===
--- ffmpeg.orig/libavcodec/libopusdec.c 2017-11-19 23:44:55.0 +0100
+++ ffmpeg/libavcodec/libopusdec.c  2017-11-23 03:54:43.0 +0100
@@ -24,6 +24,7 @@
 
 #include "libavutil/internal.h"
 #include "libavutil/intreadwrite.h"
+#include "libavutil/ffmath.h"
 
 #include "avcodec.h"
 #include "internal.h"
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] hls demuxer: add option to defer parsing of variants

2017-11-23 Thread Rainer Hochecker
---
 doc/demuxers.texi |   5 +
 libavformat/hls.c | 299 --
 2 files changed, 204 insertions(+), 100 deletions(-)

diff --git a/doc/demuxers.texi b/doc/demuxers.texi
index 73dc0feec1..634b122e10 100644
--- a/doc/demuxers.texi
+++ b/doc/demuxers.texi
@@ -316,6 +316,11 @@ segment index to start live streams at (negative values 
are from the end).
 @item max_reload
 Maximum number of times a insufficient list is attempted to be reloaded.
 Default value is 1000.
+
+@item load_all_variants
+If 0, only the first variant/playlist is loaded on open. All other variants
+get disabled and can be enabled by setting discard option in program.
+Default value is 1.
 @end table
 
 @section image2
diff --git a/libavformat/hls.c b/libavformat/hls.c
index 786934af03..c55f5ea439 100644
--- a/libavformat/hls.c
+++ b/libavformat/hls.c
@@ -112,6 +112,7 @@ struct playlist {
 int n_segments;
 struct segment **segments;
 int needed, cur_needed;
+int parsed;
 int cur_seq_no;
 int64_t cur_seg_offset;
 int64_t last_load_time;
@@ -206,6 +207,7 @@ typedef struct HLSContext {
 int strict_std_compliance;
 char *allowed_extensions;
 int max_reload;
+int load_all_variants;
 } HLSContext;
 
 static int read_chomp_line(AVIOContext *s, char *buf, int maxlen)
@@ -314,6 +316,9 @@ static struct playlist *new_playlist(HLSContext *c, const 
char *url,
 pls->is_id3_timestamped = -1;
 pls->id3_mpegts_timestamp = AV_NOPTS_VALUE;
 
+pls->index = c->n_playlists;
+pls->parsed = 0;
+pls->needed = 0;
 dynarray_add(>playlists, >n_playlists, pls);
 return pls;
 }
@@ -721,6 +726,7 @@ static int parse_playlist(HLSContext *c, const char *url,
 free_segment_list(pls);
 pls->finished = 0;
 pls->type = PLS_TYPE_UNSPECIFIED;
+pls->parsed = 1;
 }
 while (!avio_feof(in)) {
 read_chomp_line(in, line, sizeof(line));
@@ -1377,23 +1383,41 @@ reload:
 static void add_renditions_to_variant(HLSContext *c, struct variant *var,
   enum AVMediaType type, const char 
*group_id)
 {
-int i;
+int i, j;
+int found;
 
 for (i = 0; i < c->n_renditions; i++) {
 struct rendition *rend = c->renditions[i];
 
 if (rend->type == type && !strcmp(rend->group_id, group_id)) {
 
-if (rend->playlist)
+if (rend->playlist) {
 /* rendition is an external playlist
  * => add the playlist to the variant */
-dynarray_add(>playlists, >n_playlists, 
rend->playlist);
-else
+found = 0;
+for (j = 0; j < var->n_playlists; j++) {
+if (var->playlists[j] == rend->playlist) {
+found = 1;
+break;
+}
+}
+if (!found)
+dynarray_add(>playlists, >n_playlists, 
rend->playlist);
+} else {
 /* rendition is part of the variant main Media Playlist
  * => add the rendition to the main Media Playlist */
-dynarray_add(>playlists[0]->renditions,
- >playlists[0]->n_renditions,
- rend);
+found = 0;
+for (j = 0; j < var->playlists[0]->n_renditions; j++) {
+if (var->playlists[0]->renditions[j] == rend) {
+found = 1;
+break;
+}
+}
+if (!found)
+dynarray_add(>playlists[0]->renditions,
+ >playlists[0]->n_renditions,
+ rend);
+}
 }
 }
 }
@@ -1631,6 +1655,122 @@ static int hls_close(AVFormatContext *s)
 return 0;
 }
 
+static int init_playlist(HLSContext *c, struct playlist *pls)
+{
+AVInputFormat *in_fmt = NULL;
+int highest_cur_seq_no = 0;
+int ret;
+int i;
+
+if (!(pls->ctx = avformat_alloc_context())) {
+return AVERROR(ENOMEM);
+}
+
+if (pls->n_segments == 0)
+return 0;
+
+pls->needed = 1;
+pls->parent = c->ctx;
+
+/*
+ * If this is a live stream and this playlist looks like it is one segment
+ * behind, try to sync it up so that every substream starts at the same
+ * time position (so e.g. avformat_find_stream_info() will see packets from
+ * all active streams within the first few seconds). This is not very 
generic,
+ * though, as the sequence numbers are technically independent.
+ */
+highest_cur_seq_no = 0;
+for (i = 0; i < c->n_playlists; i++) {
+struct playlist *pls = c->playlists[i];
+if (!pls->parsed)
+continue;
+if (pls->cur_seq_no > highest_cur_seq_no)
+highest_cur_seq_no = pls->cur_seq_no;
+}
+if (!pls->finished && 

[FFmpeg-devel] Adding option B does not work

2017-11-23 Thread shailender Jain
Hello,


I am trying to ensure that a specific number of B Frames should be used by 
FFMPEG. I am running the following command


ffmpeg -i Rediff.mp4  -vstats_file stats.txt -c:v libx264 -bf 16  -crf 28 
Rediff2.mp4


However, when i look at the stats.txt, i cannot see 16 B-Frames. Is there any 
way this can be done? I want to find a way by which i can enforce if a frame 
will be B-Frame or P-Frame or I-Frame. Is this feasible? If not, then please 
help me identify  the source code where i can update the code


Thanks

Shailender Jain


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


Re: [FFmpeg-devel] [PATCH] avfilter: add normalize filter

2017-11-23 Thread Richard Ling
On Nov 21, 2017 10:32 PM, "Moritz Barsnick"  wrote:
>
> Nice. I personally appreciate your code comments, as I'm no big filter
> author (yet).

I've never made any contribution to ffmpeg before, so I'm almost certainly
a bad example to follow :-P

But I do like code to be well commented.

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


[FFmpeg-devel] (no subject)

2017-11-23 Thread Rainer Hochecker

Currently all variants/playlists get parsed on open. For a master playlist
with many different bitrates this can take several seconds. With the new
option set to 0 only the first variant of a master playlist is opened. Others
can be activated later by setting discard option on a program. Default value
of option preserves current behaviour.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] ffmpeg fft: fix broken opus on 3dnow

2017-11-23 Thread Mikulas Patocka
The commit b7c16a3f2c4921f613319938b8ee0e3d6fa83e8d ("x86: fft: Port to
cpuflags") breaks the opus decoder in ffmpeg when compiling for 3dnow. The
output is audible, but there's a lot of noise.

This could be tested by disabling sse and compiling ffmpeg on a processor
with 3dnow support:
CC='gcc -m32' ./configure --disable-sse --disable-sse2 --disable-sse3

The reason for the breakage is that the commit unintentionally changed the 
INTERL macro so that it is empty when compiling for 3dnow. This patch 
fixes it.

Signed-off-by: Mikulas Patocka 

---
 libavcodec/x86/fft.asm |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: ffmpeg/libavcodec/x86/fft.asm
===
--- mplayer.orig/libavcodec/x86/fft.asm
+++ mplayer/libavcodec/x86/fft.asm
@@ -199,7 +199,7 @@ SECTION .text
 vextractf128  %4 %+ H(%5), %3, 0
 vextractf128   %4(%5 + 1), %2, 1
 vextractf128  %4 %+ H(%5 + 1), %3, 1
-%elif cpuflag(sse)
+%elif cpuflag(sse) || cpuflag(3dnow)
 mova %3, %2
 unpcklps %2, %1
 unpckhps %3, %1
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] ffmpeg libopusdec: fix missing include file in libopusdec.c

2017-11-23 Thread Hendrik Leppkes
On Thu, Nov 23, 2017 at 8:22 PM, Mikulas Patocka  wrote:
> This patch fixes the following error when compiling mplayer with libopus.
>
> libavcodec/libopusdec.c: In function 'libopus_decode_init':
> libavcodec/libopusdec.c:130:27: error: implicit declaration of function 
> 'ff_exp10'; did you mean 'ff_exp2fi'? [-Werror=implicit-function-declaration]
>  double gain_lin = ff_exp10(gain_db / (20.0 * 256));
>^~~~
>ff_exp2fi
>

Can this issue be reproduced with ffmpeg alone, without mplayer?

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


Re: [FFmpeg-devel] [PATCH 1/3] avformat/hlsenc:addition of #EXT-X-MEDIA tag and AUDIO attribute

2017-11-23 Thread Steven Liu
2017-11-24 1:15 GMT+08:00 Moritz Barsnick :
> On Thu, Nov 23, 2017 at 11:47:30 +0100, Carl Eugen Hoyos wrote:
>> (Isn't there a patch to fix the variable name?)
> Still pending:
> https://patchwork.ffmpeg.org/patch/6257/

patchset pushed



Thanks
> ___
> 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 v3] avformat/hlsenc: Added option to add EXT-X-INDEPENDENT-SEGMENTS tag

2017-11-23 Thread Steven Liu
2017-11-23 19:33 GMT+08:00 Karthick J :
> ---
>  doc/muxers.texi  |  4 
>  libavformat/hlsenc.c | 17 +
>  2 files changed, 21 insertions(+)
>
> diff --git a/doc/muxers.texi b/doc/muxers.texi
> index 0bb8ad2..9d9ca31 100644
> --- a/doc/muxers.texi
> +++ b/doc/muxers.texi
> @@ -737,6 +737,10 @@ The file specified by @code{hls_key_info_file} will be 
> checked periodically and
>  detect updates to the encryption info. Be sure to replace this file 
> atomically,
>  including the file containing the AES encryption key.
>
> +@item independent_segments
> +Add the @code{#EXT-X-INDEPENDENT-SEGMENTS} to playlists that has video 
> segments
> +and when all the segments of that playlist are guaranteed to start with a 
> Key frame.
> +
>  @item split_by_time
>  Allow segments to start on frames other than keyframes. This improves
>  behavior on some players when the time between keyframes is inconsistent,
> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> index 3c47ced..3010714 100644
> --- a/libavformat/hlsenc.c
> +++ b/libavformat/hlsenc.c
> @@ -88,6 +88,7 @@ typedef enum HLSFlags {
>  HLS_SECOND_LEVEL_SEGMENT_SIZE = (1 << 10), // include segment size 
> (bytes) in segment filenames when use_localtime  e.g.: %%014s
>  HLS_TEMP_FILE = (1 << 11),
>  HLS_PERIODIC_REKEY = (1 << 12),
> +HLS_INDEPENDENT_SEGMENTS = (1 << 13),
>  } HLSFlags;
>
>  typedef enum {
> @@ -1191,6 +1192,10 @@ static int hls_window(AVFormatContext *s, int last, 
> VariantStream *vs)
>  sequence = 0;
>  }
>
> +if (hls->flags & HLS_INDEPENDENT_SEGMENTS) {
> +hls->version = 6;
> +}
> +
>  if (hls->segment_type == SEGMENT_TYPE_FMP4) {
>  hls->version = 7;
>  }
> @@ -1220,6 +1225,9 @@ static int hls_window(AVFormatContext *s, int last, 
> VariantStream *vs)
>  avio_printf(out, "#EXT-X-DISCONTINUITY\n");
>  vs->discontinuity_set = 1;
>  }
> +if (vs->has_video && (hls->flags & HLS_INDEPENDENT_SEGMENTS)) {
> +avio_printf(out, "#EXT-X-INDEPENDENT-SEGMENTS\n");
> +}
>  for (en = vs->segments; en; en = en->next) {
>  if ((hls->encrypt || hls->key_info_file) && (!key_uri || 
> strcmp(en->key_uri, key_uri) ||
>  av_strcasecmp(en->iv_string, 
> iv_string))) {
> @@ -1732,6 +1740,14 @@ static int hls_write_header(AVFormatContext *s)
>  vs->start_pts  = AV_NOPTS_VALUE;
>  vs->current_segment_final_filename_fmt[0] = '\0';
>
> +if (hls->flags & HLS_SPLIT_BY_TIME && hls->flags & 
> HLS_INDEPENDENT_SEGMENTS) {
> +// Independent segments cannot be guaranteed when splitting by time
> +hls->flags &= ~HLS_INDEPENDENT_SEGMENTS;
> +av_log(s, AV_LOG_WARNING,
> +   "'split_by_time' and 'independent_segments' cannot be enabled 
> together. "
> +   "Disabling 'independent_segments' flag\n");
> +}
> +
>  if (hls->flags & HLS_PROGRAM_DATE_TIME) {
>  time_t now0;
>  time();
> @@ -2323,6 +2339,7 @@ static const AVOption options[] = {
>  {"second_level_segment_duration", "include segment duration in segment 
> filenames when use_localtime", 0, AV_OPT_TYPE_CONST, {.i64 = 
> HLS_SECOND_LEVEL_SEGMENT_DURATION }, 0, UINT_MAX,   E, "flags"},
>  {"second_level_segment_size", "include segment size in segment filenames 
> when use_localtime", 0, AV_OPT_TYPE_CONST, {.i64 = 
> HLS_SECOND_LEVEL_SEGMENT_SIZE }, 0, UINT_MAX,   E, "flags"},
>  {"periodic_rekey", "reload keyinfo file periodically for re-keying", 0, 
> AV_OPT_TYPE_CONST, {.i64 = HLS_PERIODIC_REKEY }, 0, UINT_MAX,   E, "flags"},
> +{"independent_segments", "add EXT-X-INDEPENDENT-SEGMENTS, whenever 
> applicable", 0, AV_OPT_TYPE_CONST, { .i64 = HLS_INDEPENDENT_SEGMENTS }, 0, 
> UINT_MAX, E, "flags"},
>  {"use_localtime", "set filename expansion with strftime at segment 
> creation", OFFSET(use_localtime), AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, E },
>  {"use_localtime_mkdir", "create last directory component in 
> strftime-generated filename", OFFSET(use_localtime_mkdir), AV_OPT_TYPE_BOOL, 
> {.i64 = 0 }, 0, 1, E },
>  {"hls_playlist_type", "set the HLS playlist type", OFFSET(pl_type), 
> AV_OPT_TYPE_INT, {.i64 = PLAYLIST_TYPE_NONE }, 0, PLAYLIST_TYPE_NB-1, E, 
> "pl_type" },
> --
> 1.9.1
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

Pushed


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


Re: [FFmpeg-devel] [PATCH 2/3] udp: Check the port number provided by av_url_split as per docs

2017-11-23 Thread Michael Niedermayer
On Wed, Nov 22, 2017 at 03:28:41PM +, Derek Buitenhuis wrote:
> Signed-off-by: Derek Buitenhuis 
> ---
>  libavformat/udp.c | 8 
>  1 file changed, 8 insertions(+)
> 
> diff --git a/libavformat/udp.c b/libavformat/udp.c
> index 0dde035..7bbd282 100644
> --- a/libavformat/udp.c
> +++ b/libavformat/udp.c
> @@ -443,6 +443,10 @@ int ff_udp_set_remote_url(URLContext *h, const char *uri)
>  const char *p;
>  
>  av_url_split(NULL, 0, NULL, 0, hostname, sizeof(hostname), , NULL, 
> 0, uri);
> +if (port < 0) {
> +av_log(s, AV_LOG_ERROR, "No valid port number found in URL.\n");
> +return AVERROR(EINVAL);
> +}
>  
>  /* set the destination address */
>  s->dest_addr_len = udp_set_url(h, >dest_addr, hostname, port);
> @@ -798,6 +802,10 @@ static int udp_open(URLContext *h, const char *uri, int 
> flags)
>  
>  /* fill the dest addr */
>  av_url_split(NULL, 0, NULL, 0, hostname, sizeof(hostname), , NULL, 
> 0, uri);
> +if (port < 0) {
> +av_log(h, AV_LOG_ERROR, "Missing or invalid port provided in 
> URL.\n");
> +return AVERROR(EINVAL);
> +}
>  
>  /* XXX: fix av_url_split */
>  if (hostname[0] == '\0' || hostname[0] == '?') {
> -- 

this seems to break rtp / rtsp

ive traced it to
ff_rtsp_make_setup_request() calling ffurl_open_whitelist() without
a port

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

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


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


Re: [FFmpeg-devel] [PATCH] ffmpeg libopusdec: fix missing include file in libopusdec.c

2017-11-23 Thread Carl Eugen Hoyos
2017-11-23 23:41 GMT+01:00 Hendrik Leppkes :
> On Thu, Nov 23, 2017 at 8:22 PM, Mikulas Patocka  
> wrote:
>> This patch fixes the following error when compiling mplayer with libopus.
>>
>> libavcodec/libopusdec.c: In function 'libopus_decode_init':
>> libavcodec/libopusdec.c:130:27: error: implicit declaration of function 
>> 'ff_exp10'; did you mean 'ff_exp2fi'?
>>  double gain_lin = ff_exp10(gain_db / (20.0 * 256));
>>^~~~
>>ff_exp2fi
>
> Can this issue be reproduced with ffmpeg alone, without mplayer?

Yes, regression since 48cd3d23 on affected systems.

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


Re: [FFmpeg-devel] [PATCH 1/2] lavf/flacenc: support writing attached pictures

2017-11-23 Thread Carl Eugen Hoyos
2017-11-23 23:08 GMT+01:00 James Almer :

> Should be good to commit now.

Please mention ticket #4442.

Thank you, Carl Eugen
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] hls demuxer: add option to defer parsing of variants

2017-11-23 Thread Carl Eugen Hoyos
2017-11-23 23:20 GMT+01:00 Rainer Hochecker :

> +@item load_all_variants
> +If 0, only the first variant/playlist is loaded on open. All other variants
> +get disabled and can be enabled by setting discard option in program.
> +Default value is 1.

Shouldn't this be:
0 (or -1) for all streams (default), n>0 (or > -1) for the nth stream.
I guess it is at least possible that the user knows in advance which
streams the source will offer.
No?

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


Re: [FFmpeg-devel] [PATCH]lavc/avcodec: Allow libavcodec to overwrite profile and level

2017-11-23 Thread Carl Eugen Hoyos
2017-11-23 22:58 GMT+01:00 Michael Niedermayer :
> On Thu, Nov 23, 2017 at 04:01:06PM +0100, Carl Eugen Hoyos wrote:
>> Hi!
>>
>> The (external) encoders may overwrite level and profile because of
>> requested encoding properties, allowing libavcodec to (also) overwrite
>> them in the context makes sense (and is already done in some cases
>> afaict).
>>
>> Please comment, Carl Eugen
>
> If a user needs to generate a file with a specific profile/level
> for example because its for broadcast, some specification or a hw
> decoder.
> How could he after this patch ensure that exactly the needed profile
> is used?

Afair, x264 does change profile and / or level depending on properties
set by the user. Currently there is no way for the libavcodec user to
know that libx264 changed something.
With this change the user can know that he does not get the
requested values.

Or am I wrong and libx264 never overwrites requested values
for level and / or profile?

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


[FFmpeg-devel] [PATCHv2] avformat/mxfdec: fix last packet timestamps

2017-11-23 Thread Marton Balint
The current edit unit cannot be reliably determined for the last packet of a
video stream, because we can't query the start offset of the next edit unit
from the index. This caused missing timestamps for the last video packet.

Therefore from now on, we allow setting the PTS even if we are not sure of the
current edit unit if mxf_set_current_edit_unit returned a specific failure, and
the assumed current edit unit is the last.

Fixes last packet timestamp of:
ffprobe -fflags nofillin -show_packets tests/data/lavf/lavf.mxf -select_streams 
v

Signed-off-by: Marton Balint 
---
 libavformat/mxfdec.c|  4 ++--
 tests/ref/seek/lavf-mxf_d10 | 12 ++--
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
index 118e3e40b4..3b8d423906 100644
--- a/libavformat/mxfdec.c
+++ b/libavformat/mxfdec.c
@@ -2976,7 +2976,7 @@ static int64_t mxf_set_current_edit_unit(MXFContext *mxf, 
int64_t current_offset
 /* find mxf->current_edit_unit so that the next edit unit starts ahead of 
current_offset */
 while (mxf->current_edit_unit >= 0) {
 if (mxf_edit_unit_absolute_offset(mxf, t, mxf->current_edit_unit + 1, 
NULL, _ofs, 0) < 0)
-return -1;
+return -2;
 
 if (next_ofs <= last_ofs) {
 /* large next_ofs didn't change or current_edit_unit wrapped
@@ -3065,7 +3065,7 @@ static int mxf_set_pts(MXFContext *mxf, AVStream *st, 
AVPacket *pkt, int64_t nex
 AVCodecParameters *par = st->codecpar;
 MXFTrack *track = st->priv_data;
 
-if (par->codec_type == AVMEDIA_TYPE_VIDEO && next_ofs >= 0) {
+if (par->codec_type == AVMEDIA_TYPE_VIDEO && (next_ofs >= 0 || next_ofs == 
-2 && st->duration == mxf->current_edit_unit + 1)) {
 /* mxf->current_edit_unit good - see if we have an
  * index table to derive timestamps from */
 MXFIndexTable *t = >index_tables[0];
diff --git a/tests/ref/seek/lavf-mxf_d10 b/tests/ref/seek/lavf-mxf_d10
index 17cca29c03..5a682f0927 100644
--- a/tests/ref/seek/lavf-mxf_d10
+++ b/tests/ref/seek/lavf-mxf_d10
@@ -8,9 +8,9 @@ ret: 0 st: 0 flags:1 dts: 0.80 pts: 0.80 
pos:4265984 size:15
 ret: 0 st: 0 flags:1  ts:-0.32
 ret: 0 st: 0 flags:1 dts: 0.00 pts: 0.00 pos:   6144 
size:15
 ret: 0 st: 1 flags:0  ts: 2.576667
-ret: 0 st: 0 flags:1 dts: 0.00 pts: 0.00 pos:5117952 
size:15
+ret: 0 st: 0 flags:1 dts: 0.96 pts: 0.96 pos:5117952 
size:15
 ret: 0 st: 1 flags:1  ts: 1.470833
-ret: 0 st: 0 flags:1 dts: 0.00 pts: 0.00 pos:5117952 
size:15
+ret: 0 st: 0 flags:1 dts: 0.96 pts: 0.96 pos:5117952 
size:15
 ret: 0 st:-1 flags:0  ts: 0.365002
 ret: 0 st: 0 flags:1 dts: 0.36 pts: 0.36 pos:1923072 
size:15
 ret: 0 st:-1 flags:1  ts:-0.740831
@@ -22,7 +22,7 @@ ret: 0 st: 0 flags:1 dts: 0.96 pts: 0.96 
pos:5117952 size:15
 ret: 0 st: 1 flags:0  ts:-0.058333
 ret: 0 st: 0 flags:1 dts: 0.00 pts: 0.00 pos:   6144 
size:15
 ret: 0 st: 1 flags:1  ts: 2.835833
-ret: 0 st: 0 flags:1 dts: 0.00 pts: 0.00 pos:5117952 
size:15
+ret: 0 st: 0 flags:1 dts: 0.96 pts: 0.96 pos:5117952 
size:15
 ret: 0 st:-1 flags:0  ts: 1.730004
 ret: 0 st: 0 flags:1 dts: 0.96 pts: 0.96 pos:5117952 
size:15
 ret: 0 st:-1 flags:1  ts: 0.624171
@@ -32,7 +32,7 @@ ret: 0 st: 0 flags:1 dts: 0.00 pts: 0.00 pos: 
  6144 size:15
 ret: 0 st: 0 flags:1  ts: 2.40
 ret: 0 st: 0 flags:1 dts: 0.96 pts: 0.96 pos:5117952 
size:15
 ret: 0 st: 1 flags:0  ts: 1.306667
-ret: 0 st: 0 flags:1 dts: 0.00 pts: 0.00 pos:5117952 
size:15
+ret: 0 st: 0 flags:1 dts: 0.96 pts: 0.96 pos:5117952 
size:15
 ret: 0 st: 1 flags:1  ts: 0.200833
 ret: 0 st: 0 flags:1 dts: 0.20 pts: 0.20 pos:1071104 
size:15
 ret: 0 st:-1 flags:0  ts:-0.904994
@@ -44,9 +44,9 @@ ret: 0 st: 0 flags:1 dts: 0.88 pts: 0.88 
pos:4691968 size:15
 ret: 0 st: 0 flags:1  ts:-0.24
 ret: 0 st: 0 flags:1 dts: 0.00 pts: 0.00 pos:   6144 
size:15
 ret: 0 st: 1 flags:0  ts: 2.671667
-ret: 0 st: 0 flags:1 dts: 0.00 pts: 0.00 pos:5117952 
size:15
+ret: 0 st: 0 flags:1 dts: 0.96 pts: 0.96 pos:5117952 
size:15
 ret: 0 st: 1 flags:1  ts: 1.565833
-ret: 0 st: 0 flags:1 dts: 0.00 pts: 0.00 pos:5117952 
size:15
+ret: 0 st: 0 flags:1 dts: 0.96 pts: 0.96 pos:5117952 
size:15
 ret: 0 st:-1 flags:0  ts: 0.460008
 ret: 0 st: 0 flags:1 dts: 0.48 pts: 0.48 pos:2562048 
size:15
 ret: 0 st:-1 flags:1  ts:-0.645825
-- 
2.13.6


Re: [FFmpeg-devel] [mov] Fix trampling of ctts during seeks when sidx support is enabled.

2017-11-23 Thread Carl Eugen Hoyos
2017-11-23 19:45 GMT+01:00 John Stebbins :
> On 11/22/2017 05:26 PM, Carl Eugen Hoyos wrote:
>> 2017-11-23 1:30 GMT+01:00 John Stebbins :
>>> On 11/22/2017 02:36 PM, Carl Eugen Hoyos wrote:
 2017-08-24 0:39 GMT+02:00 Dale Curtis :

> -sc->ctts_data[ctts_count].count= count;
> -sc->ctts_data[ctts_count].duration = duration;
> -ctts_count++;
> +/* Expand entries such that we have a 1-1 mapping with samples. 
> */
> +for (j = 0; j < count; j++)
> +add_ctts_entry(>ctts_data, _count, 
> >ctts_allocated_size, 1, duration);
 count is a 32bit value read from the file, so this hunk makes
 the demuxer allocate huge amount of memories for some
 files.

 Is there an upper limit for count?
>>> In practice, if a valid mp4 blows up due to this ctts allocation,
>>> it's also going to blow up when AVIndexEntries is allocated
>>> for the samples.
>>> An invalid mp4 can do anything of course.
>> This is about invalid files allocating >1GB.
>
> Ah, ok.  The practical limit would be the number of samples 
> (sc->sample_count).
> But you can't be certain this is set before the ctts box is parsed (the value 
> is
> determined when parsing stsz box).  You can be certain it is set before
> mov_build_index is called.  So perhaps revert this part and then add code to
> mov_build_index to expand the ctts_data entries there.  This would solve the
> invalid mp4 alloc issues while still preserving the fix for trampling of ctts.

@Dale:
Could you do that?

Thank you, Carl Eugen
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 08/13] ffmpeg: Use codec hardware config to configure hwaccels

2017-11-23 Thread Mark Thompson
On 22/11/17 04:28, Philip Langdale wrote:
> On Sat, 18 Nov 2017 18:47:08 +
> Mark Thompson  wrote:
> 
>> Removes specific support for all hwaccels supported by the generic
>> code (DXVA2, D3D11VA, NVDEC, VAAPI, VDPAU and videotoolbox).
>> ---
>>  fftools/ffmpeg.c |  77 +++-
>>  fftools/ffmpeg.h |  10 +--
>>  fftools/ffmpeg_hw.c  | 244
>> +++
>> fftools/ffmpeg_opt.c |  55 ++-- 4 files changed, 250
>> insertions(+), 136 deletions(-)
>>
>> diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
>> index babd85f7bc..acff815e74 100644
>> --- a/fftools/ffmpeg.c
>> +++ b/fftools/ffmpeg.c
>> @@ -2782,45 +2782,77 @@ fail:
>>  av_freep();
>>  }
>>  
>> -static const HWAccel *get_hwaccel(enum AVPixelFormat pix_fmt, enum
>> HWAccelID selected_hwaccel_id) -{
>> -int i;
>> -for (i = 0; hwaccels[i].name; i++)
>> -if (hwaccels[i].pix_fmt == pix_fmt &&
>> -(!selected_hwaccel_id || selected_hwaccel_id ==
>> HWACCEL_AUTO || hwaccels[i].id == selected_hwaccel_id))
>> -return [i];
>> -return NULL;
>> -}
>> -
>>  static enum AVPixelFormat get_format(AVCodecContext *s, const enum
>> AVPixelFormat *pix_fmts) {
>>  InputStream *ist = s->opaque;
>>  const enum AVPixelFormat *p;
>>  int ret;
>>  
>> -for (p = pix_fmts; *p != -1; p++) {
>> +for (p = pix_fmts; *p != AV_PIX_FMT_NONE; p++) {
>>  const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(*p);
>> -const HWAccel *hwaccel;
>> +const AVCodecHWConfig  *config = NULL;
>> +int i;
>>  
>>  if (!(desc->flags & AV_PIX_FMT_FLAG_HWACCEL))
>>  break;
>>  
>> -hwaccel = get_hwaccel(*p, ist->hwaccel_id);
>> -if (!hwaccel ||
>> -(ist->active_hwaccel_id && ist->active_hwaccel_id !=
>> hwaccel->id) ||
>> -(ist->hwaccel_id != HWACCEL_AUTO && ist->hwaccel_id !=
>> hwaccel->id))
>> -continue;
>> +if (ist->hwaccel_id == HWACCEL_GENERIC ||
>> +ist->hwaccel_id == HWACCEL_AUTO) {
>> +for (i = 0;; i++) {
>> +config = avcodec_get_hw_config(s->codec, i);
>> +if (!config)
>> +break;
>> +if (!(config->methods &
>> +  AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX))
>> +continue;
> 
> Just to be explicit, only METHOD_HW_DEVICE_CTX hwaccels can be
> generically initialized, so that's why you exclude any other method?

Correct.  METHOD_INTERNAL can work without any of this stuff, while the other 
two require further specific setup which we don't deal with here (can be done 
via the old API-specific mechanism, as it is for CUVID and libmfx).

>> +if (config->pix_fmt == *p)
>> +break;
>> +}
>> +}
>> +if (config) {
>> +if (config->device_type != ist->hwaccel_device_type) {
>> +// Different hwaccel offered, ignore.
>> +continue;
>> +}
>>  
>> -ret = hwaccel->init(s);
>> -if (ret < 0) {
>> -if (ist->hwaccel_id == hwaccel->id) {
>> +ret = hwaccel_decode_init(s);
>> +if (ret < 0) {
>> +if (ist->hwaccel_id == HWACCEL_GENERIC) {
>> +av_log(NULL, AV_LOG_FATAL,
>> +   "%s hwaccel requested for input stream
>> #%d:%d, "
>> +   "but cannot be initialized.\n",
>> +
>> av_hwdevice_get_type_name(config->device_type),
>> +   ist->file_index, ist->st->index);
>> +return AV_PIX_FMT_NONE;
>> +}
>> +continue;
>> +}
>> +} else {
>> +const HWAccel *hwaccel = NULL;
>> +int i;
>> +for (i = 0; hwaccels[i].name; i++) {
>> +if (hwaccels[i].pix_fmt == *p) {
>> +hwaccel = [i];
>> +break;
> 
> This can also overrun the NULL terminator right? Or are we lucky
> because 'name' is at offset zero inside the struct and there's no
> dereference taking place.
> 
> I see this pattern has been used previously so it obviously works out.

I don't see a problem?  If hwaccels[i].name isn't set then we are looking at 
the sentinel entry in the list and the loop ends.

>> +}
>> +}
>> +if (!hwaccel) {
>> +// No hwaccel supporting this pixfmt.
>> +continue;
>> +}
>> +if (hwaccel->id != ist->hwaccel_id) {
>> +// Does not match requested hwaccel.
>> +continue;
>> +}
>> +
>> +ret = hwaccel->init(s);
>> +if (ret < 0) {
>>  av_log(NULL, AV_LOG_FATAL,
>> "%s hwaccel requested for input stream
>> #%d:%d, " "but cannot be initialized.\n",