[FFmpeg-devel] [PATCH 2/2] lavc/videotoolboxenc: set extradata when opening codec

2016-06-01 Thread Rick Kern
VideoToolbox doesn't supply parameter sets until the first frame is done
encoding. This spins up a temporary encoder and encodes a single frame to
get this data.

Signed-off-by: Rick Kern 
---
 libavcodec/videotoolboxenc.c | 326 ---
 1 file changed, 241 insertions(+), 85 deletions(-)

diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
index f4f0d8e..895924a 100644
--- a/libavcodec/videotoolboxenc.c
+++ b/libavcodec/videotoolboxenc.c
@@ -96,6 +96,13 @@ typedef struct VTEncContext {
 bool warned_color_range;
 } VTEncContext;
 
+static int vtenc_populate_extradata(AVCodecContext   *avctx,
+CMVideoCodecType codec_type,
+CFStringRef  profile_level,
+CFNumberRef  gamma_level,
+CFDictionaryRef  enc_info,
+CFDictionaryRef  pixel_buffer_info);
+
 /**
  * NULL-safe release of *refPtr, and sets value to NULL.
  */
@@ -388,7 +395,7 @@ static int set_extradata(AVCodecContext *avctx, 
CMSampleBufferRef sample_buffer)
 return status;
 }
 
-avctx->extradata = av_malloc(total_size);
+avctx->extradata = av_mallocz(total_size + AV_INPUT_BUFFER_PADDING_SIZE);
 if (!avctx->extradata) {
 return AVERROR(ENOMEM);
 }
@@ -761,83 +768,28 @@ static int get_cv_ycbcr_matrix(AVCodecContext *avctx, 
CFStringRef *matrix) {
 return 0;
 }
 
-
-static av_cold int vtenc_init(AVCodecContext *avctx)
+static int vtenc_create_encoder(AVCodecContext   *avctx,
+CMVideoCodecType codec_type,
+CFStringRef  profile_level,
+CFNumberRef  gamma_level,
+CFDictionaryRef  enc_info,
+CFDictionaryRef  pixel_buffer_info,
+VTCompressionSessionRef *session)
 {
-CFMutableDictionaryRef enc_info;
-CFMutableDictionaryRef pixel_buffer_info;
-CMVideoCodecType   codec_type;
-VTEncContext   *vtctx = avctx->priv_data;
-CFStringRefprofile_level;
-SInt32 bit_rate = avctx->bit_rate;
-CFNumberRefbit_rate_num;
-CFBooleanRef   has_b_frames_cfbool;
-CFNumberRefgamma_level;
-intstatus;
-
-codec_type = get_cm_codec_type(avctx->codec_id);
-if (!codec_type) {
-av_log(avctx, AV_LOG_ERROR, "Error: no mapping for AVCodecID %d\n", 
avctx->codec_id);
-return AVERROR(EINVAL);
-}
-
-vtctx->has_b_frames = avctx->max_b_frames > 0;
-if(vtctx->has_b_frames && vtctx->profile == H264_PROF_BASELINE){
-av_log(avctx, AV_LOG_WARNING, "Cannot use B-frames with baseline 
profile. Output will not contain B-frames.\n");
-vtctx->has_b_frames = false;
-}
-
-if (vtctx->entropy == VT_CABAC && vtctx->profile == H264_PROF_BASELINE) {
-av_log(avctx, AV_LOG_WARNING, "CABAC entropy requires 'main' or 'high' 
profile, but baseline was requested. Encode will not use CABAC entropy.\n");
-vtctx->entropy = VT_ENTROPY_NOT_SET;
-}
-
-if (!get_vt_profile_level(avctx, &profile_level)) return AVERROR(EINVAL);
-
-vtctx->session = NULL;
-
-enc_info = CFDictionaryCreateMutable(
-kCFAllocatorDefault,
-20,
-&kCFCopyStringDictionaryKeyCallBacks,
-&kCFTypeDictionaryValueCallBacks
-);
-
-if (!enc_info) return AVERROR(ENOMEM);
-
-#if !TARGET_OS_IPHONE
-if (!vtctx->allow_sw) {
-CFDictionarySetValue(enc_info, 
kVTVideoEncoderSpecification_RequireHardwareAcceleratedVideoEncoder, 
kCFBooleanTrue);
-} else {
-CFDictionarySetValue(enc_info, 
kVTVideoEncoderSpecification_EnableHardwareAcceleratedVideoEncoder,  
kCFBooleanTrue);
-}
-#endif
-
-if (avctx->pix_fmt != AV_PIX_FMT_VIDEOTOOLBOX) {
-status = create_cv_pixel_buffer_info(avctx, &pixel_buffer_info);
-if (status) {
-CFRelease(enc_info);
-return status;
-}
-} else {
-pixel_buffer_info = NULL;
-}
-
-status = VTCompressionSessionCreate(
-kCFAllocatorDefault,
-avctx->width,
-avctx->height,
-codec_type,
-enc_info,
-pixel_buffer_info,
-kCFAllocatorDefault,
-vtenc_output_callback,
-avctx,
-&vtctx->session
-);
-
-if (pixel_buffer_info) CFRelease(pixel_buffer_info);
-CFRelease(enc_info);
+VTEncContext *vtctx = avctx->priv_data;
+SInt32   bit_rate = avctx->bit_rate;
+CFNumberRef  bit_rate_num;
+
+int status = VTCompressionSessionCreate(kCFAllocatorDefault,
+avctx->width,
+avctx->height,
+codec_type,
+

[FFmpeg-devel] [PATCH 1/2] lavc/videotoolboxenc: fix allocated buffer size

2016-06-01 Thread Rick Kern
Allocates a buffer with padding, and with enough room for start codes when
length codes are smaller.

Signed-off-by: Rick Kern 
---
 libavcodec/videotoolboxenc.c | 223 ++-
 1 file changed, 94 insertions(+), 129 deletions(-)

diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
index 57ea2b3..f4f0d8e 100644
--- a/libavcodec/videotoolboxenc.c
+++ b/libavcodec/videotoolboxenc.c
@@ -199,6 +199,45 @@ static void vtenc_q_push(VTEncContext *vtctx, 
CMSampleBufferRef buffer)
 pthread_mutex_unlock(&vtctx->lock);
 }
 
+static int count_nalus(size_t length_code_size,
+   CMSampleBufferRef sample_buffer,
+   int *count)
+{
+size_t offset = 0;
+int status;
+int nalu_ct = 0;
+uint8_t size_buf[4];
+size_t src_size = CMSampleBufferGetTotalSampleSize(sample_buffer);
+CMBlockBufferRef block = CMSampleBufferGetDataBuffer(sample_buffer);
+
+if (length_code_size > 4)
+return AVERROR_INVALIDDATA;
+
+while (offset < src_size) {
+size_t curr_src_len;
+size_t box_len = 0;
+size_t i;
+
+status = CMBlockBufferCopyDataBytes(block,
+offset,
+length_code_size,
+size_buf);
+
+for (i = 0; i < length_code_size; i++) {
+box_len <<= 8;
+box_len |= size_buf[i];
+}
+
+curr_src_len = box_len + length_code_size;
+offset += curr_src_len;
+
+nalu_ct++;
+}
+
+*count = nalu_ct;
+return 0;
+}
+
 static CMVideoCodecType get_cm_codec_type(enum AVCodecID id)
 {
 switch (id) {
@@ -207,12 +246,6 @@ static CMVideoCodecType get_cm_codec_type(enum AVCodecID 
id)
 }
 }
 
-static void vtenc_free_block(void *opaque, uint8_t *data)
-{
-CMBlockBufferRef block = opaque;
-CFRelease(block);
-}
-
 /**
  * Get the parameter sets from a CMSampleBufferRef.
  * @param dst If *dst isn't NULL, the parameters are copied into existing
@@ -1081,54 +1114,6 @@ static void vtenc_get_frame_info(CMSampleBufferRef 
buffer, bool *is_key_frame)
 }
 
 /**
- * Replaces length codes with H.264 Annex B start codes.
- * length_code_size must equal sizeof(start_code).
- * On failure, the contents of data may have been modified.
- *
- * @param length_code_size Byte length of each length code
- * @param data Call with NAL units prefixed with length codes.
- * On success, the length codes are replace with
- * start codes.
- * @param size Length of data, excluding any padding.
- * @return 0 on success
- * AVERROR_BUFFER_TOO_SMALL if length code size is smaller
- * than a start code or if a length_code in data specifies
- * data beyond the end of its buffer.
- */
-static int replace_length_codes(size_t  length_code_size,
-uint8_t *data,
-size_t  size)
-{
-size_t remaining_size = size;
-
-if (length_code_size != sizeof(start_code)) {
-av_log(NULL, AV_LOG_ERROR, "Start code size and length code size not 
equal.\n");
-return AVERROR_BUFFER_TOO_SMALL;
-}
-
-while (remaining_size > 0) {
-size_t box_len = 0;
-size_t i;
-
-for (i = 0; i < length_code_size; i++) {
-box_len <<= 8;
-box_len |= data[i];
-}
-
-if (remaining_size < box_len + sizeof(start_code)) {
-av_log(NULL, AV_LOG_ERROR, "Length is out of range.\n");
-AVERROR_BUFFER_TOO_SMALL;
-}
-
-memcpy(data, start_code, sizeof(start_code));
-data += box_len + sizeof(start_code);
-remaining_size -= box_len + sizeof(start_code);
-}
-
-return 0;
-}
-
-/**
  * Copies NAL units and replaces length codes with
  * H.264 Annex B start codes. On failure, the contents of
  * dst_data may have been modified.
@@ -1148,14 +1133,19 @@ static int replace_length_codes(size_t  
length_code_size,
  * the end of its buffer.
  */
 static int copy_replace_length_codes(
+AVCodecContext *avctx,
 size_tlength_code_size,
-const uint8_t *src_data,
-size_tsrc_size,
+CMSampleBufferRef sample_buffer,
 uint8_t   *dst_data,
 size_tdst_size)
 {
+size_t src_size = CMSampleBufferGetTotalSampleSize(sample_buffer);
 size_t remaining_src_size = src_size;
 size_t remaining_dst_size = dst_size;
+size_t src_offset = 0;
+int status;
+uint8_t size_buf[4];
+CMBlockBufferRef block = CMSampleBufferGetDataBuffer(sample_buffer);
 
 if (length_code_size > 4) {
 return AVERROR_INVALIDDATA;
@@ -1168,11 +1158,19 @@ static int copy_replace_length_codes(
 size_t i;
 
 uint8_t   *dst_box;
-const uint8_t *src_box;
+
+status = CMBlockBufferCopyDataBytes(block,
+src

[FFmpeg-devel] [PATCH] lavc/audiotoolboxenc: fix dropped frames on iOS

2016-06-01 Thread Rick Kern
AudioConverterFillComplexBuffer() doesn't always call its callback. A frame
queue is used to prevent skipped audio samples.

Signed-off-by: Rick Kern 
---
 libavcodec/audiotoolboxenc.c | 78 +---
 1 file changed, 52 insertions(+), 26 deletions(-)

diff --git a/libavcodec/audiotoolboxenc.c b/libavcodec/audiotoolboxenc.c
index 855df0c..262308a 100644
--- a/libavcodec/audiotoolboxenc.c
+++ b/libavcodec/audiotoolboxenc.c
@@ -22,6 +22,9 @@
 
 #include 
 
+#define FF_BUFQUEUE_SIZE 256
+#include "libavfilter/bufferqueue.h"
+
 #include "config.h"
 #include "audio_frame_queue.h"
 #include "avcodec.h"
@@ -38,8 +41,8 @@ typedef struct ATDecodeContext {
 int quality;
 
 AudioConverterRef converter;
-AVFrame in_frame;
-AVFrame new_in_frame;
+struct FFBufQueue frame_queue;
+struct FFBufQueue used_frame_queue;
 
 unsigned pkt_size;
 AudioFrameQueue afq;
@@ -449,28 +452,30 @@ static OSStatus ffat_encode_callback(AudioConverterRef 
converter, UInt32 *nb_pac
 {
 AVCodecContext *avctx = inctx;
 ATDecodeContext *at = avctx->priv_data;
+AVFrame *frame;
 
-if (at->eof) {
-*nb_packets = 0;
-return 0;
+if (!at->frame_queue.available) {
+if (at->eof) {
+*nb_packets = 0;
+return 0;
+} else {
+*nb_packets = 0;
+return 1;
+}
 }
 
-av_frame_unref(&at->in_frame);
-av_frame_move_ref(&at->in_frame, &at->new_in_frame);
-
-if (!at->in_frame.data[0]) {
-*nb_packets = 0;
-return 1;
-}
+frame = ff_bufqueue_get(&at->frame_queue);
 
 data->mNumberBuffers  = 1;
 data->mBuffers[0].mNumberChannels = avctx->channels;
-data->mBuffers[0].mDataByteSize   = at->in_frame.nb_samples *
+data->mBuffers[0].mDataByteSize   = frame->nb_samples *
 
av_get_bytes_per_sample(avctx->sample_fmt) *
 avctx->channels;
-data->mBuffers[0].mData   = at->in_frame.data[0];
-if (*nb_packets > at->in_frame.nb_samples)
-*nb_packets = at->in_frame.nb_samples;
+data->mBuffers[0].mData   = frame->data[0];
+if (*nb_packets > frame->nb_samples)
+*nb_packets = frame->nb_samples;
+
+ff_bufqueue_add(avctx, &at->used_frame_queue, frame);
 
 return 0;
 }
@@ -492,20 +497,38 @@ static int ffat_encode(AVCodecContext *avctx, AVPacket 
*avpkt,
 };
 AudioStreamPacketDescription out_pkt_desc = {0};
 
-if ((ret = ff_alloc_packet2(avctx, avpkt, at->pkt_size, 0)) < 0)
-return ret;
-
-av_frame_unref(&at->new_in_frame);
-
 if (frame) {
+AVFrame *in_frame;
+
+if (ff_bufqueue_is_full(&at->frame_queue)) {
+/*
+ * The frame queue is significantly larger than needed in practice,
+ * but no clear way to determine the minimum number of samples to
+ * get output from AudioConverterFillComplexBuffer().
+ */
+av_log(avctx, AV_LOG_ERROR, "Bug: frame queue is too small.\n");
+return AVERROR_BUG;
+}
+
 if ((ret = ff_af_queue_add(&at->afq, frame)) < 0)
 return ret;
-if ((ret = av_frame_ref(&at->new_in_frame, frame)) < 0)
+
+in_frame = av_frame_alloc();
+if (!in_frame)
+return AVERROR(ENOMEM);
+
+if ((ret = av_frame_ref(in_frame, frame)) < 0)
 return ret;
+
+ff_bufqueue_add(avctx, &at->frame_queue, in_frame);
 } else {
 at->eof = 1;
 }
 
+if ((ret = ff_alloc_packet2(avctx, avpkt, at->pkt_size, 0)) < 0)
+return ret;
+
+
 out_buffers.mBuffers[0].mData = avpkt->data;
 
 *got_packet_ptr = avctx->frame_size / at->frame_size;
@@ -513,6 +536,9 @@ static int ffat_encode(AVCodecContext *avctx, AVPacket 
*avpkt,
 ret = AudioConverterFillComplexBuffer(at->converter, ffat_encode_callback, 
avctx,
   got_packet_ptr, &out_buffers,
   (avctx->frame_size > at->frame_size) 
? NULL : &out_pkt_desc);
+
+ff_bufqueue_discard_all(&at->used_frame_queue);
+
 if ((!ret || ret == 1) && *got_packet_ptr) {
 avpkt->size = out_buffers.mBuffers[0].mDataByteSize;
 ff_af_queue_remove(&at->afq, out_pkt_desc.mVariableFramesInPacket ?
@@ -531,16 +557,16 @@ static av_cold void ffat_encode_flush(AVCodecContext 
*avctx)
 {
 ATDecodeContext *at = avctx->priv_data;
 AudioConverterReset(at->converter);
-av_frame_unref(&at->new_in_frame);
-av_frame_unref(&at->in_frame);
+ff_bufqueue_discard_all(&at->frame_queue);
+ff_bufqueue_discard_all(&at->used_frame_queue);
 }
 
 static av_cold int ffat_close_encoder(AVCodecContext *avctx)
 {
 ATDecodeContext *at = avctx->priv_data;
 AudioConverterDispose(at->converter);
-av_frame_unref(&at->new_in_frame);
-av_frame_unref(&at->in_frame);
+ff

Re: [FFmpeg-devel] Doubts regarding SoftFloat

2016-06-01 Thread Umair Khan
Hi,

On Thu, Jun 2, 2016 at 4:02 AM, Moritz Barsnick  wrote:
> To expand on Michael's comments:
>
> On Tue, May 31, 2016 at 21:02:01 +0530, Umair Khan wrote:
>> I replaced floats in my code with SoftFloat and the results weren't as 
>> expected.
>
> Why did you implement your own multiply()? It makes incorrect
> assumptions about how SoftFloat works, as far as I can tell by a quick
> glance.

Okay. I was going to use the already present multiply function only.
But I just left it because, the multiply function is not being used in
the file I'm trying to get decoded first.

>> 3. After making the changes, the exp part was always one less than
>> what it should have been (I couldn't figure out why) and the mantissa
>> was totally different altogether. This is the commit which converts
>
> You should be using SoftFloat via its API an not touching its
> internals. (As Michael explained, and what it quite obvious from its
> code, is that its exponent has a representation with an offset of 1. Or
> something like that.)

By internals, do you mean accessing the mant and exp part ?
I'm just getting their values and printing them. I'm not altering them
explicitly.
I'll look into it a bit more now.

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


Re: [FFmpeg-devel] MetaData in Sun AU format

2016-06-01 Thread Paul B Mahol
On 6/1/16, miniupnp  wrote:
> Hello,
>
> I'm using the .AU audio file format and noticed that FFmpeg always put 8
> zero's in the annotation field.
> SOX does use the annotation field to put metadata
> (Title/Author/Album/Genre/Track)
>
> I don't think there is any precise specification for this AU annotation
> field as long as it is a null terminated character string, but what SOX
> does looks good.
>
> Attached are my patches to write metadata to AU files.
>
> Regards,
>
> Thomas Bernard
>
>

look fine to me.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] lavc/videotoolbox: fix H.264 hwaccel init issue

2016-06-01 Thread Rick Kern
Fixes VTDecompressionSessionCreate() error.

Signed-off-by: Rick Kern 
---
 libavcodec/videotoolbox.c | 59 ---
 1 file changed, 45 insertions(+), 14 deletions(-)

diff --git a/libavcodec/videotoolbox.c b/libavcodec/videotoolbox.c
index 2f4d531..cadfb23 100644
--- a/libavcodec/videotoolbox.c
+++ b/libavcodec/videotoolbox.c
@@ -487,23 +487,53 @@ static CFDictionaryRef 
videotoolbox_buffer_attributes_create(int width,
 return buffer_attributes;
 }
 
-static CMVideoFormatDescriptionRef 
videotoolbox_format_desc_create(CMVideoCodecType codec_type,
+static CMVideoFormatDescriptionRef 
videotoolbox_format_desc_create(AVCodecContext *avctx,
+   
CMVideoCodecType codec_type,

CFDictionaryRef decoder_spec,
int width,
int height)
 {
-CMFormatDescriptionRef cm_fmt_desc;
-OSStatus status;
-
-status = CMVideoFormatDescriptionCreate(kCFAllocatorDefault,
-codec_type,
-width,
-height,
-decoder_spec, // Dictionary of 
extension
-&cm_fmt_desc);
-
-if (status)
-return NULL;
+CMFormatDescriptionRef cm_fmt_desc = NULL;
+int status;
+H264Context *h = codec_type == kCMVideoCodecType_H264 ? avctx->priv_data : 
NULL;
+
+if (h && h->sps.data_size && h->pps.data_size) {
+int ps_count = 2;
+const uint8_t **ps_data = av_malloc(sizeof(uint8_t*) * ps_count);
+size_t *ps_sizes = av_malloc(sizeof(size_t)  * ps_count);
+
+ps_data[0]  = h->sps.data;
+ps_sizes[0] = h->sps.data_size;
+
+ps_data[1]  = h->pps.data;
+ps_sizes[1] = h->pps.data_size;
+
+status = CMVideoFormatDescriptionCreateFromH264ParameterSets(NULL,
+ ps_count,
+ ps_data,
+ ps_sizes,
+ 4,
+ 
&cm_fmt_desc);
+av_freep(&ps_sizes);
+av_freep(&ps_data);
+
+if (status) {
+av_log(avctx, AV_LOG_ERROR, "Error creating H.264 format 
description: %d\n", status);
+return NULL;
+}
+} else {
+status = CMVideoFormatDescriptionCreate(kCFAllocatorDefault,
+codec_type,
+width,
+height,
+decoder_spec, // Dictionary of 
extension
+&cm_fmt_desc);
+
+if (status) {
+av_log(avctx, AV_LOG_ERROR, "Error creating format description: 
%d\n", status);
+return NULL;
+}
+}
 
 return cm_fmt_desc;
 }
@@ -543,7 +573,8 @@ static int videotoolbox_default_init(AVCodecContext *avctx)
 
 decoder_spec = 
videotoolbox_decoder_config_create(videotoolbox->cm_codec_type, avctx);
 
-videotoolbox->cm_fmt_desc = 
videotoolbox_format_desc_create(videotoolbox->cm_codec_type,
+videotoolbox->cm_fmt_desc = videotoolbox_format_desc_create(avctx,
+
videotoolbox->cm_codec_type,
 decoder_spec,
 avctx->width,
 avctx->height);
-- 
2.7.4

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


Re: [FFmpeg-devel] [PATCH] Use int32_t instead of int for gaintable in hdcd filter

2016-06-01 Thread Ronald S. Bultje
Hi,

On Wed, Jun 1, 2016 at 7:47 PM, Michael Niedermayer 
wrote:

> On Thu, Jun 02, 2016 at 12:01:50AM +0200, Benjamin St wrote:
> >
>
> >  af_hdcd.c |2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > b56f3e60dbd8c688ad37cc5dceb5378f68855622
> 0001-Use-int32_t-instead-of-int-for-gaintable-in-hdcd-fil.patch
> > From 11bbac3343cb06ce0862ffbbf6365ba834b4284b Mon Sep 17 00:00:00 2001
> > From: Benjamin Steffes 
> > Date: Sun, 29 May 2016 17:45:33 +0200
> > Subject: [PATCH] Use int32_t instead of int for gaintable in hdcd filter.
>
> the commit message is missing the "why"
>
> also note POSIX gurantees >=32bit int and we require POSIX


It may be to prevent the theoretical case where the container type (int)
would be 64 bit on some platforms, which would waste some space...

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


Re: [FFmpeg-devel] [PATCH 1/2] lavf/mp3dec: pass Xing gapless metadata to AVCodecParameters

2016-06-01 Thread Jon Toohill
Based on my understanding of [1], these values in the Info tag specify only
the encoder delay/padding, which matches the documentation for these
fields. It looks like other formats are using the fields that way as well.

I think the extra 528 + 1 samples are the decoder delay [2]. It looks like
libmp3lame adds the 528 + 1 only to have mp3dec subtract it, so I'm not
sure why that's done. IIUC start_skip_samples is the mechanism that
actually accounts for the extra delay when decoding.

[1]: http://gabriel.mp3-tech.org/mp3infotag.html#delays
[2]: http://lame.sourceforge.net/tech-FAQ.txt



Jon Toohill |  Google Play Music |  jtooh...@google.com |  (650) 215-0770

On Thu, May 26, 2016 at 7:51 PM, Michael Niedermayer  wrote:

> On Wed, May 25, 2016 at 09:56:59AM -0700, Jon Toohill wrote:
> > ---
> >  libavformat/mp3dec.c | 2 ++
> >  1 file changed, 2 insertions(+)
> >
> > diff --git a/libavformat/mp3dec.c b/libavformat/mp3dec.c
> > index 3725d67..192f5ef 100644
> > --- a/libavformat/mp3dec.c
> > +++ b/libavformat/mp3dec.c
> > @@ -234,6 +234,8 @@ static void mp3_parse_info_tag(AVFormatContext *s,
> AVStream *st,
> >
> >  mp3->start_pad = v>>12;
> >  mp3->  end_pad = v&4095;
> > +st->codecpar->initial_padding = mp3->start_pad;
> > +st->codecpar->trailing_padding = mp3->end_pad;
> >  st->start_skip_samples = mp3->start_pad + 528 + 1;
> >  if (mp3->frames) {
> >  st->first_discard_sample = -mp3->end_pad + 528 + 1 +
> mp3->frames * (int64_t)spf;
>
> is the 528 + 1 difference intended to
> start_skip_samples/first_discard_sample
> ?
> mp3enc stores par->initial_padding - 528 - 1
>
> [...]
>
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> If you drop bombs on a foreign country and kill a hundred thousand
> innocent people, expect your government to call the consequence
> "unprovoked inhuman terrorist attacks" and use it to justify dropping
> more bombs and killing more people. The technology changed, the idea is
> old.
>
> ___
> 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] Use int32_t instead of int for gaintable in hdcd filter

2016-06-01 Thread Michael Niedermayer
On Thu, Jun 02, 2016 at 12:01:50AM +0200, Benjamin St wrote:
> 

>  af_hdcd.c |2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> b56f3e60dbd8c688ad37cc5dceb5378f68855622  
> 0001-Use-int32_t-instead-of-int-for-gaintable-in-hdcd-fil.patch
> From 11bbac3343cb06ce0862ffbbf6365ba834b4284b Mon Sep 17 00:00:00 2001
> From: Benjamin Steffes 
> Date: Sun, 29 May 2016 17:45:33 +0200
> Subject: [PATCH] Use int32_t instead of int for gaintable in hdcd filter.

the commit message is missing the "why"

also note POSIX gurantees >=32bit int and we require POSIX

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The worst form of inequality is to try to make unequal things equal.
-- Aristotle


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


Re: [FFmpeg-devel] [PATCH] avformat: Add Pro-MPEG CoP #3-R2 FEC protocol

2016-06-01 Thread Michael Niedermayer
On Wed, Jun 01, 2016 at 11:19:38AM +0200, Vlad Tarca wrote:
> Pro-MPEG Code of Practice #3 release 2 forward error correction for 
> rtp_mpegts streams
> 
> Fixes:
> 
> [prompeg.c]
> - proper RTP size check to fit the largest buffer
> - UDP port overflow check
> - replaced ffurl_close calls with ffurl_closep
> [rtpproto.c]
> - removed context fec flag and used fec_hd directly
> - moved fec_hd open outside the retry loop as it doesn't set any specific 
> local ports
> - replaced ffurl_close call with ffurl_closep
> 
> Signed-off-by: Vlad Tarca 

please provide a commit message that works for the commit, not one
that lists th differences to the last patch
(as only the final one is commited that would be confusing)


[...]

> +static void xor_fast(const uint8_t *in1, const uint8_t *in2, uint8_t *out, 
> int size) {
> +int i, n, s;
> +
> +#if HAVE_FAST_64BIT
> +uint64_t v1, v2;
> +
> +n = size / sizeof (uint64_t);
> +s = n * sizeof (uint64_t);
> +
> +for (i = 0; i < n; i++) {
> +v1 = AV_RN64A(in1);
> +v2 = AV_RN64A(in2);
> +AV_WN64A(out, v1 ^ v2);
> +in1 += 8;
> +in2 += 8;
> +out += 8;
> +}
> +#else
> +uint32_t v1, v2;
> +
> +n = size / sizeof (uint32_t);
> +s = n * sizeof (uint32_t);
> +
> +for (i = 0; i < n; i++) {
> +v1 = AV_RN32A(in1);
> +v2 = AV_RN32A(in2);
> +AV_WN32A(out, v1 ^ v2);
> +in1 += 4;
> +in2 += 4;
> +out += 4;
> +}
> +#endif
> +

> +if (s == size)
> +return;

is it faster with this check ?
iam asking because the check doesnt change the outcome in any way


[...]

> +static int prompeg_open(URLContext *h, const char *uri, int flags) {
> +PrompegContext *s = h->priv_data;
> +AVDictionary *udp_opts = NULL;
> +int rtp_port;
> +char hostname[256];
> +char buf[1024];
> +
> +s->fec_col_hd = NULL;
> +s->fec_row_hd = NULL;
> +
> +if (s->l * s->d > 100) {
> +av_log(h, AV_LOG_ERROR, "L * D must be <= 100\n");
> +return AVERROR(EINVAL);
> +}
> +
> +av_url_split(NULL, 0, NULL, 0, hostname, sizeof (hostname), &rtp_port,
> +NULL, 0, uri);
> +
> +if (rtp_port < 1 || rtp_port > 65531) {
> +av_log(h, AV_LOG_ERROR, "Invalid RTP base port %d\n", rtp_port);
> +return AVERROR(EINVAL);
> +}
> +
> +if (s->ttl > 0) {
> +snprintf(buf, sizeof (buf), "%d", s->ttl);
> +av_dict_set(&udp_opts, "ttl", buf, 0);
> +}
> +
> +ff_url_join(buf, sizeof (buf), "udp", NULL, hostname, rtp_port + 2, 
> NULL);
> +if (ffurl_open_whitelist(&s->fec_col_hd, buf, flags, 
> &h->interrupt_callback,
> +&udp_opts, h->protocol_whitelist, h->protocol_blacklist, h) < 0)
> +goto fail;
> +ff_url_join(buf, sizeof (buf), "udp", NULL, hostname, rtp_port + 4, 
> NULL);
> +if (ffurl_open_whitelist(&s->fec_row_hd, buf, flags, 
> &h->interrupt_callback,
> +&udp_opts, h->protocol_whitelist, h->protocol_blacklist, h) < 0)
> +goto fail;
> +
> +h->max_packet_size = s->fec_col_hd->max_packet_size;
> +s->init = 1;
> +
> +av_dict_free(&udp_opts);
> +av_log(h, AV_LOG_INFO, "ProMPEG CoP#3-R2 FEC L=%d D=%d\n", s->l, s->d);
> +return 0;
> +
> +fail:
> +ffurl_closep(&s->fec_col_hd);
> +ffurl_closep(&s->fec_row_hd);
> +av_dict_free(&udp_opts);
> +return AVERROR(EIO);
> +}
> +
> +static int prompeg_init(URLContext *h, const uint8_t *buf, int size) {
> +PrompegContext *s = h->priv_data;
> +uint32_t seed;
> +int bitstring_len, rtp_buf_len;
> +int i;
> +
> +s->fec_buf = NULL;
> +s->rtp_buf = NULL;
> +
> +if (size < 12 || size >= INT_MAX - 16) {
> +av_log(h, AV_LOG_ERROR, "Invalid RTP packet size\n");
> +return AVERROR_INVALIDDATA;
> +}
> +
> +s->packet_idx = 0;
> +s->packet_idx_max = s->l * s->d;
> +s->packet_size = size;
> +s->recovery_len = size - 12;
> +rtp_buf_len = 28 + s->recovery_len; // 12 + 16: RTP + FEC headers

> +s->rtp_buf_size = rtp_buf_len * sizeof (uint8_t);
> +bitstring_len = 8 + s->recovery_len; // 8: P, X, CC, M, PT, SN, TS
> +s->bitstring_size = bitstring_len * sizeof (uint8_t);

sizeof (uint8_t) is always 1, the multiplications arent needed
also why are some called _size and some _len ?


[...]
> @@ -412,6 +441,14 @@ static int rtp_open(URLContext *h, const char *uri, int 
> flags)
>  break;
>  }
>  
> +s->fec_hd = NULL;
> +if (fec_protocol) {
> +ff_url_join(buf, sizeof(buf), fec_protocol, NULL, hostname, 
> rtp_port, NULL);

> +if (ffurl_open_whitelist(&s->fec_hd, buf, flags, 
> &h->interrupt_callback,
> + &fec_opts, h->protocol_whitelist, 
> h->protocol_blacklist, h) < 0)
> +goto fail;

something is wrong with the indention here


[...]
> @@ -474,7 +518,7 @@ static int rtp_read(URLContext *h, uint8_t *buf, int size)
>  static int rtp_write(URLContex

Re: [FFmpeg-devel] [PATCH] vaapi: Enable more libva surface formats

2016-06-01 Thread Michael Niedermayer
On Wed, Jun 01, 2016 at 08:22:26PM +0100, Mark Thompson wrote:
> On 22/05/16 11:38, Mark Thompson wrote:
> > ---
> > These were not already enabled because the other tine does not have 
> > suitable support for them.
> > 
> > BGR0/RGB0 tested and working.  I don't have any hardware for the others, 
> > but I believe they should work.
> > 
> >  libavutil/hwcontext_vaapi.c | 10 +-
> >  1 file changed, 5 insertions(+), 5 deletions(-)
> > 
> > diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c
> > index c2cdaa9..7c3e4bd 100644
> > --- a/libavutil/hwcontext_vaapi.c
> > +++ b/libavutil/hwcontext_vaapi.c
> > @@ -86,16 +86,16 @@ static struct {
> >  MAP(YUY2, YUV422,  YUYV422),
> >  MAP(Y800, YUV400,  GRAY8),
> >  #ifdef VA_FOURCC_P010
> > -  //MAP(P010, YUV420_10BPP, P010),
> > +MAP(P010, YUV420_10BPP, P010),
> >  #endif
> >  MAP(BGRA, RGB32,   BGRA),
> > -  //MAP(BGRX, RGB32,   BGR0),
> > +MAP(BGRX, RGB32,   BGR0),
> >  MAP(RGBA, RGB32,   RGBA),
> > -  //MAP(RGBX, RGB32,   RGB0),
> > +MAP(RGBX, RGB32,   RGB0),
> >  MAP(ABGR, RGB32,   ABGR),
> > -  //MAP(XBGR, RGB32,   0BGR),
> > +MAP(XBGR, RGB32,   0BGR),
> >  MAP(ARGB, RGB32,   ARGB),
> > -  //MAP(XRGB, RGB32,   0RGB),
> > +MAP(XRGB, RGB32,   0RGB),
> >  };
> >  #undef MAP
> > 
> 
> Ping.

applied

thanks

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

Rewriting code that is poorly written but fully understood is good.
Rewriting code that one doesnt understand is a sign that one is less smart
then the original author, trying to rewrite it will not make it better.


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


Re: [FFmpeg-devel] [PATCH] Respect payload offset in av_grow_packet

2016-06-01 Thread Michael Niedermayer
On Wed, May 25, 2016 at 05:58:33PM +0300, Andriy Lysnevych wrote:
> > data_offset should probably be size_t, thats also what offsetof() would
> > give
> > a pointer difference can be larger than INT_MAX
> 
> Done
> 
> > also please add a av_assert0 that pkt->data is not NULL or handle that
> > case
> 
> Done NULL data handling but it makes code more complex. Please check.
> 
> > as pkt->size can be 0 iam not sure pkt->data is guranteed to be non
> > null
> 
> It should work with pkt->size = 0 for both reference counted and
> not-reference counted packets without memory leak. It should allocate
> just padding and zeroize it.

>  avpacket.c |   28 +---
>  1 file changed, 21 insertions(+), 7 deletions(-)
> 1f6f2b7fe3cbb95616537b4509cd8751b9a24aaa  
> 0001-Respect-payload-offset-in-av_grow_packet.patch
> From b92cc763ebb4e9f16989da442af745a78a9c2501 Mon Sep 17 00:00:00 2001
> From: Andriy Lysnevych 
> Date: Wed, 25 May 2016 17:56:21 +0300
> Subject: [PATCH] Respect payload offset in av_grow_packet

applied

thx

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

It is dangerous to be right in matters on which the established authorities
are wrong. -- Voltaire


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


Re: [FFmpeg-devel] Doubts regarding SoftFloat

2016-06-01 Thread Moritz Barsnick
To expand on Michael's comments:

On Tue, May 31, 2016 at 21:02:01 +0530, Umair Khan wrote:
> I replaced floats in my code with SoftFloat and the results weren't as 
> expected.

Why did you implement your own multiply()? It makes incorrect
assumptions about how SoftFloat works, as far as I can tell by a quick
glance.

> 3. After making the changes, the exp part was always one less than
> what it should have been (I couldn't figure out why) and the mantissa
> was totally different altogether. This is the commit which converts

You should be using SoftFloat via its API an not touching its
internals. (As Michael explained, and what it quite obvious from its
code, is that its exponent has a representation with an offset of 1. Or
something like that.)

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


[FFmpeg-devel] [PATCH] Use int32_t instead of int for gaintable in hdcd filter

2016-06-01 Thread Benjamin St

From 11bbac3343cb06ce0862ffbbf6365ba834b4284b Mon Sep 17 00:00:00 2001
From: Benjamin Steffes 
Date: Sun, 29 May 2016 17:45:33 +0200
Subject: [PATCH] Use int32_t instead of int for gaintable in hdcd filter.

Signed-off-by: Benjamin Steffes 
---
 libavfilter/af_hdcd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavfilter/af_hdcd.c b/libavfilter/af_hdcd.c
index 7907edf..16bdcb0 100644
--- a/libavfilter/af_hdcd.c
+++ b/libavfilter/af_hdcd.c
@@ -683,7 +683,7 @@ static const uint8_t readaheadtab[] = {
 };
 
 //values between 0 and 1 multiplied by 2^23 to avoid floating point numbers.
-static const int gaintab[] = {
+static const int32_t gaintab[] = {
 0x80, 0x7ff144, 0x7fe28a, 0x7fd3d2, 0x7fc51b, 0x7fb666, 0x7fa7b3, 0x7f9901, 0x7f8a52, 0x7f7ba3, 0x7f6cf7, 0x7f5e4c, 0x7f4fa3, 0x7f40fc, 0x7f3256,
 0x7f23b2, 0x7f1510, 0x7f066f, 0x7ef7d0, 0x7ee933, 0x7eda97, 0x7ecbfd, 0x7ebd65, 0x7eaece, 0x7ea039, 0x7e91a6, 0x7e8315, 0x7e7485, 0x7e65f6, 0x7e576a,
 0x7e48df, 0x7e3a56, 0x7e2bce, 0x7e1d49, 0x7e0ec5, 0x7e0042, 0x7df1c1, 0x7de342, 0x7dd4c5, 0x7dc649, 0x7db7cf, 0x7da956, 0x7d9adf, 0x7d8c6a, 0x7d7df7,
-- 
2.5.0

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


Re: [FFmpeg-devel] [PATCH] vaapi: Enable more libva surface formats

2016-06-01 Thread Mark Thompson
On 22/05/16 11:38, Mark Thompson wrote:
> ---
> These were not already enabled because the other tine does not have suitable 
> support for them.
> 
> BGR0/RGB0 tested and working.  I don't have any hardware for the others, but 
> I believe they should work.
> 
>  libavutil/hwcontext_vaapi.c | 10 +-
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c
> index c2cdaa9..7c3e4bd 100644
> --- a/libavutil/hwcontext_vaapi.c
> +++ b/libavutil/hwcontext_vaapi.c
> @@ -86,16 +86,16 @@ static struct {
>  MAP(YUY2, YUV422,  YUYV422),
>  MAP(Y800, YUV400,  GRAY8),
>  #ifdef VA_FOURCC_P010
> -  //MAP(P010, YUV420_10BPP, P010),
> +MAP(P010, YUV420_10BPP, P010),
>  #endif
>  MAP(BGRA, RGB32,   BGRA),
> -  //MAP(BGRX, RGB32,   BGR0),
> +MAP(BGRX, RGB32,   BGR0),
>  MAP(RGBA, RGB32,   RGBA),
> -  //MAP(RGBX, RGB32,   RGB0),
> +MAP(RGBX, RGB32,   RGB0),
>  MAP(ABGR, RGB32,   ABGR),
> -  //MAP(XBGR, RGB32,   0BGR),
> +MAP(XBGR, RGB32,   0BGR),
>  MAP(ARGB, RGB32,   ARGB),
> -  //MAP(XRGB, RGB32,   0RGB),
> +MAP(XRGB, RGB32,   0RGB),
>  };
>  #undef MAP
> 

Ping.

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


[FFmpeg-devel] Patch that adds timeline function for eq filter

2016-06-01 Thread Maxim Petrov

From 570b215c110b027badc41d1206b0ff6d4806a98f Mon Sep 17 00:00:00 2001
From: Ilya87 
Date: Wed, 1 Jun 2016 07:49:51 +0300
Subject: [PATCH] Timeline function for the eq filter

---
 libavfilter/vf_eq.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavfilter/vf_eq.c b/libavfilter/vf_eq.c
index 0b929f3..5ecdb31 100644
--- a/libavfilter/vf_eq.c
+++ b/libavfilter/vf_eq.c
@@ -385,4 +385,5 @@ AVFilter ff_vf_eq = {
 .query_formats   = query_formats,
 .init= initialize,
 .uninit  = uninit,
+.flags = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC,
 };
-- 
2.8.3

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


Re: [FFmpeg-devel] [PATCH 1/3] avutil/frame: Document avcodec_get_frame_class() and the option naming system

2016-06-01 Thread Michael Niedermayer
On Sat, May 28, 2016 at 04:57:13PM +0200, Michael Niedermayer wrote:
> Missing docs found by: nevcairiel
> 
> Signed-off-by: Michael Niedermayer 
> ---
>  libavutil/frame.h |4 
>  1 file changed, 4 insertions(+)

patchset applied

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

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


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


Re: [FFmpeg-devel] [PATCH] extends Generic/CDDI/MPEG2 essence descriptors

2016-06-01 Thread Michael Niedermayer
On Thu, Apr 21, 2016 at 05:03:01PM +0300, Maksym Veremeyenko wrote:
> Hi,
> 
> attached patches extends Generic/CDDI/MPEG2 essence descriptors with
> additional items. These items required by AMWA AS-10 MXF
> specification.
> 
> -- 
> Maksym Veremeyenko
> 
[...]

>  mxfenc.c |   91 
> ++-
>  1 file changed, 90 insertions(+), 1 deletion(-)
> 0df0bfaa318361ecec5c47572650b3563b0f8a74  
> 0001-Extend-Generic-CDCI-picture-essence-descriptors-with.patch
> From eb3ef1f423864bd8d79d6170bbc137ac0be62f0b Mon Sep 17 00:00:00 2001
> From: Maksym Veremeyenko 
> Date: Wed, 20 Apr 2016 14:24:40 +0300
> Subject: [PATCH 1/2] Extend Generic/CDCI picture essence descriptors with
>  additional items

does this fix something ?


> 
> ---
>  libavformat/mxfenc.c |   91 
> +-
>  1 files changed, 90 insertions(+), 1 deletions(-)
> 
> diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c
> index 36a43e4..ec42cf5 100644
> --- a/libavformat/mxfenc.c
> +++ b/libavformat/mxfenc.c
> @@ -419,10 +419,27 @@ static const MXFLocalTagPair mxf_local_tag_batch[] = {
>  { 0x3201, 
> {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x04,0x01,0x06,0x01,0x00,0x00,0x00,0x00}},
>  /* Picture Essence Coding */
>  { 0x3212, 
> {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x04,0x01,0x03,0x01,0x06,0x00,0x00,0x00}},
>  /* Field Dominance (Opt) */
>  { 0x3215, 
> {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x05,0x04,0x05,0x01,0x13,0x00,0x00,0x00,0x00}},
>  /* Signal Standard */
> +{ 0x3216, 
> {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x05,0x04,0x01,0x03,0x02,0x08,0x00,0x00,0x00}},
>  /* StoredF2Offset */
> +{ 0x3205, 
> {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x01,0x04,0x01,0x05,0x01,0x08,0x00,0x00,0x00}},
>  /* Sampled Width */
> +{ 0x3204, 
> {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x01,0x04,0x01,0x05,0x01,0x07,0x00,0x00,0x00}},
>  /* Sampled Height */
> +{ 0x3206, 
> {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x01,0x04,0x01,0x05,0x01,0x09,0x00,0x00,0x00}},
>  /* SampledXOffset */
> +{ 0x3207, 
> {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x01,0x04,0x01,0x05,0x01,0x0A,0x00,0x00,0x00}},
>  /* SampledYOffset */
> +{ 0x320A, 
> {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x01,0x04,0x01,0x05,0x01,0x0D,0x00,0x00,0x00}},
>  /* DisplayXOffset */
> +{ 0x3217, 
> {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x05,0x04,0x01,0x03,0x02,0x07,0x00,0x00,0x00}},
>  /* DisplayF2Offset */
> +{ 0x3210, 
> {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x04,0x01,0x02,0x01,0x01,0x01,0x02,0x00}},
>  /* Capture Gamma */
> +{ 0x3211, 
> {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x04,0x18,0x01,0x01,0x00,0x00,0x00,0x00}},
>  /* Image Alignment Offset */
> +{ 0x3213, 
> {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x04,0x18,0x01,0x02,0x00,0x00,0x00,0x00}},
>  /* Image Start Offset */
> +{ 0x3214, 
> {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x04,0x18,0x01,0x03,0x00,0x00,0x00,0x00}},
>  /* Image End Offset */
>  // CDCI Picture Essence Descriptor
>  { 0x3301, 
> {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x04,0x01,0x05,0x03,0x0A,0x00,0x00,0x00}},
>  /* Component Depth */
>  { 0x3302, 
> {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x01,0x04,0x01,0x05,0x01,0x05,0x00,0x00,0x00}},
>  /* Horizontal Subsampling */
>  { 0x3303, 
> {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x01,0x04,0x01,0x05,0x01,0x06,0x00,0x00,0x00}},
>  /* Color Siting */
> +{ 0x3308, 
> {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x04,0x01,0x05,0x01,0x10,0x00,0x00,0x00}},
>  /* Vertical Subsampling */
> +{ 0x330B, 
> {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x05,0x03,0x01,0x02,0x01,0x0A,0x00,0x00,0x00}},
>  /* ReversedByteOrder */
> +{ 0x3307, 
> {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x04,0x18,0x01,0x04,0x00,0x00,0x00,0x00}},
>  /* PaddingBits */
> +{ 0x3304, 
> {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x01,0x04,0x01,0x05,0x03,0x03,0x00,0x00,0x00}},
>  /* Black Ref Level */
> +{ 0x3305, 
> {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x01,0x04,0x01,0x05,0x03,0x04,0x00,0x00,0x00}},
>  /* White Ref level */
> +{ 0x3306, 
> {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x04,0x01,0x05,0x03,0x05,0x00,0x00,0x00}},
>  /* Color Range */
>  // Generic Sound Essence Descriptor
>  { 0x3D02, 
> {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x04,0x04,0x02,0x03,0x01,0x04,0x00,0x00,0x00}},
>  /* Locked/Unlocked */
>  { 0x3D03, 
> {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x05,0x04,0x02,0x03,0x01,0x01,0x01,0x00,0x00}},
>  /* Audio sampling rate */
> @@ -452,6 +469,11 @@ static const MXFLocalTagPair 
> mxf_user_comments_local_tag[] = {
>  { 0x5003, 
> {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x03,0x02,0x01,0x02,0x0A,0x01,0x00,0x00}},
>  /* Value */
>  };
>  
> +static const uint8_t capture_gamma_ITU470[] = // MXF-Profile ARD_ZDF_SDF02 - 
> v1.0.pdf
> +
> {06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x01,0x01,0x01,0x01,0x00,0x00};
> +static const uint8_t capture_gamma_ITU709[] = // MXF-Profile ARD_ZDF_HDF01a 
> - v1.1.pdf, also used in SMP

Re: [FFmpeg-devel] [PATCH] extends Generic/CDDI/MPEG2 essence descriptors

2016-06-01 Thread Michael Niedermayer
On Thu, Apr 21, 2016 at 05:03:01PM +0300, Maksym Veremeyenko wrote:
> Hi,
> 
> attached patches extends Generic/CDDI/MPEG2 essence descriptors with
> additional items. These items required by AMWA AS-10 MXF
> specification.
> 
> -- 
> Maksym Veremeyenko
> 

>  mxfenc.c |   47 ++-
>  1 file changed, 46 insertions(+), 1 deletion(-)
> ac195a1f686025452a8dcb009ed62ec9a2b69db8  
> 0002-Extend-mpeg2-video-descriptor-with-additional-items.patch
> From 937b1e3f14d641b83a40c9dc5e64e227121dddfa Mon Sep 17 00:00:00 2001
> From: Maksym Veremeyenko 
> Date: Thu, 21 Apr 2016 01:18:39 +0300
> Subject: [PATCH 2/2] Extend mpeg2 video descriptor with additional items
> 
> ---
>  libavformat/mxfenc.c |   47 ++-
>  1 files changed, 46 insertions(+), 1 deletions(-)
> 
> diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c
> index ec42cf5..c658624 100644
> --- a/libavformat/mxfenc.c
> +++ b/libavformat/mxfenc.c
> @@ -50,6 +50,7 @@
>  #include "libavcodec/dnxhddata.h"
>  #include "libavcodec/h264.h"
>  #include "libavcodec/internal.h"
> +#include "libavcodec/mpegvideo.h"
>  #include "audiointerleave.h"
>  #include "avformat.h"
>  #include "avio_internal.h"
> @@ -458,6 +459,14 @@ static const MXFLocalTagPair mxf_local_tag_batch[] = {
>  // MPEG video Descriptor
>  { 0x8000, 
> {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x05,0x04,0x01,0x06,0x02,0x01,0x0B,0x00,0x00}},
>  /* BitRate */
>  { 0x8007, 
> {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x05,0x04,0x01,0x06,0x02,0x01,0x0A,0x00,0x00}},
>  /* ProfileAndLevel */
> +{ 0x8001, 
> {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x05,0x04,0x01,0x06,0x02,0x01,0x02,0x00,0x00}},
>  /* Single Sequence Flag */
> +{ 0x8002, 
> {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x05,0x04,0x01,0x06,0x02,0x01,0x03,0x00,0x00}},
>  /* Constant B Picture Flag */
> +{ 0x8003, 
> {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x05,0x04,0x01,0x06,0x02,0x01,0x04,0x00,0x00}},
>  /* Coded Content Scanning Kind */
> +{ 0x8004, 
> {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x05,0x04,0x01,0x06,0x02,0x01,0x05,0x00,0x00}},
>  /* Low Delay Indicator */
> +{ 0x8005, 
> {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x05,0x04,0x01,0x06,0x02,0x01,0x06,0x00,0x00}},
>  /* Closed GOP Indicator */
> +{ 0x8006, 
> {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x05,0x04,0x01,0x06,0x02,0x01,0x07,0x00,0x00}},
>  /* Identical GOP */
> +{ 0x8008, 
> {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x05,0x04,0x01,0x06,0x02,0x01,0x08,0x00,0x00}},
>  /* Maximum GOP Size */
> +{ 0x8009, 
> {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x05,0x04,0x01,0x06,0x02,0x01,0x09,0x00,0x00}},
>  /* Maximum B Picture Count */
>  // Wave Audio Essence Descriptor
>  { 0x3D09, 
> {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x05,0x04,0x02,0x03,0x03,0x05,0x00,0x00,0x00}},
>  /* Average Bytes Per Second */
>  { 0x3D0A, 
> {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x05,0x04,0x02,0x03,0x02,0x01,0x00,0x00,0x00}},
>  /* Block Align */
> @@ -1203,7 +1212,10 @@ static void mxf_write_mpegvideo_desc(AVFormatContext 
> *s, AVStream *st)
>  int profile_and_level = (st->codecpar->profile<<4) | st->codecpar->level;
>  
>  if (st->codecpar->codec_id != AV_CODEC_ID_H264) {
> -mxf_write_cdci_common(s, st, mxf_mpegvideo_descriptor_key, 8+5);
> +AVCodecContext *avctx = st->codec;

> +MpegEncContext *mpeg = (avctx)?avctx->priv_data:NULL;

this is not ok
it breaks API and ABI, MpegEncContext can change without major
version bumps, its not even guranteed the
priv_data is a MpegEncContext also the data can be stream copied

you can only take information from AVStream, AVCodecParameters,
AVCodecContext side data and the AVPacket data and extradata

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

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


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


Re: [FFmpeg-devel] [PATCH] lavu: Adding hybrid-log gamma enum value and transfer function.

2016-06-01 Thread Michael Niedermayer
On Tue, May 31, 2016 at 09:02:44PM -0700, Neil Birkbeck wrote:
> Any other thoughts on we should move forward with the _ARIB_STD name
> or to use something like HYBRID_LOG_GAMMA?

patch applied as noone seems to objec tto the name judging from
the lack of comments to the patch

thx

[...]
-- 
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] FFPlay on a HLS stream skips audio from time to time.

2016-06-01 Thread Adrian Cruceru

Hi,

Patch is attached,

Quick notes:
- Playing HLS streams - FFPlay stalls a bit before each segment download
- Stalls accumulate and FFPlay falls behind
- We get log warning and segment skip.

Fix:
- Just make sure HLS is marked as a real time stream.

---
 ffplay.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/ffplay.c b/ffplay.c
index 11c5091..ed001cc 100644
--- a/ffplay.c
+++ b/ffplay.c
@@ -2801,6 +2801,7 @@ static int is_realtime(AVFormatContext *s)
 if(   !strcmp(s->iformat->name, "rtp")
|| !strcmp(s->iformat->name, "rtsp")
|| !strcmp(s->iformat->name, "sdp")
+   || !strcmp(s->iformat->name, "hls,applehttp")
 )
 return 1;

--
2.7.4

Thank you,
Adrian
>From cf7d13397b996eb0d4b97dadbf9b7250fd96e598 Mon Sep 17 00:00:00 2001
From: Adrian Cruceru 
Date: Wed, 1 Jun 2016 16:05:25 +0300
Subject: [PATCH] FFPlay on a HLS stream skips audio from time to time.

Log warning: "skipping %d segments ahead, expired from playlists" is displayed (hls.c:1290)
Online reports: http://ffmpeg.gusari.org/viewtopic.php?f=26&t=1444

Actual problem:
- FFPlay ends up with audio way behind streaming server
- This is because HLS works as a real time protocol using:
- - Large segments - download takes some time.
- - ffplay.c queues up at most 25 frames (lines 3068-3078) - which may be insufficient and cause slight stall in audio playback until next segment is downloaded.
- - stalls above accumulate to the point where ffplay does a skip-to-correct segment and jumps over some data. (This is done as server may remove segments as expired)

Fix:
- Quick option - and one in patch - just make sure we use infinite_buffer for hls as well. (mark it as real time)
- Alternative - increase buffer size to be larger then time it takes to download a segment.
---
 ffplay.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/ffplay.c b/ffplay.c
index 11c5091..ed001cc 100644
--- a/ffplay.c
+++ b/ffplay.c
@@ -2801,6 +2801,7 @@ static int is_realtime(AVFormatContext *s)
 if(   !strcmp(s->iformat->name, "rtp")
|| !strcmp(s->iformat->name, "rtsp")
|| !strcmp(s->iformat->name, "sdp")
+   || !strcmp(s->iformat->name, "hls,applehttp")
 )
 return 1;
 
-- 
2.7.4

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


Re: [FFmpeg-devel] [PATCH] avformat/isom: add MagicYUV FourCCs

2016-06-01 Thread Piotr Bandurski
samples:

https://www.datafilehost.com/d/e0a14440

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


[FFmpeg-devel] [PATCH] avformat/isom: add MagicYUV FourCCs

2016-06-01 Thread Piotr Bandurski


0001-avformat-isom-add-MagicYUV-FourCCs.diff
Description: Binary data
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] Looking for C++ developer with ffmpeg library experience for hire

2016-06-01 Thread Ragnar Rüütel

Hi all,

I have small project where I need to capture windows desktop screen(s) 
on client PC and save it as video file (MP4 container and h264 codec) on 
server. I've managed to get some screen capture samples working on my 
own but my understanding of FFmpeg is quite limited so I need help from 
someone with much more experience with FFmpeg.


I have two Visual Studio 2015 projects (client and server) which have 
all the necessary parts in place.


The applications work cycle must be following:
1. Server sends start signal (already done)
2. Client starts GDI capturing
3. After couple of seconds of capture, Client resamples captured screen 
(to save bandwidth) and sends it to Server
4. Server receives screen data, converts it to h264/mp4 and saves it to 
disk.

 ... 3 and 4 are repeated until ...
5. Server sends stop signal (also done)
6. Client stops GDI capturing and sends final part of screen capture to 
Server

7- Server saves final part of screen capture to MP4 file

Requirements:
1. Must work on most Windows versions (7/8.1/10/etc)
2. The mp4 file on Server must be playable after every screen addition 
since client might go away before Server sends stop signal.

3. Client cant have external dependencies (expect FFmpeg of course).
4. On multi screen Client there should be option to select which (or 
all) screen to capture (provided with start signal from Server).
5. Option to set screen resolution, color depth and frame rate (provided 
with start signal from Server).

6. CPU and memory usage on client should be as low as possible.

If You're interested then email me(rax +at+ aweroc +dot+ com) Your offer 
and payment terms.


Please post additional questions here.

With Regards,
Ragnar

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


Re: [FFmpeg-devel] [PATCH] avcodec: add MagicYUV decoder

2016-06-01 Thread Christophe Gisquet
2016-05-30 17:50 GMT+02:00 Paul B Mahol :
> On 5/30/16, Piotr Bandurski  wrote:
>> Hi,
>>
>>> patch attached.
>>
>> Is decoding of interlaced video supported? Because I get here invalid
>> output.
>>
>> Also crash happens with this fuzzed file:
>>
>> https://www.datafilehost.com/d/c64eb5b1
>>
>> Regards
>
> Can you create YUVA video somehow? I can't with virtualdub.

So a final iteration was pushed.

Can any of you create fate tests, ideally for 3 cases,
"normal"/"interlaced"/"YUVA" (or whatever required introducing quirks
in the code)

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


[FFmpeg-devel] MetaData in Sun AU format

2016-06-01 Thread miniupnp
Hello,

I'm using the .AU audio file format and noticed that FFmpeg always put 8
zero's in the annotation field.
SOX does use the annotation field to put metadata
(Title/Author/Album/Genre/Track)

I don't think there is any precise specification for this AU annotation
field as long as it is a null terminated character string, but what SOX
does looks good.

Attached are my patches to write metadata to AU files.

Regards,

Thomas Bernard

From 7a1fb8a24ee54187412adfe1a466702b6353edbb Mon Sep 17 00:00:00 2001
From: Thomas Bernard 
Date: Tue, 31 May 2016 22:47:20 +0200
Subject: [PATCH 2/2] Adjust reference data for AU Sun audio in consequence of
 addition of MetaData in header

---
 tests/ref/lavf/au  |4 ++--
 tests/ref/seek/lavf-au |   30 +++---
 2 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/tests/ref/lavf/au b/tests/ref/lavf/au
index ede4926..dcd02f3 100644
--- a/tests/ref/lavf/au
+++ b/tests/ref/lavf/au
@@ -1,3 +1,3 @@
-aa5ec1f82ac07c653ffc527b0f0dc10d *./tests/data/lavf/lavf.au
-88232 ./tests/data/lavf/lavf.au
+5228ad3783888c45a08dac5ab6118794 *./tests/data/lavf/lavf.au
+88240 ./tests/data/lavf/lavf.au
 ./tests/data/lavf/lavf.au CRC=0x3a1da17e
diff --git a/tests/ref/seek/lavf-au b/tests/ref/seek/lavf-au
index d5a70b2..8edce58 100644
--- a/tests/ref/seek/lavf-au
+++ b/tests/ref/seek/lavf-au
@@ -1,53 +1,53 @@
-ret: 0 st: 0 flags:1 dts: 0.00 pts: 0.00 pos: 32 size:  2048
+ret: 0 st: 0 flags:1 dts: 0.00 pts: 0.00 pos: 40 size:  2048
 ret: 0 st:-1 flags:0  ts:-1.00
-ret: 0 st: 0 flags:1 dts: 0.00 pts: 0.00 pos: 32 size:  2048
+ret: 0 st: 0 flags:1 dts: 0.00 pts: 0.00 pos: 40 size:  2048
 ret: 0 st:-1 flags:1  ts: 1.894167
 ret:-EOF
 ret: 0 st: 0 flags:0  ts: 0.788345
-ret: 0 st: 0 flags:1 dts: 0.788345 pts: 0.788345 pos:  69564 size:  2048
+ret: 0 st: 0 flags:1 dts: 0.788345 pts: 0.788345 pos:  69572 size:  2048
 ret: 0 st: 0 flags:1  ts:-0.317506
-ret: 0 st: 0 flags:1 dts: 0.00 pts: 0.00 pos: 32 size:  2048
+ret: 0 st: 0 flags:1 dts: 0.00 pts: 0.00 pos: 40 size:  2048
 ret: 0 st:-1 flags:0  ts: 2.576668
 ret:-EOF
 ret: 0 st:-1 flags:1  ts: 1.470835
 ret:-EOF
 ret: 0 st: 0 flags:0  ts: 0.365011
-ret: 0 st: 0 flags:1 dts: 0.365011 pts: 0.365011 pos:  32226 size:  2048
+ret: 0 st: 0 flags:1 dts: 0.365011 pts: 0.365011 pos:  32234 size:  2048
 ret: 0 st: 0 flags:1  ts:-0.740839
-ret: 0 st: 0 flags:1 dts: 0.00 pts: 0.00 pos: 32 size:  2048
+ret: 0 st: 0 flags:1 dts: 0.00 pts: 0.00 pos: 40 size:  2048
 ret: 0 st:-1 flags:0  ts: 2.153336
 ret:-EOF
 ret: 0 st:-1 flags:1  ts: 1.047503
 ret:-EOF
 ret: 0 st: 0 flags:0  ts:-0.058322
-ret: 0 st: 0 flags:1 dts: 0.00 pts: 0.00 pos: 32 size:  2048
+ret: 0 st: 0 flags:1 dts: 0.00 pts: 0.00 pos: 40 size:  2048
 ret: 0 st: 0 flags:1  ts: 2.835828
 ret:-EOF
 ret: 0 st:-1 flags:0  ts: 1.730004
 ret:-EOF
 ret: 0 st:-1 flags:1  ts: 0.624171
-ret: 0 st: 0 flags:1 dts: 0.624172 pts: 0.624172 pos:  55084 size:  2048
+ret: 0 st: 0 flags:1 dts: 0.624172 pts: 0.624172 pos:  55092 size:  2048
 ret: 0 st: 0 flags:0  ts:-0.481655
-ret: 0 st: 0 flags:1 dts: 0.00 pts: 0.00 pos: 32 size:  2048
+ret: 0 st: 0 flags:1 dts: 0.00 pts: 0.00 pos: 40 size:  2048
 ret: 0 st: 0 flags:1  ts: 2.412494
 ret:-EOF
 ret: 0 st:-1 flags:0  ts: 1.306672
 ret:-EOF
 ret: 0 st:-1 flags:1  ts: 0.200839
-ret: 0 st: 0 flags:1 dts: 0.200839 pts: 0.200839 pos:  17746 size:  2048
+ret: 0 st: 0 flags:1 dts: 0.200839 pts: 0.200839 pos:  17754 size:  2048
 ret: 0 st: 0 flags:0  ts:-0.904989
-ret: 0 st: 0 flags:1 dts: 0.00 pts: 0.00 pos: 32 size:  2048
+ret: 0 st: 0 flags:1 dts: 0.00 pts: 0.00 pos: 40 size:  2048
 ret: 0 st: 0 flags:1  ts: 1.989184
 ret:-EOF
 ret: 0 st:-1 flags:0  ts: 0.883340
-ret: 0 st: 0 flags:1 dts: 0.88 pts: 0.88 pos:  77942 size:  2048
+ret: 0 st: 0 flags:1 dts: 0.88 pts: 0.88 pos:  77950 size:  2048
 ret: 0 st:-1 flags:1  ts:-0.222493
-ret: 0 st: 0 flags:1 dts: 0.00 pts: 0.00 pos: 32 size:  2048
+ret: 0 st: 0 flags:1 dts: 0.00 pts: 0.00 pos: 40 size:  2048
 ret: 0 st: 0 flags:0  ts: 2.671678
 ret:-EOF
 ret: 0 st: 0 flags:1  ts: 1.565850
 ret:-EOF
 ret: 0 st:-1 flags:0  ts: 0.460008
-ret: 0 st: 0 flags:1 dts: 0.46 pts: 0.46 pos:  40604 size:  2048
+ret: 0 st: 0 flags:1 dts: 0.46 pts: 0.46 pos:  40612 size:  2048
 ret: 0 st:-1 flags:1  ts:-0.645825
-ret: 0 st: 0 flags:1 dts: 0.00 pts: 0.00 p

Re: [FFmpeg-devel] [PATCH 1/2] lavc/mediacodecdec_h264: switch to new BSF API

2016-06-01 Thread Matthieu Bouron
On Tue, May 31, 2016 at 10:13:40AM +0200, Matthieu Bouron wrote:
> On Sun, May 29, 2016 at 10:15:44AM +0200, Matthieu Bouron wrote:
> > On Fri, May 27, 2016 at 10:13:20AM +0200, Matthieu Bouron wrote:
> > > From: Matthieu Bouron 
> > > 
> > > ---
> > >  libavcodec/mediacodecdec_h264.c | 61 
> > > +
> > >  1 file changed, 37 insertions(+), 24 deletions(-)
> > > 
> > > diff --git a/libavcodec/mediacodecdec_h264.c 
> > > b/libavcodec/mediacodecdec_h264.c
> > > index 2d1d525..7f764e9 100644
> > > --- a/libavcodec/mediacodecdec_h264.c
> > > +++ b/libavcodec/mediacodecdec_h264.c
> > > @@ -23,6 +23,7 @@
> > >  #include 
> > >  #include 
> > >  
> > > +#include "libavutil/avassert.h"
> > >  #include "libavutil/common.h"
> > >  #include "libavutil/fifo.h"
> > >  #include "libavutil/opt.h"
> > > @@ -41,13 +42,11 @@ typedef struct MediaCodecH264DecContext {
> > >  
> > >  MediaCodecDecContext ctx;
> > >  
> > > -AVBitStreamFilterContext *bsf;
> > > +AVBSFContext *bsf;
> > >  
> > >  AVFifoBuffer *fifo;
> > >  
> > > -AVPacket input_ref;
> > >  AVPacket filtered_pkt;
> > > -uint8_t *filtered_data;
> > >  
> > >  } MediaCodecH264DecContext;
> > >  
> > > @@ -156,8 +155,9 @@ static av_cold int 
> > > mediacodec_decode_close(AVCodecContext *avctx)
> > >  ff_mediacodec_dec_close(avctx, &s->ctx);
> > >  
> > >  av_fifo_free(s->fifo);
> > > +av_bsf_free(&s->bsf);
> > >  
> > > -av_bitstream_filter_close(s->bsf);
> > > +av_packet_unref(&s->filtered_pkt);
> > >  
> > >  return 0;
> > >  }
> > > @@ -211,12 +211,23 @@ static av_cold int 
> > > mediacodec_decode_init(AVCodecContext *avctx)
> > >  goto done;
> > >  }
> > >  
> > > -s->bsf = av_bitstream_filter_init("h264_mp4toannexb");
> > > -if (!s->bsf) {
> > > -ret = AVERROR(ENOMEM);
> > > +const AVBitStreamFilter *bsf = 
> > > av_bsf_get_by_name("h264_mp4toannexb");
> > > +if(!bsf) {
> > > +ret = AVERROR_BSF_NOT_FOUND;
> > >  goto done;
> > >  }
> > >  
> > > +if ((ret = av_bsf_alloc(bsf, &s->bsf))) {
> > > +goto done;
> > > +}
> > > +
> > > +if (((ret = avcodec_parameters_from_context(s->bsf->par_in, avctx)) 
> > > < 0) ||
> > > +((ret = av_bsf_init(s->bsf)) < 0)) {
> > > +  goto done;
> > > +}
> > > +
> > > +av_init_packet(&s->filtered_pkt);
> > > +
> > >  done:
> > >  if (format) {
> > >  ff_AMediaFormat_delete(format);
> > > @@ -265,7 +276,9 @@ static int mediacodec_decode_frame(AVCodecContext 
> > > *avctx, void *data,
> > >  while (!*got_frame) {
> > >  /* prepare the input data -- convert to Annex B if needed */
> > >  if (s->filtered_pkt.size <= 0) {
> > > -int size;
> > > +AVPacket input_pkt = { 0 };
> > > +
> > > +av_packet_unref(&s->filtered_pkt);
> > >  
> > >  /* no more data */
> > >  if (av_fifo_size(s->fifo) < sizeof(AVPacket)) {
> > > @@ -273,22 +286,24 @@ static int mediacodec_decode_frame(AVCodecContext 
> > > *avctx, void *data,
> > >  ff_mediacodec_dec_decode(avctx, &s->ctx, frame, 
> > > got_frame, avpkt);
> > >  }
> > >  
> > > -if (s->filtered_data != s->input_ref.data)
> > > -av_freep(&s->filtered_data);
> > > -s->filtered_data = NULL;
> > > -av_packet_unref(&s->input_ref);
> > > +av_fifo_generic_read(s->fifo, &input_pkt, sizeof(input_pkt), 
> > > NULL);
> > > +
> > > +ret = av_bsf_send_packet(s->bsf, &input_pkt);
> > > +if (ret < 0) {
> > > +return ret;
> > > +}
> > > +
> > > +ret = av_bsf_receive_packet(s->bsf, &s->filtered_pkt);
> > > +if (ret == AVERROR(EAGAIN)) {
> > > +goto done;
> > > +}
> > > +
> > > +/* h264_mp4toannexb is used here and does not require 
> > > flushing */
> > > +av_assert0(ret != AVERROR_EOF);
> > >  
> > > -av_fifo_generic_read(s->fifo, &s->input_ref, 
> > > sizeof(s->input_ref), NULL);
> > > -ret = av_bitstream_filter_filter(s->bsf, avctx, NULL,
> > > - &s->filtered_data, &size,
> > > - s->input_ref.data, 
> > > s->input_ref.size, 0);
> > >  if (ret < 0) {
> > > -s->filtered_data = s->input_ref.data;
> > > -size = s->input_ref.size;
> > > +return ret;
> > >  }
> > > -s->filtered_pkt  = s->input_ref;
> > > -s->filtered_pkt.data = s->filtered_data;
> > > -s->filtered_pkt.size = size;
> > >  }
> > >  
> > >  ret = mediacodec_process_data(avctx, frame, got_frame, 
> > > &s->filtered_pkt);
> > > @@ -298,7 +313,7 @@ static int mediacodec_decode_frame(AVCodecContext 
> > > *avctx, void

[FFmpeg-devel] [PATCH] avformat: Add Pro-MPEG CoP #3-R2 FEC protocol

2016-06-01 Thread Vlad Tarca
Pro-MPEG Code of Practice #3 release 2 forward error correction for rtp_mpegts 
streams

Fixes:

[prompeg.c]
- proper RTP size check to fit the largest buffer
- UDP port overflow check
- replaced ffurl_close calls with ffurl_closep
[rtpproto.c]
- removed context fec flag and used fec_hd directly
- moved fec_hd open outside the retry loop as it doesn't set any specific local 
ports
- replaced ffurl_close call with ffurl_closep

Signed-off-by: Vlad Tarca 
---
 Changelog   |   1 +
 doc/general.texi|   1 +
 doc/protocols.texi  |  35 
 libavformat/Makefile|   1 +
 libavformat/prompeg.c   | 487 
 libavformat/protocols.c |   1 +
 libavformat/rtpproto.c  |  62 +-
 7 files changed, 585 insertions(+), 3 deletions(-)
 create mode 100644 libavformat/prompeg.c

diff --git a/Changelog b/Changelog
index 697b430..34bc23a 100644
--- a/Changelog
+++ b/Changelog
@@ -37,6 +37,7 @@ version :
 - Direct Stream Transfer (DST) decoder
 - loudnorm filter
 - MTAF demuxer and decoder
+- Pro-MPEG CoP #3-R2 FEC protocol
 
 version 3.0:
 - Common Encryption (CENC) MP4 encoding and decoding support
diff --git a/doc/general.texi b/doc/general.texi
index 2d3dd0b..80a434a 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -1126,6 +1126,7 @@ performance on systems without hardware floating point 
support).
 @item MMSH @tab X
 @item MMST @tab X
 @item pipe @tab X
+@item Pro-MPEG FEC @tab X
 @item RTMP @tab X
 @item RTMPE@tab X
 @item RTMPS@tab X
diff --git a/doc/protocols.texi b/doc/protocols.texi
index a9c9d0c..875fdac 100644
--- a/doc/protocols.texi
+++ b/doc/protocols.texi
@@ -513,6 +513,41 @@ time, which is valuable if data transmission is slow.
 Note that some formats (typically MOV), require the output protocol to
 be seekable, so they will fail with the pipe output protocol.
 
+@section prompeg
+
+Pro-MPEG Code of Practice #3 Release 2 FEC protocol.
+
+The Pro-MPEG CoP#3 FEC is a 2D parity-check forward error correction mechanism
+for MPEG-2 Transport Streams sent over RTP.
+
+This protocol must be used in conjunction with the @code{rtp_mpegts} muxer and
+the @code{rtp} protocol.
+
+The required syntax is:
+@example
+-f rtp_mpegts -fec prompeg=@var{option}=@var{val}... 
rtp://@var{hostname}:@var{port}
+@end example
+
+The destination UDP ports are @code{port + 2} for the column FEC stream
+and @code{port + 4} for the row FEC stream.
+
+This protocol accepts the following options:
+@table @option
+
+@item l=@var{n}
+The number of columns (4-20, LxD <= 100)
+
+@item d=@var{n}
+The number of rows (4-20, LxD <= 100)
+
+@end table
+
+Example usage:
+
+@example
+-f rtp_mpegts -fec prompeg=l=8:d=4 rtp://@var{hostname}:@var{port}
+@end example
+
 @section rtmp
 
 Real-Time Messaging Protocol.
diff --git a/libavformat/Makefile b/libavformat/Makefile
index 6684ead..90d7587 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -547,6 +547,7 @@ OBJS-$(CONFIG_MD5_PROTOCOL)  += md5proto.o
 OBJS-$(CONFIG_MMSH_PROTOCOL) += mmsh.o mms.o asf.o
 OBJS-$(CONFIG_MMST_PROTOCOL) += mmst.o mms.o asf.o
 OBJS-$(CONFIG_PIPE_PROTOCOL) += file.o
+OBJS-$(CONFIG_PROMPEG_PROTOCOL)  += prompeg.o
 OBJS-$(CONFIG_RTMP_PROTOCOL) += rtmpproto.o rtmppkt.o
 OBJS-$(CONFIG_RTMPE_PROTOCOL)+= rtmpproto.o rtmppkt.o
 OBJS-$(CONFIG_RTMPS_PROTOCOL)+= rtmpproto.o rtmppkt.o
diff --git a/libavformat/prompeg.c b/libavformat/prompeg.c
new file mode 100644
index 000..d4beb19
--- /dev/null
+++ b/libavformat/prompeg.c
@@ -0,0 +1,487 @@
+/*
+ * Pro-MPEG Code of Practice #3 Release 2 FEC
+ * Copyright (c) 2016 Mobibase, France (http://www.mobibase.com)
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file
+ * Pro-MPEG Code of Practice #3 Release 2 FEC protocol
+ * @author Vlad Tarca 
+ */
+
+/*
+ * Reminder:
+
+ [RFC 2733] FEC Packet Structure
+
+   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+   | RTP Header|
+   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+   | FEC Header|
+   +-

Re: [FFmpeg-devel] [PATCH]Filter: Add snapshot filter. It is enable to save snapshot.

2016-06-01 Thread kl222
> On 28.05.2016 07:31, kl222 wrote:
> > On 27.05.2016 13:49, Nicolas George wrote:
> >> Can you explain your use case for this filter?
> >>
> >> I ask because I am very uncomfortable with filters that perform
> >> direct output instead of producing frames for the rest of the graph.
> >> They need to duplicate the encoding and muxing code, usually with
> >> fewer options and features, and that duplicated code becomes itself a
> >> maintenance burden in case of API changes and such.
> >>
> >> IMHO, a better solution would be some kind of "interactive select"
> >> (or just an option of plain select) filter, and encode its output as 
> >> image2.
> >>
> >
> > I want to implement to the snapshot function whenever push stream, and
> > set the file name of snapshot picture.
> > this function can snapshot pictures before, between or after the other 
> > filters.
> > Because I want to change the file in filter, so duplicate the encoding
> > and muxing code can not be avoided.
> > OK, add it to "select" filter and a single filter patch. Chosen by you. see
> annex.
> 
> The way you added it to the select filter it still uses own muxing code and
> doesn't allow to take full advantage of output format options.
> 
> To give an idea what I had in mind when suggesting the select filter: The
> following command uses current FFmpeg code to generate snapshot files of the
> first two video
> frames:
> 
> ffmpeg -i input-file.avi -f image2 -q 5 -filter:v "select=lt(selected_n\,2)" 
> -y
> snapshot-%03d.jpg
> 
> Now if the select filter code would be improved to allow updating the 
> evaluated
> expression at run-time, sending filter commands like
> 
> expr lt(selected_n,2)  // save two snapshot files expr lt(selected_n,3)  // 
> add
> another snapshot file expr lt(selected_n,4)  // add another snapshot file
> 
> could be used to trigger saving snapshot files on demand.
> 

I understand your usage scenario. But I am not specified snapshot file name on 
the command line. But it needs to be updated it is, another program specified 
file name. So, I think as a separate filter is better.


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