Re: [FFmpeg-devel] [PATCH] avdevice/decklink: adjust for timecode lag

2019-08-20 Thread Gyan



On 19-08-2019 07:15 PM, Ilinca Tudose wrote:

Hi Marton,

I want to confirm that we get correctly synced TCs when leaving out the
format_code parameter and using an ffmpeg build from head (not with Gyan's
patch). However, I was under the impression that we need the format_code so
that we can capture different content types, in the original format. For
example multiple frame rates or interlaced content. How would we set this
up if we are not using format_code? Is this identified automatically?


A couple of follow-up Qs:

Is auto-detection available for all Decklink devices?

For those for which it is available, are there any edge cases in which 
it sets inaccurate mode?


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

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

Re: [FFmpeg-devel] [PATCH] libavcodec: add editpts bitstream filter [v4]

2019-08-20 Thread Andreas Håkon
Ping!

‐‐‐ Original Message ‐‐‐
On Friday, 16 de August de 2019 12:19, Andreas Håkon 
 wrote:

> Hi,
>
> The latest version ready to merge of the bitstream filter "editpts".
> Implements all requests.
>
> This supersedes:
>
> https://patchwork.ffmpeg.org/patch/14302/
>
> https://patchwork.ffmpeg.org/patch/14195/
>
> https://patchwork.ffmpeg.org/patch/13743/
>
> https://patchwork.ffmpeg.org/patch/13699/

And I explain the reason for this filter:
- When there is a slight misalignment in some stream, for example a lipsync 
failure,
it's possible to compensate such misalignment without having to recompress any 
stream.
Just by applying this filter you can do all the work.

Regards.
A.H.

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

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

Re: [FFmpeg-devel] [PATCH 1/3] avcodec/alsdec: Limit maximum channels to 64

2019-08-20 Thread Thilo Borgmann
Am 19.08.19 um 23:22 schrieb Michael Niedermayer:
> On Mon, Aug 19, 2019 at 05:09:37PM +0200, Thilo Borgmann wrote:
>> Am 19.08.19 um 14:27 schrieb Michael Niedermayer:
>>> On Mon, Aug 19, 2019 at 07:41:43AM +0200, Thilo Borgmann wrote:
 Am 19.08.19 um 01:30 schrieb Michael Niedermayer:
> There seems to be no limit in the specification and upto 64k could be 
> stored
> 64 is chooses as limit as thats also used for AAC and is what a int64 mask
> can handle
>
> An alternative to this patch would be a max_channels variable

 There's a conformance file containing 512 channels, that should be the 
 default max value.
>>>
>>> will apply with that value later
>>
>> Decoding of that is already stopped via FF_SANE_NB_CHANNELS in 
>> lavc/internal.h.
>> That is currently set to 256U. I guess pushing that to 512U might already be 
>> enough without any change to single decoders?
> 
> the problem of out of memory is that the als decoder allocates some pretty
> large things per channel. A check on channels needs to happen before
> this.
> The existing checks didnt achieve that.
> 
> I can of course post a patchset that uses FF_SANE_NB_CHANNELS in als and
> bump it to the next number if people prefer this ?
> 
> Note though that increasing FF_SANE_NB_CHANNELS may also increase timeouts
> in other decoders.

I see the problem.
However, right now alsdec is fine with any number of channels and the CLI 
prevents decoding anything above FF_SANE_NB_CHANNELS (checks are in 
lavc/decoding.c and lavc/utils.c; this would also stop any FATE test on 512 
channels file).

So having alsdec check for a value higher than FF_SANE_NB_CHANNELS (like 512) 
would have no effect for CLI users, right?

-Thilo

>> Once fixed, I will add a FATE test for the 512 channel conformance file.
> 
> thx
> 
>>
>> -Thilo
>> ___
>> ffmpeg-devel mailing list
>> ffmpeg-devel@ffmpeg.org
>> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>
>> To unsubscribe, visit link above, or email
>> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
> 
> 
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
> 

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

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

Re: [FFmpeg-devel] [PATCH v2] hevc_mp4toannexb: Insert correct parameter sets before IRAP

2019-08-20 Thread Andreas Rheinhardt
Hello,

I have not looked at the *PS and the SEI stuff yet, but here is
already my review of the general code.

Andriy Gelman:
> From: Andriy Gelman 
> 
> Fixes #7799
> 
> Currently, the mp4toannexb filter always inserts the same extradata at
> the start of the first IRAP unit. As in ticket #7799, this can lead to
> decoding errors if modified parameter sets are signalled in-band.
> 
> This commit keeps track of the vps/sps/pps parameter sets during the
> conversion. The correct combination is inserted at the start of the
> first IRAP unit instead of the original extradata. SEI prefix nal units
> are also cached and inserted after the parameter sets.
> 
> This commit also makes an update to the hevc-bsf-mp4toannexb fate
> test since the result before this patch contained duplicate vps/sps/pps
> parameter sets in-band.
> ---
>  libavcodec/hevc_mp4toannexb_bsf.c | 475 +++---
>  tests/fate/hevc.mak   |   2 +-
>  2 files changed, 437 insertions(+), 40 deletions(-)
> 
> diff --git a/libavcodec/hevc_mp4toannexb_bsf.c 
> b/libavcodec/hevc_mp4toannexb_bsf.c
> index 09bce5b34c..7f3d68252d 100644
> --- a/libavcodec/hevc_mp4toannexb_bsf.c
> +++ b/libavcodec/hevc_mp4toannexb_bsf.c
> @@ -28,19 +28,212 @@
>  #include "bsf.h"
>  #include "bytestream.h"
>  #include "hevc.h"
> -
> -#define MIN_HEVCC_LENGTH 23
> +#include "h2645_parse.h"
> +#include "hevc_ps.h"
> +#include "golomb.h"
> +
> +#define MIN_HEVCC_LENGTH23
> +#define PROFILE_WITHOUT_IDC_BITS88
> +#define IS_IRAP(s)  ((s)->type >= 16 && (s)->type <= 23)
> +#define IS_PARAMSET(s)  ((s)->type >= 32 && (s)->type <= 34)
> +
> +#define WRITE_NAL(pkt, prev_size, in_buffer) do {
> \
> +AV_WB32((pkt)->data + (prev_size), 1);   
> \
> +prev_size += 4;  
> \
> +memcpy((pkt)->data + (prev_size), (in_buffer)->data, (in_buffer)->size); 
> \
> +prev_size += (in_buffer)->size;  
> \
> +} while (0)
> +
> +typedef struct Param {
> +AVBufferRef *raw_data; /*store a copy of the raw data to construct 
> extradata*/
> +int ref;  /*stores the ref of the higher level parameter set*/
> +} Param;
> +
> +/*modified version of HEVCParamSets to store bytestream and reference to 
> previous level*/
> +typedef struct ParamSets {
> +Param vps_list[HEVC_MAX_VPS_COUNT];
> +Param sps_list[HEVC_MAX_SPS_COUNT];
> +Param pps_list[HEVC_MAX_PPS_COUNT];
> +
> +AVBufferRef *sei_prefix;
> +} ParamSets;
>  
>  typedef struct HEVCBSFContext {
> -uint8_t  length_size;
> -int  extradata_parsed;
> +uint8_t  length_size;
> +int  extradata_parsed;
> +ParamSetsps; /*make own of version of HEVCParamSets store copy of 
> the bytestream*/
>  } HEVCBSFContext;
>  
> +
> +static int parse_vps(AVBSFContext* ctx, H2645NAL *nal)
> +{
> +int vps_id = 0;
> +Param *param_ptr;
> +
> +HEVCBSFContext *s = ctx->priv_data;
> +ParamSets *ps = >ps;
> +
> +GetBitContext *gb = >gb;
> +int nal_size  = nal->raw_size;
> +
> +vps_id = get_bits(gb, 4);
> +if (vps_id >= HEVC_MAX_VPS_COUNT) {
> +av_log(ctx, AV_LOG_ERROR, "VPS id out of range: %d\n", vps_id);
> +return AVERROR_INVALIDDATA;
> +}
> +
> +param_ptr = >vps_list[vps_id];
> +/*init raw_data if needed*/
> +if (!param_ptr->raw_data) {
> +param_ptr->raw_data = av_buffer_allocz(nal_size);
> +param_ptr->ref  = 0;
> +if (!param_ptr->raw_data)
> +return AVERROR(ENOMEM);
> +}
> +
> +if (param_ptr->raw_data && param_ptr->raw_data->size == nal_size &&
> +!memcmp(param_ptr->raw_data->data, nal->raw_data, nal_size)) {
> +av_log(ctx, AV_LOG_DEBUG, "Parsed VPS id: %d. Copy already exists in 
> parameter set\n", vps_id);
> +} else {
> +AVBufferRef *vps_buf = av_buffer_allocz(nal_size);
> +if (!vps_buf)
> +return AVERROR(ENOMEM);
> +
> +/*copy raw data into vps_buf buffer and replace existing copy in ps*/
> +memcpy(vps_buf->data, nal->raw_data, nal_size);
> +av_buffer_unref(_ptr->raw_data);
> +param_ptr->raw_data = vps_buf;
> +}
> +return 0;
> +}
> +
> +static int parse_sps(AVBSFContext *ctx, H2645NAL *nal)
> +{
> +int sps_id, vps_ref, max_sub_layers_minus1;
> +int i;
> +Param *param_ptr;
> +
> +HEVCBSFContext *s = (HEVCBSFContext*)ctx->priv_data;
> +ParamSets *ps = >ps;
> +
> +GetBitContext *gb = >gb;
> +int nal_size  = nal->raw_size;
> +
> +uint8_t sub_layer_profile_present_flag[HEVC_MAX_SUB_LAYERS];
> +uint8_t sub_layer_level_present_flag[HEVC_MAX_SUB_LAYERS];
> +
> +vps_ref = get_bits(gb, 4);
> +if (vps_ref >= HEVC_MAX_VPS_COUNT) {
> +av_log(ctx, AV_LOG_ERROR, "VPS id out of range: %d\n", vps_ref);
> +return 

[FFmpeg-devel] [PATCH 1/2] avcodec/vp5/6/8: use vpX_rac_is_end()

2019-08-20 Thread Michael Niedermayer
Signed-off-by: Michael Niedermayer 
---
 libavcodec/vp5.c | 2 +-
 libavcodec/vp6.c | 2 +-
 libavcodec/vp8.c | 8 
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/libavcodec/vp5.c b/libavcodec/vp5.c
index 49988b8b76..0fca282918 100644
--- a/libavcodec/vp5.c
+++ b/libavcodec/vp5.c
@@ -183,7 +183,7 @@ static int vp5_parse_coeff(VP56Context *s)
 int b, i, cg, idx, ctx, ctx_last;
 int pt = 0;/* plane type (0 for Y, 1 for U or V) */
 
-if (c->end <= c->buffer && c->bits >= 0) {
+if (vpX_rac_is_end(c)) {
 av_log(s->avctx, AV_LOG_ERROR, "End of AC stream reached in 
vp5_parse_coeff\n");
 return AVERROR_INVALIDDATA;
 }
diff --git a/libavcodec/vp6.c b/libavcodec/vp6.c
index 977fcb7076..e5dec19f50 100644
--- a/libavcodec/vp6.c
+++ b/libavcodec/vp6.c
@@ -473,7 +473,7 @@ static int vp6_parse_coeff(VP56Context *s)
 int b, i, cg, idx, ctx;
 int pt = 0;/* plane type (0 for Y, 1 for U or V) */
 
-if (c->end <= c->buffer && c->bits >= 0) {
+if (vpX_rac_is_end(c)) {
 av_log(s->avctx, AV_LOG_ERROR, "End of AC stream reached in 
vp6_parse_coeff\n");
 return AVERROR_INVALIDDATA;
 }
diff --git a/libavcodec/vp8.c b/libavcodec/vp8.c
index efc62aabaf..eb51d1f3c9 100644
--- a/libavcodec/vp8.c
+++ b/libavcodec/vp8.c
@@ -658,7 +658,7 @@ static int vp7_decode_frame_header(VP8Context *s, const 
uint8_t *buf, int buf_si
 s->fade_present = vp8_rac_get(c);
 }
 
-if (c->end <= c->buffer && c->bits >= 0)
+if (vpX_rac_is_end(c))
 return AVERROR_INVALIDDATA;
 /* E. Fading information for previous frame */
 if (s->fade_present && vp8_rac_get(c)) {
@@ -693,7 +693,7 @@ static int vp7_decode_frame_header(VP8Context *s, const 
uint8_t *buf, int buf_si
 vp78_update_pred16x16_pred8x8_mvc_probabilities(s, VP7_MVC_SIZE);
 }
 
-if (c->end <= c->buffer && c->bits >= 0)
+if (vpX_rac_is_end(c))
 return AVERROR_INVALIDDATA;
 
 if ((ret = vp7_fade_frame(s, alpha, beta)) < 0)
@@ -2375,7 +2375,7 @@ static av_always_inline int 
decode_mb_row_no_filter(AVCodecContext *avctx, void
 curframe->tf.f->data[2] +  8 * mb_y * s->uvlinesize
 };
 
-if (c->end <= c->buffer && c->bits >= 0)
+if (vpX_rac_is_end(c))
  return AVERROR_INVALIDDATA;
 
 if (mb_y == 0)
@@ -2406,7 +2406,7 @@ static av_always_inline int 
decode_mb_row_no_filter(AVCodecContext *avctx, void
 td->mv_bounds.mv_max.x = ((s->mb_width - 1) << 6) + MARGIN;
 
 for (mb_x = 0; mb_x < s->mb_width; mb_x++, mb_xy++, mb++) {
-if (c->end <= c->buffer && c->bits >= 0)
+if (vpX_rac_is_end(c))
 return AVERROR_INVALIDDATA;
 // Wait for previous thread to read mb_x+2, and reach mb_y-1.
 if (prev_td != td) {
-- 
2.23.0

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

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

[FFmpeg-devel] [PATCH] small v360 improvements

2019-08-20 Thread Paul B Mahol
Hi,

patches attached.


0001-doc-filters-fix-v360-options-names.patch
Description: Binary data


0002-add-v360-to-Changelog.patch
Description: Binary data


0003-doc-filters-fix-typos.patch
Description: Binary data


0004-avfilter-vf_v360-improve-comments-above-headers.patch
Description: Binary data


0005-avfilter-vf_v360-remove-unused-header.patch
Description: Binary data
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

[FFmpeg-devel] [PATCH 2/2] avcodec/vp56rac: delay signaling an error on truncated input

2019-08-20 Thread Michael Niedermayer
A threshold of 1 is sufficient for simple_dump_cut.webm, 10 is used
just to be sure the next truncated file doesnt cause the same issue

Obvious alternative fixes are to simply accept that the file is broken or to
write some advanced error concealment or to
simply accept that the decoder wont stop at the end of input.

Fixes: Ticket 8069 (artifacts not the differing md5 which was there before 
1afd246960202917e244c844c534e9c1e3c323f5)
Fixes: simple_dump_cut.webm
Fixes: regression of 1afd246960202917e244c844c534e9c1e3c323f5

fate-vp5 changes because the last frame is truncated and now handled
differently.

Signed-off-by: Michael Niedermayer 
---
 libavcodec/vp56.h| 5 -
 libavcodec/vp56rac.c | 1 +
 tests/ref/fate/vp5   | 2 +-
 3 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/libavcodec/vp56.h b/libavcodec/vp56.h
index 84b2f6c94b..65cf46870a 100644
--- a/libavcodec/vp56.h
+++ b/libavcodec/vp56.h
@@ -89,6 +89,7 @@ typedef struct VP56RangeCoder {
 const uint8_t *buffer;
 const uint8_t *end;
 unsigned int code_word;
+int end_reached;
 } VP56RangeCoder;
 
 typedef struct VP56RefDc {
@@ -235,7 +236,9 @@ int ff_vp56_init_range_decoder(VP56RangeCoder *c, const 
uint8_t *buf, int buf_si
  */
 static av_always_inline int vpX_rac_is_end(VP56RangeCoder *c)
 {
-return c->end <= c->buffer && c->bits >= 0;
+if (c->end <= c->buffer && c->bits >= 0)
+c->end_reached ++;
+return c->end_reached > 10;
 }
 
 static av_always_inline unsigned int vp56_rac_renorm(VP56RangeCoder *c)
diff --git a/libavcodec/vp56rac.c b/libavcodec/vp56rac.c
index e70302bf85..64fb6a99b4 100644
--- a/libavcodec/vp56rac.c
+++ b/libavcodec/vp56rac.c
@@ -43,6 +43,7 @@ int ff_vp56_init_range_decoder(VP56RangeCoder *c, const 
uint8_t *buf, int buf_si
 c->bits = -16;
 c->buffer = buf;
 c->end = buf + buf_size;
+c->end_reached = 0;
 if (buf_size < 1)
 return AVERROR_INVALIDDATA;
 c->code_word = bytestream_get_be24(>buffer);
diff --git a/tests/ref/fate/vp5 b/tests/ref/fate/vp5
index 2469a3ec21..09ebe62b25 100644
--- a/tests/ref/fate/vp5
+++ b/tests/ref/fate/vp5
@@ -249,4 +249,4 @@
 0,243,243,1,   233472, 0x6f530ac6
 0,244,244,1,   233472, 0x94f7466c
 0,245,245,1,   233472, 0xa8c1d365
-0,246,246,1,   233472, 0xbf73f1b7
+0,246,246,1,   233472, 0x4f3ef38c
-- 
2.23.0

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

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

[FFmpeg-devel] [PATCH 2/3] dnn: change .model file format to put layer number at the end of file

2019-08-20 Thread Guo, Yejun
currently, the layer number is at the beginning of the .model file,
so we have to scan twice in python script, the first scan to get the
layer number. Only one scan needed after put the layer number at the
end of .model file.

Signed-off-by: Guo, Yejun 
---
 libavfilter/dnn/dnn_backend_native.c|  2 ++
 tools/python/convert_from_tensorflow.py | 12 +---
 2 files changed, 3 insertions(+), 11 deletions(-)

diff --git a/libavfilter/dnn/dnn_backend_native.c 
b/libavfilter/dnn/dnn_backend_native.c
index 78227a5..0ba4e44 100644
--- a/libavfilter/dnn/dnn_backend_native.c
+++ b/libavfilter/dnn/dnn_backend_native.c
@@ -93,8 +93,10 @@ DNNModel *ff_dnn_load_model_native(const char 
*model_filename)
 }
 model->model = (void *)network;
 
+avio_seek(model_file_context, file_size - 4, SEEK_SET);
 network->layers_num = (int32_t)avio_rl32(model_file_context);
 dnn_size = 4;
+avio_seek(model_file_context, 0, SEEK_SET);
 
 network->layers = av_mallocz(network->layers_num * sizeof(Layer));
 if (!network->layers){
diff --git a/tools/python/convert_from_tensorflow.py 
b/tools/python/convert_from_tensorflow.py
index 34454b8..cbc76a9 100644
--- a/tools/python/convert_from_tensorflow.py
+++ b/tools/python/convert_from_tensorflow.py
@@ -129,15 +129,6 @@ class TFConverter:
 self.converted_nodes.add(node.name)
 
 
-def generate_layer_number(self):
-# in current hard code implementation, the layer number is the first 
data written to the native model file
-# it is not easy to know it at the beginning time in the general 
converter, so first do a dry run for compatibility
-# will be refined later.
-with open('/tmp/tmp.model', 'wb') as f:
-self.dump_layers_to_file(f)
-self.converted_nodes.clear()
-
-
 def dump_layers_to_file(self, f):
 for node in self.nodes:
 if node.name in self.converted_nodes:
@@ -157,10 +148,9 @@ class TFConverter:
 
 
 def dump_to_file(self):
-self.generate_layer_number()
 with open(self.outfile, 'wb') as f:
-np.array([self.layer_number], dtype=np.uint32).tofile(f)
 self.dump_layers_to_file(f)
+np.array([self.layer_number], dtype=np.uint32).tofile(f)
 
 
 def generate_name_node_dict(self):
-- 
2.7.4

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

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

[FFmpeg-devel] [PATCH 1/3] dnn: introduce dnn operand (in c code) to hold operand infos within network

2019-08-20 Thread Guo, Yejun
the info can be saved in dnn operand object without regenerating again and 
again,
and it is also needed for layer split/merge, and for memory reuse.

to make things step by step, this patch just focuses on c code,
the change within python script will be added later.

Signed-off-by: Guo, Yejun 
---
 libavfilter/dnn/dnn_backend_native.c   | 226 -
 libavfilter/dnn/dnn_backend_native.h   |  54 +-
 libavfilter/dnn/dnn_backend_native_layer_pad.c |  24 ++-
 libavfilter/dnn/dnn_backend_native_layer_pad.h |   4 +-
 tests/dnn/Makefile |   2 +-
 tests/dnn/dnn-layer-pad-test.c |  60 +--
 6 files changed, 236 insertions(+), 134 deletions(-)

diff --git a/libavfilter/dnn/dnn_backend_native.c 
b/libavfilter/dnn/dnn_backend_native.c
index d52abc6..78227a5 100644
--- a/libavfilter/dnn/dnn_backend_native.c
+++ b/libavfilter/dnn/dnn_backend_native.c
@@ -30,77 +30,30 @@
 static DNNReturnType set_input_output_native(void *model, DNNInputData *input, 
const char *input_name, const char **output_names, uint32_t nb_output)
 {
 ConvolutionalNetwork *network = (ConvolutionalNetwork *)model;
-InputParams *input_params;
-ConvolutionalParams *conv_params;
-DepthToSpaceParams *depth_to_space_params;
-LayerPadParams *pad_params;
-int cur_width, cur_height, cur_channels;
-int32_t layer;
 
-if (network->layers_num <= 0 || network->layers[0].type != INPUT){
+if (network->layers_num <= 0 || network->operands_num <= 0)
 return DNN_ERROR;
-}
-else{
-input_params = (InputParams *)network->layers[0].params;
-input_params->width = cur_width = input->width;
-input_params->height = cur_height = input->height;
-input_params->channels = cur_channels = input->channels;
-if (input->data){
-av_freep(>data);
-}
-av_assert0(input->dt == DNN_FLOAT);
-network->layers[0].output = input->data = av_malloc(cur_height * 
cur_width * cur_channels * sizeof(float));
-if (!network->layers[0].output){
-return DNN_ERROR;
-}
-}
-
-for (layer = 1; layer < network->layers_num; ++layer){
-switch (network->layers[layer].type){
-case CONV:
-conv_params = (ConvolutionalParams *)network->layers[layer].params;
-if (conv_params->input_num != cur_channels){
-return DNN_ERROR;
-}
-cur_channels = conv_params->output_num;
-
-if (conv_params->padding_method == VALID) {
-int pad_size = (conv_params->kernel_size - 1) * 
conv_params->dilation;
-cur_height -= pad_size;
-cur_width -= pad_size;
-}
-break;
-case DEPTH_TO_SPACE:
-depth_to_space_params = (DepthToSpaceParams 
*)network->layers[layer].params;
-if (cur_channels % (depth_to_space_params->block_size * 
depth_to_space_params->block_size) != 0){
-return DNN_ERROR;
-}
-cur_channels = cur_channels / (depth_to_space_params->block_size * 
depth_to_space_params->block_size);
-cur_height *= depth_to_space_params->block_size;
-cur_width *= depth_to_space_params->block_size;
-break;
-case MIRROR_PAD:
-pad_params = (LayerPadParams *)network->layers[layer].params;
-cur_height = cur_height + pad_params->paddings[1][0] + 
pad_params->paddings[1][1];
-cur_width = cur_width + pad_params->paddings[2][0] + 
pad_params->paddings[2][1];
-cur_channels = cur_channels + pad_params->paddings[3][0] + 
pad_params->paddings[3][1];
-break;
-default:
-return DNN_ERROR;
-}
-if (network->layers[layer].output){
-av_freep(>layers[layer].output);
-}
-
-if (cur_height <= 0 || cur_width <= 0)
-return DNN_ERROR;
 
-network->layers[layer].output = av_malloc(cur_height * cur_width * 
cur_channels * sizeof(float));
-if (!network->layers[layer].output){
-return DNN_ERROR;
-}
-}
+av_assert0(input->dt == DNN_FLOAT);
+
+/**
+ * as the first step, suppose network->operands[0] is the input operand.
+ */
+network->operands[0].dims[0] = 1;
+network->operands[0].dims[1] = input->height;
+network->operands[0].dims[2] = input->width;
+network->operands[0].dims[3] = input->channels;
+network->operands[0].type = DOT_INPUT;
+network->operands[0].data_type = DNN_FLOAT;
+network->operands[0].isNHWC = 1;
+
+av_freep(>operands[0].data);
+network->operands[0].length = 
calculate_operand_data_length(>operands[0]);
+network->operands[0].data = av_malloc(network->operands[0].length);
+if (!network->operands[0].data)
+return DNN_ERROR;
 
+input->data = network->operands[0].data;
 return DNN_SUCCESS;
 }
 
@@ -119,6 

Re: [FFmpeg-devel] [CALL] New FFmpeg developers meeting

2019-08-20 Thread Paul B Mahol
Hi,

Because of current overall toxic situation in FFmpeg, meeting will not be
held until situation improves considerably.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH 1/1] avformat/matroska: fully parse stsd atom in v_quicktime tracks

2019-08-20 Thread Michael Niedermayer
On Sun, Aug 18, 2019 at 12:32:03PM +0200, Stanislav Ionascu wrote:
> Hi,
> 
> thanks for looking into this.
> 
> On Sun, Aug 18, 2019 at 4:55 AM Andreas Rheinhardt
>  wrote:
> >
> > Hello,
> >
> > I am no expert on mov (and so this should definitely be looked at from
> > someone who is), but I have some points:
> >
> > Stanislav Ionascu:
> > > diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
> > > index 1ea9b807e6..2a397c909a 100644
> > > --- a/libavformat/matroskadec.c
> > > +++ b/libavformat/matroskadec.c
> > > @@ -2473,25 +2473,58 @@ static int
> > matroska_parse_tracks(AVFormatContext *s)
> > >  } else if (!strcmp(track->codec_id, "V_QUICKTIME") &&
> > > (track->codec_priv.size >= 21)  &&
> > > (track->codec_priv.data)) {
> > > +MOVStreamContext *msc;
> > > +MOVContext *mc = NULL;
> > > +void *priv_data;
> > > +int nb_streams;
> >
> > You could initialize nb_streams and priv_data here. And the
> > initialization of mc is unnecessary.
> 
> Done.
> 
> >
> > >  int ret = get_qt_codec(track, , _id);
> > >  if (ret < 0)
> > >  return ret;
> > > -if (codec_id == AV_CODEC_ID_NONE &&
> > AV_RL32(track->codec_priv.data+4) == AV_RL32("SMI ")) {
> > > -fourcc = MKTAG('S','V','Q','3');
> > > -codec_id = ff_codec_get_id(ff_codec_movvideo_tags,
> > fourcc);
> > > +mc = av_mallocz(sizeof(*mc));
> > > +if (!mc)
> > > +return AVERROR(ENOMEM);
> > > +priv_data = st->priv_data;
> > > +nb_streams = s->nb_streams;
> > > +mc->fc = s;
> > > +st->priv_data = msc = av_mallocz(sizeof(MOVStreamContext));
> > > +if (!msc) {
> > > +av_free(mc);
> > > +st->priv_data = priv_data;
> > > +return AVERROR(ENOMEM);
> > >  }
> > > +ffio_init_context(, track->codec_priv.data,
> > > +  track->codec_priv.size,
> > > +  0, NULL, NULL, NULL, NULL);
> > > +
> > > +/* ff_mov_read_stsd_entries updates stream s->nb_streams-1,
> > > + * so set it temporarily to indicate which stream to
> > update. */
> > > +s->nb_streams = st->index + 1;
> > > +ff_mov_read_stsd_entries(mc, , 1);
> >
> > Is it intentional that you don't check the return value here?.
> 
> Added the check.
> 
> >
> > > +
> > > +/* copy palette from MOVStreamContext */
> > > +track->has_palette = msc->has_palette;
> > > +if (track->has_palette) {
> > > +/* leave bit_depth = -1, to reuse
> > bits_per_coded_sample  */
> > > +memcpy(track->palette, msc->palette, AVPALETTE_COUNT);
> >
> > In case the track has a palette, your patch would only copy 256 bytes
> > of it, but a palette consists of 256 uint32_t. (This link
> > https://drive.google.com/drive/folders/0B3_pEBoLs0faWElmM2FnLTZYNlk
> > from the commit message that added the palette stuff seems to still
> > work if you need samples for this.)
> 
> Indeed. I've corrected that. Also remuxed all mov's into mkv's, and
> verified that they all still work.
> 
> >
> > > +}
> > > +
> > > +av_free(msc);
> > > +av_free(mc);
> > > +st->priv_data = priv_data;
> > > +s->nb_streams = nb_streams;
> > > +fourcc = st->codecpar->codec_tag;
> > > +codec_id = st->codecpar->codec_id;
> > > +
> > > +av_log(matroska->ctx, AV_LOG_TRACE,
> > > +   "mov FourCC found %s.\n", av_fourcc2str(fourcc));
> > > +
> > >  if (codec_id == AV_CODEC_ID_NONE)
> > >  av_log(matroska->ctx, AV_LOG_ERROR,
> > > -   "mov FourCC not found %s.\n",
> > av_fourcc2str(fourcc));
> >
> > If the codec_id turns out to be AV_CODEC_ID_NONE, two strings will be
> > output (at least on loglevel trace): "mov FourCC found %s.\n" and then
> > "mov FourCC not found %s.\n". The first of these is superfluous in
> > this case.
> 
> Removed it, as stsd parser will also trace the FourCC code.
> 
> >
> > > -if (track->codec_priv.size >= 86) {
> > > -bit_depth = AV_RB16(track->codec_priv.data + 82);
> > > -ffio_init_context(, track->codec_priv.data,
> > > -  track->codec_priv.size,
> > > -  0, NULL, NULL, NULL, NULL);
> > > -if (ff_get_qtpalette(codec_id, , track->palette)) {
> >
> > If I am not extremely mistaken, then there is no need to include
> > qtpalette.h any more after removing this function call.
> 
> Yes. Removed as it's not necessary.
> 
> >
> > > -bit_depth &= 0x1F;
> > > -track->has_palette = 1;
> > > -}
> > > +   

Re: [FFmpeg-devel] [PATCH]lavc/g729dec: Support decoding ACELP.KELVIN

2019-08-20 Thread Paul B Mahol
Do not use full caps name for short name.

On Mon, Aug 19, 2019 at 11:38 PM Carl Eugen Hoyos 
wrote:

> Hi!
>
> Attached patch fixes tickets #4799 and #8081, thanks to Paul for his help.
>
> Please comment, Carl Eugen
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH v2 1/3] avfilter: add v360 filter

2019-08-20 Thread Paul B Mahol
On Mon, Aug 19, 2019 at 11:31 PM James Almer  wrote:

> On 8/13/2019 10:14 PM, Eugene Lyapustin wrote:
> > Signed-off-by: Eugene Lyapustin 
> > ---
> >  doc/filters.texi |  137 +++
> >  libavfilter/Makefile |1 +
> >  libavfilter/allfilters.c |1 +
> >  libavfilter/vf_v360.c| 1847 ++
> >  4 files changed, 1986 insertions(+)
> >  create mode 100644 libavfilter/vf_v360.c
> >
> > diff --git a/doc/filters.texi b/doc/filters.texi
>
> Shouldn't this make use of the AVSphericalMapping frame side data if
> available?
>

It is extremely limited API. And due lavfi limitations it can only clear
current side data and set new one.


> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

[FFmpeg-devel] [PATCH 3/3] dnn: export operand info in python script and load in c code

2019-08-20 Thread Guo, Yejun
Signed-off-by: Guo, Yejun 
---
 libavfilter/dnn/dnn_backend_native.c|  49 +++---
 libavfilter/dnn/dnn_backend_native.h|   2 +-
 libavfilter/dnn_interface.h |   2 +-
 tools/python/convert_from_tensorflow.py | 111 +---
 4 files changed, 142 insertions(+), 22 deletions(-)

diff --git a/libavfilter/dnn/dnn_backend_native.c 
b/libavfilter/dnn/dnn_backend_native.c
index 0ba4e44..eeae711 100644
--- a/libavfilter/dnn/dnn_backend_native.c
+++ b/libavfilter/dnn/dnn_backend_native.c
@@ -72,7 +72,6 @@ DNNModel *ff_dnn_load_model_native(const char *model_filename)
 ConvolutionalParams *conv_params;
 DepthToSpaceParams *depth_to_space_params;
 LayerPadParams *pad_params;
-int32_t operand_index = 0;
 
 model = av_malloc(sizeof(DNNModel));
 if (!model){
@@ -93,9 +92,10 @@ DNNModel *ff_dnn_load_model_native(const char 
*model_filename)
 }
 model->model = (void *)network;
 
-avio_seek(model_file_context, file_size - 4, SEEK_SET);
+avio_seek(model_file_context, file_size - 8, SEEK_SET);
 network->layers_num = (int32_t)avio_rl32(model_file_context);
-dnn_size = 4;
+network->operands_num = (int32_t)avio_rl32(model_file_context);
+dnn_size = 8;
 avio_seek(model_file_context, 0, SEEK_SET);
 
 network->layers = av_mallocz(network->layers_num * sizeof(Layer));
@@ -105,11 +105,6 @@ DNNModel *ff_dnn_load_model_native(const char 
*model_filename)
 return NULL;
 }
 
-/**
- * Operands should be read from model file, the whole change will be huge.
- * to make things step by step, we first mock the operands, instead of 
reading from model file.
- */
-network->operands_num = network->layers_num + 1;
 network->operands = av_mallocz(network->operands_num * sizeof(DnnOperand));
 if (!network->operands){
 avio_closep(_file_context);
@@ -120,8 +115,6 @@ DNNModel *ff_dnn_load_model_native(const char 
*model_filename)
 for (layer = 0; layer < network->layers_num; ++layer){
 layer_type = (int32_t)avio_rl32(model_file_context);
 dnn_size += 4;
-network->layers[layer].input_operand_indexes[0] = operand_index++;
-network->layers[layer].output_operand_index = operand_index;
 switch (layer_type){
 case CONV:
 conv_params = av_malloc(sizeof(ConvolutionalParams));
@@ -162,6 +155,9 @@ DNNModel *ff_dnn_load_model_native(const char 
*model_filename)
 for (i = 0; i < conv_params->output_num; ++i){
 conv_params->biases[i] = 
av_int2float(avio_rl32(model_file_context));
 }
+network->layers[layer].input_operand_indexes[0] = 
(int32_t)avio_rl32(model_file_context);
+network->layers[layer].output_operand_index = 
(int32_t)avio_rl32(model_file_context);
+dnn_size += 8;
 network->layers[layer].type = CONV;
 network->layers[layer].params = conv_params;
 break;
@@ -174,6 +170,9 @@ DNNModel *ff_dnn_load_model_native(const char 
*model_filename)
 }
 depth_to_space_params->block_size = 
(int32_t)avio_rl32(model_file_context);
 dnn_size += 4;
+network->layers[layer].input_operand_indexes[0] = 
(int32_t)avio_rl32(model_file_context);
+network->layers[layer].output_operand_index = 
(int32_t)avio_rl32(model_file_context);
+dnn_size += 8;
 network->layers[layer].type = DEPTH_TO_SPACE;
 network->layers[layer].params = depth_to_space_params;
 break;
@@ -191,6 +190,9 @@ DNNModel *ff_dnn_load_model_native(const char 
*model_filename)
 pad_params->paddings[i][1] = avio_rl32(model_file_context);
 dnn_size += 8;
 }
+network->layers[layer].input_operand_indexes[0] = 
(int32_t)avio_rl32(model_file_context);
+network->layers[layer].output_operand_index = 
(int32_t)avio_rl32(model_file_context);
+dnn_size += 8;
 network->layers[layer].type = MIRROR_PAD;
 network->layers[layer].params = pad_params;
 break;
@@ -201,6 +203,33 @@ DNNModel *ff_dnn_load_model_native(const char 
*model_filename)
 }
 }
 
+for (int32_t i = 0; i < network->operands_num; ++i){
+DnnOperand *oprd;
+int32_t name_len;
+int32_t operand_index = (int32_t)avio_rl32(model_file_context);
+dnn_size += 4;
+
+oprd = >operands[operand_index];
+name_len = (int32_t)avio_rl32(model_file_context);
+dnn_size += 4;
+
+avio_get_str(model_file_context, name_len, oprd->name, 
sizeof(oprd->name));
+dnn_size += name_len;
+
+oprd->type = (int32_t)avio_rl32(model_file_context);
+dnn_size += 4;
+
+oprd->data_type = (int32_t)avio_rl32(model_file_context);
+dnn_size += 4;
+
+for (int32_t dim = 0; dim < 4; ++dim) {
+oprd->dims[dim] = 

[FFmpeg-devel] [PATCH v1 1/2] avcodec/videotoolboxenc: add H264 Extended profile and level

2019-08-20 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
 libavcodec/videotoolboxenc.c | 14 ++
 1 file changed, 14 insertions(+)

diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
index d76bb7f646..b16b056f6c 100644
--- a/libavcodec/videotoolboxenc.c
+++ b/libavcodec/videotoolboxenc.c
@@ -80,6 +80,8 @@ static struct{
 CFStringRef kVTProfileLevel_H264_High_5_1;
 CFStringRef kVTProfileLevel_H264_High_5_2;
 CFStringRef kVTProfileLevel_H264_High_AutoLevel;
+CFStringRef kVTProfileLevel_H264_Extended_5_0;
+CFStringRef kVTProfileLevel_H264_Extended_AutoLevel;
 
 CFStringRef kVTProfileLevel_HEVC_Main_AutoLevel;
 CFStringRef kVTProfileLevel_HEVC_Main10_AutoLevel;
@@ -137,6 +139,8 @@ static void loadVTEncSymbols(){
 GET_SYM(kVTProfileLevel_H264_High_5_1,   "H264_High_5_1");
 GET_SYM(kVTProfileLevel_H264_High_5_2,   "H264_High_5_2");
 GET_SYM(kVTProfileLevel_H264_High_AutoLevel, "H264_High_AutoLevel");
+GET_SYM(kVTProfileLevel_H264_Extended_5_0,   "H264_Extended_5_0");
+GET_SYM(kVTProfileLevel_H264_Extended_AutoLevel, 
"H264_Extended_AutoLevel");
 
 GET_SYM(kVTProfileLevel_HEVC_Main_AutoLevel, "HEVC_Main_AutoLevel");
 GET_SYM(kVTProfileLevel_HEVC_Main10_AutoLevel,   "HEVC_Main10_AutoLevel");
@@ -154,6 +158,7 @@ typedef enum VT_H264Profile {
 H264_PROF_BASELINE,
 H264_PROF_MAIN,
 H264_PROF_HIGH,
+H264_PROF_EXTENDED,
 H264_PROF_COUNT
 } VT_H264Profile;
 
@@ -704,6 +709,14 @@ static bool get_vt_h264_profile_level(AVCodecContext 
*avctx,
   compat_keys.kVTProfileLevel_H264_High_5_2;   
break;
 }
 break;
+case H264_PROF_EXTENDED:
+switch (vtctx->level) {
+case  0: *profile_level_val =
+  
compat_keys.kVTProfileLevel_H264_Extended_AutoLevel; break;
+case 50: *profile_level_val =
+  
compat_keys.kVTProfileLevel_H264_Extended_5_0;   break;
+}
+break;
 }
 
 if (!*profile_level_val) {
@@ -2531,6 +2544,7 @@ static const AVOption h264_options[] = {
 { "baseline", "Baseline Profile", 0, AV_OPT_TYPE_CONST, { .i64 = 
H264_PROF_BASELINE }, INT_MIN, INT_MAX, VE, "profile" },
 { "main", "Main Profile", 0, AV_OPT_TYPE_CONST, { .i64 = 
H264_PROF_MAIN }, INT_MIN, INT_MAX, VE, "profile" },
 { "high", "High Profile", 0, AV_OPT_TYPE_CONST, { .i64 = 
H264_PROF_HIGH }, INT_MIN, INT_MAX, VE, "profile" },
+{ "extended", "Extend Profile",   0, AV_OPT_TYPE_CONST, { .i64 = 
H264_PROF_EXTENDED }, INT_MIN, INT_MAX, VE, "profile" },
 
 { "level", "Level", OFFSET(level), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 52, 
VE, "level" },
 { "1.3", "Level 1.3, only available with Baseline Profile", 0, 
AV_OPT_TYPE_CONST, { .i64 = 13 }, INT_MIN, INT_MAX, VE, "level" },
-- 
2.21.0

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

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

[FFmpeg-devel] [PATCH v1 2/2] avcodec/videotoolboxenc: return error for invalid/unsupport profile or level

2019-08-20 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
 libavcodec/videotoolboxenc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
index b16b056f6c..52fc531af3 100644
--- a/libavcodec/videotoolboxenc.c
+++ b/libavcodec/videotoolboxenc.c
@@ -1109,6 +1109,7 @@ static int vtenc_create_encoder(AVCodecContext   *avctx,
 profile_level);
 if (status) {
 av_log(avctx, AV_LOG_ERROR, "Error setting profile/level 
property: %d\n", status);
+return AVERROR_EXTERNAL;
 }
 }
 }
-- 
2.21.0

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

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

Re: [FFmpeg-devel] [PATCH]lavc/g729dec: Support decoding ACELP.KELVIN

2019-08-20 Thread Carl Eugen Hoyos
Am Di., 20. Aug. 2019 um 10:30 Uhr schrieb Paul B Mahol :
>
> Do not use full caps name for short name.

New patch attached.

Thank you, Carl Eugen
From 8af0b279ad0c25425d075498f60b0770528687a2 Mon Sep 17 00:00:00 2001
From: Carl Eugen Hoyos 
Date: Mon, 19 Aug 2019 23:34:37 +0200
Subject: [PATCH] lavc/g729dec: Support decoding Sipro ACELP.KELVIN.

Fixes ticket #4799.
Analyzed-by: Aleksandr Ustinov
---
 Changelog|  3 +++
 configure|  1 +
 doc/general.texi |  1 +
 libavcodec/allcodecs.c   |  1 +
 libavcodec/avcodec.h |  1 +
 libavcodec/codec_desc.c  |  6 ++
 libavcodec/g729_parser.c |  5 +++--
 libavcodec/g729dec.c | 21 +++--
 libavcodec/version.h |  2 +-
 libavformat/riff.c   |  1 +
 10 files changed, 37 insertions(+), 5 deletions(-)

diff --git a/Changelog b/Changelog
index 389ca6c4db..42c1d16207 100644
--- a/Changelog
+++ b/Changelog
@@ -1,6 +1,9 @@
 Entries are sorted chronologically from oldest to youngest within each release,
 releases are sorted from youngest to oldest.
 
+version :
+- support Sipro ACELP.KELVIN decoding
+
 version 4.2:
 - tpad filter
 - AV1 decoding support through libdav1d
diff --git a/configure b/configure
index c09c842809..fc073967b3 100755
--- a/configure
+++ b/configure
@@ -2635,6 +2635,7 @@ ac3_decoder_select="ac3_parser ac3dsp bswapdsp fmtconvert mdct"
 ac3_fixed_decoder_select="ac3_parser ac3dsp bswapdsp mdct"
 ac3_encoder_select="ac3dsp audiodsp mdct me_cmp"
 ac3_fixed_encoder_select="ac3dsp audiodsp mdct me_cmp"
+acelp_kelvin_decoder_select="g729_decoder"
 adpcm_g722_decoder_select="g722dsp"
 adpcm_g722_encoder_select="g722dsp"
 aic_decoder_select="golomb idctdsp"
diff --git a/doc/general.texi b/doc/general.texi
index 3c0c803449..d90588c63a 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -1057,6 +1057,7 @@ following image formats are supported:
 @item AAC+   @tab  E  @tab  IX
 @tab encoding supported through external library libfdk-aac
 @item AC-3   @tab IX  @tab  IX
+@item ACELP.KELVIN   @tab @tab  X
 @item ADPCM 4X Movie @tab @tab  X
 @item APDCM Yamaha AICA  @tab @tab  X
 @item ADPCM CDROM XA @tab @tab  X
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index d2f9a39ce5..5936cdc467 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -32,6 +32,7 @@
 extern AVCodec ff_a64multi_encoder;
 extern AVCodec ff_a64multi5_encoder;
 extern AVCodec ff_aasc_decoder;
+extern AVCodec ff_acelp_kelvin_decoder;
 extern AVCodec ff_aic_decoder;
 extern AVCodec ff_alias_pix_encoder;
 extern AVCodec ff_alias_pix_decoder;
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index d234271c5b..7ec4014d8b 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -629,6 +629,7 @@ enum AVCodecID {
 AV_CODEC_ID_ON2AVC,
 AV_CODEC_ID_DSS_SP,
 AV_CODEC_ID_CODEC2,
+AV_CODEC_ID_ACELP_KELVIN,
 
 AV_CODEC_ID_FFWAVESYNTH = 0x15800,
 AV_CODEC_ID_SONIC,
diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
index 4d033c20ff..716e278b93 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -2834,6 +2834,12 @@ static const AVCodecDescriptor codec_descriptors[] = {
 .long_name = NULL_IF_CONFIG_SMALL("codec2 (very low bitrate speech codec)"),
 .props = AV_CODEC_PROP_LOSSY,
 },
+{
+.id= AV_CODEC_ID_ACELP_KELVIN,
+.name  = "acelp.kelvin",
+.long_name = NULL_IF_CONFIG_SMALL("Sipro ACELP.KELVIN"),
+.props = AV_CODEC_PROP_LOSSY,
+},
 {
 .id= AV_CODEC_ID_FFWAVESYNTH,
 .type  = AVMEDIA_TYPE_AUDIO,
diff --git a/libavcodec/g729_parser.c b/libavcodec/g729_parser.c
index 9982dbfffc..5a57025d62 100644
--- a/libavcodec/g729_parser.c
+++ b/libavcodec/g729_parser.c
@@ -45,9 +45,10 @@ static int g729_parse(AVCodecParserContext *s1, AVCodecContext *avctx,
 int next;
 
 if (!s->block_size) {
-av_assert1(avctx->codec_id == AV_CODEC_ID_G729);
 /* FIXME: replace this heuristic block_size with more precise estimate */
 s->block_size = (avctx->bit_rate < 8000) ? G729D_6K4_BLOCK_SIZE : G729_8K_BLOCK_SIZE;
+if (avctx->codec_id == AV_CODEC_ID_ACELP_KELVIN)
+s->block_size++;
 s->block_size *= avctx->channels;
 s->duration   = avctx->frame_size;
 }
@@ -76,7 +77,7 @@ static int g729_parse(AVCodecParserContext *s1, AVCodecContext *avctx,
 }
 
 AVCodecParser ff_g729_parser = {
-.codec_ids  = { AV_CODEC_ID_G729 },
+.codec_ids  = { AV_CODEC_ID_G729, AV_CODEC_ID_ACELP_KELVIN },
 .priv_data_size = sizeof(G729ParseContext),
 .parser_parse   = g729_parse,
 .parser_close   = ff_parse_close,
diff --git a/libavcodec/g729dec.c b/libavcodec/g729dec.c
index 2e4756b805..5a5da5b03c 100644
--- a/libavcodec/g729dec.c
+++ b/libavcodec/g729dec.c
@@ -424,7 +424,7 @@ static int decode_frame(AVCodecContext 

Re: [FFmpeg-devel] [REQUEST] avcodec/scpr: revert d70276921348

2019-08-20 Thread Kieran Kunhya
On Tue, 20 Aug 2019 at 18:06, Michael Niedermayer 
wrote:

> On Tue, Aug 20, 2019 at 05:09:51PM +0100, Kieran Kunhya wrote:
> > On Tue, 20 Aug 2019 at 14:16, Carl Eugen Hoyos 
> wrote:
> >
> > > Am Di., 20. Aug. 2019 um 14:48 Uhr schrieb Paul B Mahol <
> one...@gmail.com
> > > >:
> > >
> > > > I kindly ask that following commit:
> > > d702769213487923c0fb0abe4b61f4d9ebddb88b
> > >
> > > I still believe what the patch does is a very good idea and a revert
> would
> > > hurt FFmpeg.
> > >
> >
> > We should not turn CFR streams into VFR. This would not be acceptable for
> > H264 not should it be acceptable for any other codec.
>
> All MPEG & ITU codecs i remember follow this too as far as possible,
> including H264
>
> [...]
> again, we return metadata we do not return the same frame
>
> same is true for msmpeg4 and every other codec which uses metadata at AVI
> level
> that is skiped frames. The codecs are CFR at AVI level but we do not
> output CFR
>

All of these codecs contain metadata to add more frames if the decoder
requires.
Nowhere are frames which can't be decoded are dropped.



> But what is more bizare (to me at least) is that this was not a controversy
> at the time CFR was the standard and all these codecs where "new".
> Please correct me if iam wrong but the "CFR must be CFR" seems to
> originate
> from some professional broadcast people (like you).
>

This is what you would call an "ad-hominem"


> But then it seems the codecs which broadcast people use
> the fact they dont preserve CFR in this way isnt a problem and not even
> noticed
> while for codecs that broadcast has noting to do with like SCPR its a big
> issue.
> This makes no sense to me.
>

Someone decoding an SCPR file to encode to another format now has fewer
frames than before.
All done to pass a fuzzer. Simple as that.

Kieran

-- 
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> Take away the freedom of one citizen and you will be jailed, take away
> the freedom of all citizens and you will be congratulated by your peers
> in Parliament.
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

[FFmpeg-devel] [PATCH v2] tools/target_dec_fuzzer: use refcounted packets

2019-08-20 Thread James Almer
Should reduce date copying considerably.

Signed-off-by: James Almer 
---
Fixed a stupid mistake when checking the return value for av_new_packet().
Still untested.

 tools/target_dec_fuzzer.c | 71 ---
 1 file changed, 21 insertions(+), 50 deletions(-)

diff --git a/tools/target_dec_fuzzer.c b/tools/target_dec_fuzzer.c
index d83039417c..0d10503cfb 100644
--- a/tools/target_dec_fuzzer.c
+++ b/tools/target_dec_fuzzer.c
@@ -85,47 +85,6 @@ static int subtitle_handler(AVCodecContext *avctx, void 
*frame,
 return ret;
 }
 
-// Class to handle buffer allocation and resize for each frame
-typedef struct FuzzDataBuffer {
-size_t size_;
-uint8_t *data_;
-} FuzzDataBuffer;
-
-static void FDBCreate(FuzzDataBuffer *FDB) {
-FDB->size_ = 0x1000;
-FDB->data_ = av_malloc(FDB->size_);
-if (!FDB->data_)
-error("Failed memory allocation");
-}
-
-static void FDBDesroy(FuzzDataBuffer *FDB) { av_free(FDB->data_); }
-
-static void FDBRealloc(FuzzDataBuffer *FDB, size_t size) {
-size_t needed = size + AV_INPUT_BUFFER_PADDING_SIZE;
-av_assert0(needed > size);
-if (needed > FDB->size_) {
-av_free(FDB->data_);
-FDB->size_ = needed;
-FDB->data_ = av_malloc(FDB->size_);
-if (!FDB->data_)
-error("Failed memory allocation");
-}
-}
-
-static void FDBPrepare(FuzzDataBuffer *FDB, AVPacket *dst, const uint8_t *data,
-size_t size)
-{
-FDBRealloc(FDB, size);
-memcpy(FDB->data_, data, size);
-size_t padd = FDB->size_ - size;
-if (padd > AV_INPUT_BUFFER_PADDING_SIZE)
-padd = AV_INPUT_BUFFER_PADDING_SIZE;
-memset(FDB->data_ + size, 0, padd);
-av_init_packet(dst);
-dst->data = FDB->data_;
-dst->size = size;
-}
-
 // Ensure we don't loop forever
 const uint32_t maxiteration = 8096;
 const uint64_t maxpixels_per_frame = 4096 * 4096;
@@ -135,7 +94,6 @@ static const uint64_t FUZZ_TAG = 0x4741542D5A5A5546ULL;
 
 int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
 const uint64_t fuzz_tag = FUZZ_TAG;
-FuzzDataBuffer buffer;
 const uint8_t *last = data;
 const uint8_t *end = data + size;
 uint32_t it = 0;
@@ -186,6 +144,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t 
size) {
 error("Failed memory allocation");
 
 ctx->max_pixels = maxpixels_per_frame; //To reduce false positive OOM and 
hangs
+ctx->refcounted_frames = 1;
 
 if (size > 1024) {
 GetByteContext gbc;
@@ -222,7 +181,6 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t 
size) {
 }
 parser_avctx->codec_id = ctx->codec_id;
 
-FDBCreate();
 int got_frame;
 AVFrame *frame = av_frame_alloc();
 if (!frame)
@@ -230,6 +188,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t 
size) {
 
 // Read very simple container
 AVPacket avpkt, parsepkt;
+av_init_packet();
 while (data < end && it < maxiteration) {
 // Search for the TAG
 while (data + sizeof(fuzz_tag) < end) {
@@ -240,7 +199,10 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t 
size) {
 if (data + sizeof(fuzz_tag) > end)
 data = end;
 
-FDBPrepare(, , last, data - last);
+res = av_new_packet(, data - last);
+if (res < 0)
+error("Failed memory allocation");
+memcpy(parsepkt.data, last, data - last);
 data += sizeof(fuzz_tag);
 last = data;
 
@@ -257,13 +219,21 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t 
size) {
 avpkt.pts = parser->pts;
 avpkt.dts = parser->dts;
 avpkt.pos = parser->pos;
+if (avpkt.data == parsepkt.data) {
+avpkt.buf = av_buffer_ref(parsepkt.buf);
+if (!avpkt.buf)
+error("Failed memory allocation");
+} else {
+ret = av_packet_make_refcounted();
+if (ret < 0)
+error("Failed memory allocation");
+}
 if ( parser->key_frame == 1 ||
 (parser->key_frame == -1 && parser->pict_type == 
AV_PICTURE_TYPE_I))
 avpkt.flags |= AV_PKT_FLAG_KEY;
 avpkt.flags |= parsepkt.flags & AV_PKT_FLAG_DISCARD;
 } else {
-avpkt = parsepkt;
-parsepkt.size = 0;
+av_packet_move_ref(, );
 }
 
   // Iterate through all data
@@ -284,16 +254,17 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t 
size) {
 avpkt.data += ret;
 avpkt.size -= ret;
   }
+  av_packet_unref();
 }
+av_packet_unref();
 }
 maximums_reached:
 
-av_init_packet();
-avpkt.data = NULL;
-avpkt.size = 0;
+av_packet_unref();
 
 do {
 got_frame = 0;
+av_frame_unref(frame);
 decode_handler(ctx, frame, 

Re: [FFmpeg-devel] [PATCH V3] avcodec/libvpxenc: add ROI-based encoding support for VP8/VP9 support

2019-08-20 Thread Guo, Yejun


> -Original Message-
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf Of
> James Zern
> Sent: Wednesday, August 21, 2019 8:47 AM
> To: FFmpeg development discussions and patches 
> Subject: Re: [FFmpeg-devel] [PATCH V3] avcodec/libvpxenc: add ROI-based
> encoding support for VP8/VP9 support
> 
> Hi,
> 
> On Tue, Aug 13, 2019 at 8:29 PM Guo, Yejun  wrote:
> > example command line to verify it:
> > ./ffmpeg -i input.stream -vf addroi=0:0:iw/3:ih/3:-0.8 -c:v libvpx -b:v 2M
> tmp.webm
> >
> > Signed-off-by: Guo, Yejun 
> > ---
> >  libavcodec/libvpxenc.c | 197
> +
> >  1 file changed, 197 insertions(+)
> >
> > [...]
> >
> > +
> > +memset(roi_map, 0, sizeof(*roi_map));
> > +
> > +/* segment id 0 in roi_map is reserved for the areas not covered by
> AVRegionOfInterest.
> > + * segment id 0 in roi_map is also for the areas with
> AVRegionOfInterest.qoffset near 0.
> > + * (delta_q of segment id 0 is 0).
> > + */
> > +segment_mapping[MAX_DELTA_Q] = 1;
> > +/* roi_map has memset with zero, just explictly set it again for 
> > explict
> understanding. */
> 
> There are some typos in this, but as the comment says, it's redundant.
> I think this and
> the next line could be removed.

thanks, will remove.

> 
> > +roi_map->delta_q[0] = 0;
> > +segment_id = 1;
> > +
> > +roi = (const AVRegionOfInterest*)sd->data;
> > +self_size = roi->self_size;
> > +if (!self_size || sd->size % self_size != 0) {
> > +av_log(avctx, AV_LOG_ERROR, "Invalid
> AVRegionOfInterest.self_size.\n");
> > +return AVERROR(EINVAL);
> > +}
> > +nb_rois = sd->size / self_size;
> > +
> > +/* This list must be iterated from zero because regions are
> > + * defined in order of decreasing importance. So discard less
> > + * important areas if they exceed the segment count.
> > + */
> > +for (int i = 0; i < nb_rois; i++) {
> > +int delta_q;
> > +int mapping_index;
> > +
> > +roi = (const AVRegionOfInterest*)(sd->data + self_size * i);
> > +if (roi->qoffset.den == 0) {
> > +av_log(avctx, AV_LOG_ERROR,
> "AVRegionOfInterest.qoffset.den must not be zero.\n");
> > +return AVERROR(EINVAL);
> > +}
> > +
> > +delta_q = (int)(roi->qoffset.num * 1.0f / roi->qoffset.den *
> MAX_DELTA_Q);
> > +delta_q = av_clip(delta_q, -MAX_DELTA_Q, MAX_DELTA_Q);
> > +
> 
> Note that libvpx allows other adjustments (loop filter, block skipping, among
> others), but there may not be a way to provide this with AVRegionOfInterest.

thanks, I see, here we might use qoffset only to change the delta_q.

> 
> > [...]
> > +
> > +if (ctx->aq_mode > 0 || ctx->cpu_used < 5 || ctx->deadline !=
> VPX_DL_REALTIME) {
> > +if (!ctx->roi_warned) {
> > +ctx->roi_warned = 1;
> > +if (ctx->aq_mode > 0)
> > +av_log(avctx, AV_LOG_WARNING, "ROI is disabled
> when any of AQ mode is on, skipping ROI.\n");
> > +else
> > +av_log(avctx, AV_LOG_WARNING, "due to libvpx's
> internal issue (see function apply_roi_map), skipping ROI.\n");
> 
> I think this could just mention that ROI is only supported with aq_mode==0,
> cpu_used >= 5 and deadline set to realtime rather than having a more specific
> statement like this one.

ok, will change it.

> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [REQUEST] avcodec/scpr: revert d70276921348

2019-08-20 Thread Michael Niedermayer
On Tue, Aug 20, 2019 at 06:13:49PM -0300, James Almer wrote:
> On 8/20/2019 3:32 PM, Michael Niedermayer wrote:
> > On Tue, Aug 20, 2019 at 02:52:49PM -0300, James Almer wrote:
> >> On 8/20/2019 2:46 PM, Michael Niedermayer wrote:
> >>> On Tue, Aug 20, 2019 at 02:49:13PM +0200, Paul B Mahol wrote:
>  Hi,
> 
>  I kindly ask that following commit: 
>  d702769213487923c0fb0abe4b61f4d9ebddb88b
>  is reverted as it does contradicts with reference decoder.
> >>>
> >>> Noone is listed in MAINTAINERs for scpr.c
> >>> the main author of scpr.c is you, so  i think you are the closest to a
> >>> maintainer.
> >>>
> >>> So if after everyone who wants to comment has commented you still want 
> >>> this
> >>> reverted. Then ill revert (or you can revert too)
> >>> but personally i think that skiping duplicated frames has many advantages
> >>> and its better to skip them
> >>>
> >>> Thanks
> >>
> >> I suggested on IRC to add an option somewhere (new AVCodecContext field?
> >> ffmpeg cli option? Mapping it to AV_CODEC_FLAG2_FAST?) to tell crf
> >> decoders to instead output vrf in situations like this.
> > 
> > IMHO never output known duplicate frames is best. But if people want to
> > change this. A flag/field is the next best option.
> 
> > AV_CODEC_FLAG2_FAST does not solve this as the flag has a different
> > meaning.
> 
> How so? The doxy says "Allow non spec compliant speedup tricks.".
> Outputting vfr when cfr is the spec compliant behavior sure sounds like
> it's a good fit for this feature.

AV_CODEC_FLAG2_FAST will cause output to differ in pixel values from
a compliant decoder.

while droping duplicated frames can be reversed by duplicating again with
no pixel differences.

So a user application which needs pixel exact values can use the flag to
drop duplicate frames but cannot use AV_CODEC_FLAG2_FAST


> 
> A new flag/field would be needed

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Elect your leaders based on what they did after the last election, not
based on what they say before an election.



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

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

[FFmpeg-devel] [PATCH] tools/target_dec_fuzzer: use refcounted packets

2019-08-20 Thread James Almer
Should help reduce date copying.

Signed-off-by: James Almer 
---
Untested.

 tools/target_dec_fuzzer.c | 71 ---
 1 file changed, 21 insertions(+), 50 deletions(-)

diff --git a/tools/target_dec_fuzzer.c b/tools/target_dec_fuzzer.c
index d83039417c..c3232e8d80 100644
--- a/tools/target_dec_fuzzer.c
+++ b/tools/target_dec_fuzzer.c
@@ -85,47 +85,6 @@ static int subtitle_handler(AVCodecContext *avctx, void 
*frame,
 return ret;
 }
 
-// Class to handle buffer allocation and resize for each frame
-typedef struct FuzzDataBuffer {
-size_t size_;
-uint8_t *data_;
-} FuzzDataBuffer;
-
-static void FDBCreate(FuzzDataBuffer *FDB) {
-FDB->size_ = 0x1000;
-FDB->data_ = av_malloc(FDB->size_);
-if (!FDB->data_)
-error("Failed memory allocation");
-}
-
-static void FDBDesroy(FuzzDataBuffer *FDB) { av_free(FDB->data_); }
-
-static void FDBRealloc(FuzzDataBuffer *FDB, size_t size) {
-size_t needed = size + AV_INPUT_BUFFER_PADDING_SIZE;
-av_assert0(needed > size);
-if (needed > FDB->size_) {
-av_free(FDB->data_);
-FDB->size_ = needed;
-FDB->data_ = av_malloc(FDB->size_);
-if (!FDB->data_)
-error("Failed memory allocation");
-}
-}
-
-static void FDBPrepare(FuzzDataBuffer *FDB, AVPacket *dst, const uint8_t *data,
-size_t size)
-{
-FDBRealloc(FDB, size);
-memcpy(FDB->data_, data, size);
-size_t padd = FDB->size_ - size;
-if (padd > AV_INPUT_BUFFER_PADDING_SIZE)
-padd = AV_INPUT_BUFFER_PADDING_SIZE;
-memset(FDB->data_ + size, 0, padd);
-av_init_packet(dst);
-dst->data = FDB->data_;
-dst->size = size;
-}
-
 // Ensure we don't loop forever
 const uint32_t maxiteration = 8096;
 const uint64_t maxpixels_per_frame = 4096 * 4096;
@@ -135,7 +94,6 @@ static const uint64_t FUZZ_TAG = 0x4741542D5A5A5546ULL;
 
 int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
 const uint64_t fuzz_tag = FUZZ_TAG;
-FuzzDataBuffer buffer;
 const uint8_t *last = data;
 const uint8_t *end = data + size;
 uint32_t it = 0;
@@ -186,6 +144,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t 
size) {
 error("Failed memory allocation");
 
 ctx->max_pixels = maxpixels_per_frame; //To reduce false positive OOM and 
hangs
+ctx->refcounted_frames = 1;
 
 if (size > 1024) {
 GetByteContext gbc;
@@ -222,7 +181,6 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t 
size) {
 }
 parser_avctx->codec_id = ctx->codec_id;
 
-FDBCreate();
 int got_frame;
 AVFrame *frame = av_frame_alloc();
 if (!frame)
@@ -230,6 +188,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t 
size) {
 
 // Read very simple container
 AVPacket avpkt, parsepkt;
+av_init_packet();
 while (data < end && it < maxiteration) {
 // Search for the TAG
 while (data + sizeof(fuzz_tag) < end) {
@@ -240,7 +199,10 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t 
size) {
 if (data + sizeof(fuzz_tag) > end)
 data = end;
 
-FDBPrepare(, , last, data - last);
+res = av_new_packet(, data - last);
+if (!res)
+error("Failed to find decoder");
+memcpy(parsepkt.data, last, data - last);
 data += sizeof(fuzz_tag);
 last = data;
 
@@ -257,13 +219,21 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t 
size) {
 avpkt.pts = parser->pts;
 avpkt.dts = parser->dts;
 avpkt.pos = parser->pos;
+if (avpkt.data == parsepkt.data) {
+avpkt.buf = av_buffer_ref(parsepkt.buf);
+if (!avpkt.buf)
+error("Failed memory allocation");
+} else {
+ret = av_packet_make_refcounted();
+if (ret < 0)
+error("Failed memory allocation");
+}
 if ( parser->key_frame == 1 ||
 (parser->key_frame == -1 && parser->pict_type == 
AV_PICTURE_TYPE_I))
 avpkt.flags |= AV_PKT_FLAG_KEY;
 avpkt.flags |= parsepkt.flags & AV_PKT_FLAG_DISCARD;
 } else {
-avpkt = parsepkt;
-parsepkt.size = 0;
+av_packet_move_ref(, );
 }
 
   // Iterate through all data
@@ -284,16 +254,17 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t 
size) {
 avpkt.data += ret;
 avpkt.size -= ret;
   }
+  av_packet_unref();
 }
+av_packet_unref();
 }
 maximums_reached:
 
-av_init_packet();
-avpkt.data = NULL;
-avpkt.size = 0;
+av_packet_unref();
 
 do {
 got_frame = 0;
+av_frame_unref(frame);
 decode_handler(ctx, frame, _frame, );
 } while (got_frame == 1 && it++ < maxiteration);
 
@@ -303,6 +274,6 @@ 

Re: [FFmpeg-devel] [PATCH] lavf/vf_deinterlace_vaapi: flush queued frame in field mode

2019-08-20 Thread Fu, Linjie
> -Original Message-
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Mark Thompson
> Sent: Wednesday, August 21, 2019 04:49
> To: ffmpeg-devel@ffmpeg.org
> Subject: Re: [FFmpeg-devel] [PATCH] lavf/vf_deinterlace_vaapi: flush
> queued frame in field mode
> 
> On 02/08/2019 10:53, Linjie Fu wrote:
> > Add deint_vaapi_request_frame for deinterlace_vaapi, send NULL frame
> > to flush the queued frame.
> >
> > Fix the frame drop issue in field mode:
> >
> > ffmpeg -hwaccel vaapi -vaapi_device /dev/dri/renderD128 -v verbose -c:v
> > h264 -i ./input.h264 -vf 'format=nv12|vaapi,hwupload,
> > deinterlace_vaapi=mode=bob:rate=field,hwdownload,format=nv12'
> > -pix_fmt yuv420p -f rawvideo -vsync passthrough -y dump.yuv
> >
> > Signed-off-by: Linjie Fu 
> > ---
> >  libavfilter/vf_deinterlace_vaapi.c | 46
> --
> >  1 file changed, 39 insertions(+), 7 deletions(-)
> 
> Can you explain in more detail what the problem is here?  What frame is
> being dropped?


Would you please try this clips to see whether it could be reproduced on your 
side?
https://drive.google.com/open?id=11FZlT0vl_GoGjlEuihpZHgbwgVA7yGUV


$ ffmpeg -hwaccel vaapi -vaapi_device /dev/dri/renderD128 
-hwaccel_output_format vaapi -v verbose -c:v h264 -i ./input.h264 -vf 
'hwupload,deinterlace_vaapi=mode=bob:rate=frame' -f null -

2 frames

$ ffmpeg -hwaccel vaapi -vaapi_device /dev/dri/renderD128 
-hwaccel_output_format vaapi -v verbose -c:v h264 -i ./input.h264 -vf 
'hwupload,deinterlace_vaapi=mode=bob:rate=field' -f null -

Before applying:
2 frames

After applying:
4 frames 

> With this patch applied, the filter always segfaults for me at the end of the
> stream when set to field rate:

This patch just sends a NULL frame to deint_vaapi_request_frame() at the end.
Since the input_frame is not NULL in the log, it's kind of weird if it triggers 
a segfault.

Is it possible to share the clips to reproduce this?

> $ gdb --args ./ffmpeg_g -hwaccel vaapi -hwaccel_device
> /dev/dri/renderD129 -hwaccel_output_format vaapi -i f100.mp4 -an -vf
> deinterlace_vaapi=rate=field -f null -
> ...
> Thread 1 "ffmpeg_g" received signal SIGSEGV, Segmentation fault.
> 0x55755fb1 in deint_vaapi_filter_frame (inlink=0x59092300,
> input_frame=0x58d42000) at src/libavfilter/vf_deinterlace_vaapi.c:227
> 227 ctx->frame_queue[current_frame_index + i + 1]->data[3];
> (gdb) bt
> #0  0x55755fb1 in deint_vaapi_filter_frame (inlink=0x59092300,
> input_frame=0x58d42000) at src/libavfilter/vf_deinterlace_vaapi.c:227


Thanks for the response.

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

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

Re: [FFmpeg-devel] [PATCH] Change libaom default to crf=28.

2019-08-20 Thread Elliott Karpilovsky
I believe the documentation is out of date. I added some debug
statements and verified that variable was being used to pull CRF
values when AOM_Q mode is set. I have
https://aomedia-review.googlesource.com/c/aom/+/94104 out to update
the documentation.


On Fri, Aug 16, 2019 at 10:59 AM James Zern
 wrote:
>
> Hi,
>
> On Thu, Aug 15, 2019 at 1:22 PM elliottk
>  wrote:
> >
> > Current default is 256kbps, which produces inconsistent
> > results (too high for low-res, too low for hi-res).
> > Use CRF instead, which will adapt.
> > ---
> >  libavcodec/libaomenc.c | 9 +
> >  1 file changed, 5 insertions(+), 4 deletions(-)
> >
> > diff --git a/libavcodec/libaomenc.c b/libavcodec/libaomenc.c
> > index 9b4fb3b4eb..621e897672 100644
> > --- a/libavcodec/libaomenc.c
> > +++ b/libavcodec/libaomenc.c
> > @@ -575,10 +575,11 @@ static av_cold int aom_init(AVCodecContext *avctx,
> >  if (enccfg.rc_end_usage == AOM_CQ) {
> >  enccfg.rc_target_bitrate = 100;
> >  } else {
> > -avctx->bit_rate = enccfg.rc_target_bitrate * 1000;
> > +enccfg.rc_end_usage = AOM_Q;
>
> Unless the docs are out of date this should be AOM_CQ level since crf
> is mapped to that control [1].
>
> > +ctx->crf = 28;
> >  av_log(avctx, AV_LOG_WARNING,
> > -   "Neither bitrate nor constrained quality specified, 
> > using default bitrate of %dkbit/sec\n",
> > -   enccfg.rc_target_bitrate);
> > +   "Neither bitrate nor constrained quality specified, 
> > using default CRF of %d\n",
> > +   ctx->crf);
> >  }
> >  }
> >
>
> [1] https://aomedia.googlesource.com/aom/+/refs/heads/master/aom/aomcx.h#221
> "For this value to be used aom_codec_enc_cfg_t::rc_end_usage must be
> set to #AOM_CQ."
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH v2] avcodec/h264_parse: retry decoding SPS with complete NAL

2019-08-20 Thread Jun Li
On Mon, Aug 19, 2019 at 7:24 PM Jun Li  wrote:

> Fix #6591
> The content has no rbsp_stop_one_bit for ending the SPS, that
> causes the decoding SPS failure, results decoding frame failure as well.
>
> The patch is just adding a retry with complete NALU, copied from the retry
> in decode_nal_unit()
> ---
>  libavcodec/h264_parse.c | 11 +--
>  1 file changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/libavcodec/h264_parse.c b/libavcodec/h264_parse.c
> index ac31f54e07..ea7a958dd9 100644
> --- a/libavcodec/h264_parse.c
> +++ b/libavcodec/h264_parse.c
> @@ -376,8 +376,15 @@ static int decode_extradata_ps(const uint8_t *data,
> int size, H264ParamSets *ps,
>  switch (nal->type) {
>  case H264_NAL_SPS:
>  ret = ff_h264_decode_seq_parameter_set(>gb, logctx, ps,
> 0);
> -if (ret < 0)
> -goto fail;
> +if (ret < 0) {
> +GetBitContext tmp_gb = nal->gb;
> +av_log(logctx, AV_LOG_DEBUG,
> +   "SPS decoding failure, trying again with the complete
> NAL\n");
> +init_get_bits8(_gb, nal->raw_data + 1, nal->raw_size
> - 1);
> +if ((ret = ff_h264_decode_seq_parameter_set(_gb,
> logctx, ps, 0)) < 0 &&
> +(ret = ff_h264_decode_seq_parameter_set(_gb,
> logctx, ps, 1)) < 0)
> +goto fail;
> +}
>  break;
>  case H264_NAL_PPS:
>  ret = ff_h264_decode_picture_parameter_set(>gb, logctx,
> ps,
> --
> 2.17.1
>
>
Ping
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH V3] avcodec/libvpxenc: add ROI-based encoding support for VP8/VP9 support

2019-08-20 Thread James Zern
Hi,

On Tue, Aug 13, 2019 at 8:29 PM Guo, Yejun  wrote:
> example command line to verify it:
> ./ffmpeg -i input.stream -vf addroi=0:0:iw/3:ih/3:-0.8 -c:v libvpx -b:v 2M 
> tmp.webm
>
> Signed-off-by: Guo, Yejun 
> ---
>  libavcodec/libvpxenc.c | 197 
> +
>  1 file changed, 197 insertions(+)
>
> [...]
>
> +
> +memset(roi_map, 0, sizeof(*roi_map));
> +
> +/* segment id 0 in roi_map is reserved for the areas not covered by 
> AVRegionOfInterest.
> + * segment id 0 in roi_map is also for the areas with 
> AVRegionOfInterest.qoffset near 0.
> + * (delta_q of segment id 0 is 0).
> + */
> +segment_mapping[MAX_DELTA_Q] = 1;
> +/* roi_map has memset with zero, just explictly set it again for explict 
> understanding. */

There are some typos in this, but as the comment says, it's redundant.
I think this and
the next line could be removed.

> +roi_map->delta_q[0] = 0;
> +segment_id = 1;
> +
> +roi = (const AVRegionOfInterest*)sd->data;
> +self_size = roi->self_size;
> +if (!self_size || sd->size % self_size != 0) {
> +av_log(avctx, AV_LOG_ERROR, "Invalid 
> AVRegionOfInterest.self_size.\n");
> +return AVERROR(EINVAL);
> +}
> +nb_rois = sd->size / self_size;
> +
> +/* This list must be iterated from zero because regions are
> + * defined in order of decreasing importance. So discard less
> + * important areas if they exceed the segment count.
> + */
> +for (int i = 0; i < nb_rois; i++) {
> +int delta_q;
> +int mapping_index;
> +
> +roi = (const AVRegionOfInterest*)(sd->data + self_size * i);
> +if (roi->qoffset.den == 0) {
> +av_log(avctx, AV_LOG_ERROR, "AVRegionOfInterest.qoffset.den must 
> not be zero.\n");
> +return AVERROR(EINVAL);
> +}
> +
> +delta_q = (int)(roi->qoffset.num * 1.0f / roi->qoffset.den * 
> MAX_DELTA_Q);
> +delta_q = av_clip(delta_q, -MAX_DELTA_Q, MAX_DELTA_Q);
> +

Note that libvpx allows other adjustments (loop filter, block skipping, among
others), but there may not be a way to provide this with AVRegionOfInterest.

> [...]
> +
> +if (ctx->aq_mode > 0 || ctx->cpu_used < 5 || ctx->deadline != 
> VPX_DL_REALTIME) {
> +if (!ctx->roi_warned) {
> +ctx->roi_warned = 1;
> +if (ctx->aq_mode > 0)
> +av_log(avctx, AV_LOG_WARNING, "ROI is disabled when any 
> of AQ mode is on, skipping ROI.\n");
> +else
> +av_log(avctx, AV_LOG_WARNING, "due to libvpx's internal 
> issue (see function apply_roi_map), skipping ROI.\n");

I think this could just mention that ROI is only supported with aq_mode==0,
cpu_used >= 5 and deadline set to realtime rather than having a more specific
statement like this one.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH 0/3] AVEncodeInfo and extractqp changes

2019-08-20 Thread Juan De León
On Mon, Aug 19, 2019 at 4:37 PM Juan De León  wrote:

> Proposed changes to use AVEncodeInfoFrame and AVencodeInfoBlock
> data types as AVFrameSideData, including the changes tothe h264
> decoder as well as a filter to output the data extracted.
>
> Filter can be called using:
> ffmpeg -debug extractqp -i  -lavfi extractqp=extractqp.log -f
> null -
>
> More options in filters.texi, libx264 has to be enabled.
>
> doc/filters.texi   |  40 ++
>  libavfilter/Makefile   |   1 +
>  libavfilter/allfilters.c   |   1 +
>  libavfilter/vf_extractqp.c | 243
> +
>  4 files changed, 285 insertions(+)
>
> libavcodec/avcodec.h   |  1 +
>  libavcodec/h264dec.c   | 40 
>  libavcodec/options_table.h |  1 +
>  3 files changed, 42 insertions(+)
>
> libavutil/Makefile  |   2 ++
>  libavutil/encode_info.c |  70
> +
>  libavutil/encode_info.h | 110
> 
>  libavutil/frame.c   |   1 +
>  libavutil/frame.h   |   7 +++
>  5 files changed, 190 insertions(+)
>
>
A very gentle ping.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

[FFmpeg-devel] [PATCH v1 2/3] avformat/hlsenc: fix memleak of filename

2019-08-20 Thread Steven Liu
CID: 1452445
Signed-off-by: Steven Liu 
---
 libavformat/hlsenc.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index fbc6554b97..689e29edcc 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -2580,9 +2580,8 @@ static int hls_write_trailer(struct AVFormatContext *s)
 
 vs->size = range_length;
 hlsenc_io_close(s, >out, filename);
-av_free(filename);
-
 failed:
+av_free(filename);
 av_write_trailer(oc);
 if (oc->url[0]) {
 proto = avio_find_protocol_name(oc->url);
-- 
2.15.1




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

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

[FFmpeg-devel] [PATCH v1 3/3] avformat/hlsenc: remove unused value

2019-08-20 Thread Steven Liu
CID: 1452644
Signed-off-by: Steven Liu 
---
 libavformat/hlsenc.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 689e29edcc..6b0f49c3b7 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -2786,7 +2786,6 @@ static int hls_init(AVFormatContext *s)
 ret = format_name(hls->segment_filename, >basename, i, 
vs->varname);
 if (ret < 0)
 goto fail;
-basename_size = strlen(vs->basename) + 1;
 } else {
 if (hls->flags & HLS_SINGLE_FILE) {
 if (hls->segment_type == SEGMENT_TYPE_FMP4) {
-- 
2.15.1



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

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

[FFmpeg-devel] [PATCH v1 1/3] avformat/hlsenc: fix memleak in hls_write_trailer

2019-08-20 Thread Steven Liu
fix CID: 1426931

Signed-off-by: Steven Liu 
---
 libavformat/hlsenc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 836e290eea..fbc6554b97 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -2539,6 +2539,7 @@ static int hls_write_trailer(struct AVFormatContext *s)
 filename = av_asprintf("%s", vs->avf->url);
 }
 if (!filename) {
+av_free(old_filename);
 return AVERROR(ENOMEM);
 }
 
-- 
2.15.1



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

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

Re: [FFmpeg-devel] [PATCH] lavf: Add DICOM demuxer, lavc: Add DICOM decoder

2019-08-20 Thread Michael Niedermayer
On Tue, Aug 20, 2019 at 08:53:43PM +0530, Shivam wrote:
> Sorry, for my previous mail, i forgot to attach the patch.
> 
> The patch contains support for Dicom files. The below features are supported
> yet:-
> Uncompressed DICOM files using any of the Implicit and Explicit VR formats.
> Multiframe files are also supported.
> To extract the metadata or info about the procedure, I have added an option
> "-metadata." (The tags present in Dicom dictionary would be demuxed).
> 
> I have also uploaded DICOM samples here.
> https://1drv.ms/u/s!AosJ9_SrP4Tsh2WoPfQAI8cSsqUs?e=ZMd5fR
> 
> Please review,
> 
> Thank you,
> Shivam Goyal
> 

>  Changelog|1 
>  libavcodec/Makefile  |1 
>  libavcodec/allcodecs.c   |1 
>  libavcodec/avcodec.h |1 
>  libavcodec/codec_desc.c  |7 
>  libavcodec/dicom.c   |  189 
>  libavcodec/version.h |2 
>  libavformat/Makefile |1 
>  libavformat/allformats.c |1 
>  libavformat/dicom.h  |  108 +++
>  libavformat/dicomdec.c   |  594 ++
>  libavformat/dicomdict.c  |  716 
> +++
>  libavformat/version.h|2 
>  13 files changed, 1622 insertions(+), 2 deletions(-)
> d47b7ad6a9f16ce4e29a67a99800183f9056062d  add_dicom.patch
> From cd7ebe834278b29b0429b3f5b377154490ee159f Mon Sep 17 00:00:00 2001
> From: Shivam Goyal <1998.goyal.shi...@gmail.com>
> Date: Tue, 20 Aug 2019 20:03:02 +0530
> Subject: [PATCH] lavc: add DICOM decoder, lavf: add DICOM demuxer
> 

> ---
>  Changelog|   1 +
>  libavcodec/Makefile  |   1 +
>  libavcodec/allcodecs.c   |   1 +
>  libavcodec/avcodec.h |   1 +
>  libavcodec/codec_desc.c  |   7 +
>  libavcodec/dicom.c   | 189 +++
>  libavcodec/version.h |   2 +-
>  libavformat/Makefile |   1 +
>  libavformat/allformats.c |   1 +
>  libavformat/dicom.h  | 108 ++
>  libavformat/dicomdec.c   | 594 
>  libavformat/dicomdict.c  | 716 +++
>  libavformat/version.h|   2 +-

libavformat and libavcodec changes should be in seperate patches


>  13 files changed, 1622 insertions(+), 2 deletions(-)
>  create mode 100644 libavcodec/dicom.c
>  create mode 100644 libavformat/dicom.h
>  create mode 100644 libavformat/dicomdec.c
>  create mode 100644 libavformat/dicomdict.c
> 
> diff --git a/Changelog b/Changelog
> index c1f1237770..e04c3aa5f6 100644
> --- a/Changelog
> +++ b/Changelog
> @@ -4,6 +4,7 @@ releases are sorted from youngest to oldest.
>  version :
>  - Intel QSV-accelerated MJPEG decoding
>  - Intel QSV-accelerated VP9 decoding
> +- DICOM decoder and demxer
>  
>  version 4.2:
>  - tpad filter
> diff --git a/libavcodec/Makefile b/libavcodec/Makefile
> index e49188357b..799da8aef7 100644
> --- a/libavcodec/Makefile
> +++ b/libavcodec/Makefile
> @@ -263,6 +263,7 @@ OBJS-$(CONFIG_DCA_DECODER) += dcadec.o dca.o 
> dcadata.o dcahuff.o \
>  OBJS-$(CONFIG_DCA_ENCODER) += dcaenc.o dca.o dcadata.o dcahuff.o 
> \
>dcaadpcm.o
>  OBJS-$(CONFIG_DDS_DECODER) += dds.o
> +OBJS-$(CONFIG_DICOM_DECODER)   += dicom.o
>  OBJS-$(CONFIG_DIRAC_DECODER)   += diracdec.o dirac.o diracdsp.o 
> diractab.o \
>dirac_arith.o dirac_dwt.o 
> dirac_vlc.o
>  OBJS-$(CONFIG_DFA_DECODER) += dfa.o
> diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
> index 22985325e0..02a1afa7e8 100644
> --- a/libavcodec/allcodecs.c
> +++ b/libavcodec/allcodecs.c
> @@ -83,6 +83,7 @@ extern AVCodec ff_cscd_decoder;
>  extern AVCodec ff_cyuv_decoder;
>  extern AVCodec ff_dds_decoder;
>  extern AVCodec ff_dfa_decoder;
> +extern AVCodec ff_dicom_decoder;
>  extern AVCodec ff_dirac_decoder;
>  extern AVCodec ff_dnxhd_encoder;
>  extern AVCodec ff_dnxhd_decoder;
> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> index d234271c5b..756e168c75 100644
> --- a/libavcodec/avcodec.h
> +++ b/libavcodec/avcodec.h
> @@ -410,6 +410,7 @@ enum AVCodecID {
>  AV_CODEC_ID_SCREENPRESSO,
>  AV_CODEC_ID_RSCC,
>  AV_CODEC_ID_AVS2,
> +AV_CODEC_ID_DICOM,
>  
>  AV_CODEC_ID_Y41P = 0x8000,
>  AV_CODEC_ID_AVRP,
> diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
> index 4d033c20ff..ae9abdb2ba 100644
> --- a/libavcodec/codec_desc.c
> +++ b/libavcodec/codec_desc.c
> @@ -1403,6 +1403,13 @@ static const AVCodecDescriptor codec_descriptors[] = {
>  .long_name = NULL_IF_CONFIG_SMALL("AVS2-P2/IEEE1857.4"),
>  .props = AV_CODEC_PROP_LOSSY,
>  },
> +{
> +.id= AV_CODEC_ID_DICOM,
> +.type  = AVMEDIA_TYPE_VIDEO,
> +.name  = "dicom",
> +.long_name = NULL_IF_CONFIG_SMALL("DICOM (Digital Imaging and 
> Communications in Medicine)"),
> +.props = AV_CODEC_PROP_LOSSY | AV_CODEC_PROP_LOSSLESS,
> +

Re: [FFmpeg-devel] [REQUEST] avcodec/scpr: revert d70276921348

2019-08-20 Thread James Almer
On 8/20/2019 3:32 PM, Michael Niedermayer wrote:
> On Tue, Aug 20, 2019 at 02:52:49PM -0300, James Almer wrote:
>> On 8/20/2019 2:46 PM, Michael Niedermayer wrote:
>>> On Tue, Aug 20, 2019 at 02:49:13PM +0200, Paul B Mahol wrote:
 Hi,

 I kindly ask that following commit: 
 d702769213487923c0fb0abe4b61f4d9ebddb88b
 is reverted as it does contradicts with reference decoder.
>>>
>>> Noone is listed in MAINTAINERs for scpr.c
>>> the main author of scpr.c is you, so  i think you are the closest to a
>>> maintainer.
>>>
>>> So if after everyone who wants to comment has commented you still want this
>>> reverted. Then ill revert (or you can revert too)
>>> but personally i think that skiping duplicated frames has many advantages
>>> and its better to skip them
>>>
>>> Thanks
>>
>> I suggested on IRC to add an option somewhere (new AVCodecContext field?
>> ffmpeg cli option? Mapping it to AV_CODEC_FLAG2_FAST?) to tell crf
>> decoders to instead output vrf in situations like this.
> 
> IMHO never output known duplicate frames is best. But if people want to
> change this. A flag/field is the next best option.

> AV_CODEC_FLAG2_FAST does not solve this as the flag has a different
> meaning.

How so? The doxy says "Allow non spec compliant speedup tricks.".
Outputting vfr when cfr is the spec compliant behavior sure sounds like
it's a good fit for this feature.

A new flag/field would be needed
> 
> Thanks
> 
> [...]
> 
> 
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
> 

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

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

Re: [FFmpeg-devel] [REQUEST] avcodec/scpr: revert d70276921348

2019-08-20 Thread Michael Niedermayer
On Tue, Aug 20, 2019 at 02:49:13PM +0200, Paul B Mahol wrote:
> Hi,
> 
> I kindly ask that following commit: d702769213487923c0fb0abe4b61f4d9ebddb88b
> is reverted as it does contradicts with reference decoder.

Noone is listed in MAINTAINERs for scpr.c
the main author of scpr.c is you, so  i think you are the closest to a
maintainer.

So if after everyone who wants to comment has commented you still want this
reverted. Then ill revert (or you can revert too)
but personally i think that skiping duplicated frames has many advantages
and its better to skip them

Thanks

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

I do not agree with what you have to say, but I'll defend to the death your
right to say it. -- Voltaire


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

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

Re: [FFmpeg-devel] [PATCH v2 1/3] avfilter: add v360 filter

2019-08-20 Thread James Almer
On 8/20/2019 5:29 AM, Paul B Mahol wrote:
> On Mon, Aug 19, 2019 at 11:31 PM James Almer  wrote:
> 
>> On 8/13/2019 10:14 PM, Eugene Lyapustin wrote:
>>> Signed-off-by: Eugene Lyapustin 
>>> ---
>>>  doc/filters.texi |  137 +++
>>>  libavfilter/Makefile |1 +
>>>  libavfilter/allfilters.c |1 +
>>>  libavfilter/vf_v360.c| 1847 ++
>>>  4 files changed, 1986 insertions(+)
>>>  create mode 100644 libavfilter/vf_v360.c
>>>
>>> diff --git a/doc/filters.texi b/doc/filters.texi
>>
>> Shouldn't this make use of the AVSphericalMapping frame side data if
>> available?
>>
> 
> It is extremely limited API.

It can surely be extended if required.

> And due lavfi limitations it can only clear current side data and set new one.

Isn't that enough? This filter converts from one projection to another.
Replacing the side data after said conversion to reflect the changes
would be the expected behavior.

> 
> 
>> ___
>> ffmpeg-devel mailing list
>> ffmpeg-devel@ffmpeg.org
>> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>
>> To unsubscribe, visit link above, or email
>> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
> 

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

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

Re: [FFmpeg-devel] [REQUEST] avcodec/scpr: revert d70276921348

2019-08-20 Thread Michael Niedermayer
On Tue, Aug 20, 2019 at 02:52:49PM -0300, James Almer wrote:
> On 8/20/2019 2:46 PM, Michael Niedermayer wrote:
> > On Tue, Aug 20, 2019 at 02:49:13PM +0200, Paul B Mahol wrote:
> >> Hi,
> >>
> >> I kindly ask that following commit: 
> >> d702769213487923c0fb0abe4b61f4d9ebddb88b
> >> is reverted as it does contradicts with reference decoder.
> > 
> > Noone is listed in MAINTAINERs for scpr.c
> > the main author of scpr.c is you, so  i think you are the closest to a
> > maintainer.
> > 
> > So if after everyone who wants to comment has commented you still want this
> > reverted. Then ill revert (or you can revert too)
> > but personally i think that skiping duplicated frames has many advantages
> > and its better to skip them
> > 
> > Thanks
> 
> I suggested on IRC to add an option somewhere (new AVCodecContext field?
> ffmpeg cli option? Mapping it to AV_CODEC_FLAG2_FAST?) to tell crf
> decoders to instead output vrf in situations like this.

IMHO never output known duplicate frames is best. But if people want to
change this. A flag/field is the next best option.
AV_CODEC_FLAG2_FAST does not solve this as the flag has a different
meaning. A new flag/field would be needed

Thanks

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

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


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

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

Re: [FFmpeg-devel] [PATCH] lavf/vf_deinterlace_vaapi: flush queued frame in field mode

2019-08-20 Thread Mark Thompson
On 02/08/2019 10:53, Linjie Fu wrote:
> Add deint_vaapi_request_frame for deinterlace_vaapi, send NULL frame
> to flush the queued frame.
> 
> Fix the frame drop issue in field mode:
> 
> ffmpeg -hwaccel vaapi -vaapi_device /dev/dri/renderD128 -v verbose -c:v
> h264 -i ./input.h264 -vf 'format=nv12|vaapi,hwupload,
> deinterlace_vaapi=mode=bob:rate=field,hwdownload,format=nv12'
> -pix_fmt yuv420p -f rawvideo -vsync passthrough -y dump.yuv
> 
> Signed-off-by: Linjie Fu 
> ---
>  libavfilter/vf_deinterlace_vaapi.c | 46 
> --
>  1 file changed, 39 insertions(+), 7 deletions(-)

Can you explain in more detail what the problem is here?  What frame is being 
dropped?


I already get the expected number of frames out with both rate settings (input 
total - forward references - backward references, all multiplied by 2 for field 
rate output).  E.g. for 100 frames/field-pairs of input:

$ ./ffmpeg_g -hwaccel vaapi -hwaccel_device /dev/dri/renderD129 
-hwaccel_output_format vaapi -i f100.mp4 -an -vf deinterlace_vaapi=rate=frame 
-f null -
...
frame=   97

$ ./ffmpeg_g -hwaccel vaapi -hwaccel_device /dev/dri/renderD129 
-hwaccel_output_format vaapi -i f100.mp4 -an -vf deinterlace_vaapi=rate=field 
-f null -
...
frame=  194

(With forward = 2, backward = 1.)


With this patch applied, the filter always segfaults for me at the end of the 
stream when set to field rate:

$ gdb --args ./ffmpeg_g -hwaccel vaapi -hwaccel_device /dev/dri/renderD129 
-hwaccel_output_format vaapi -i f100.mp4 -an -vf deinterlace_vaapi=rate=field 
-f null -
...
Thread 1 "ffmpeg_g" received signal SIGSEGV, Segmentation fault.
0x55755fb1 in deint_vaapi_filter_frame (inlink=0x59092300, 
input_frame=0x58d42000) at src/libavfilter/vf_deinterlace_vaapi.c:227
227 ctx->frame_queue[current_frame_index + i + 1]->data[3];
(gdb) bt
#0  0x55755fb1 in deint_vaapi_filter_frame (inlink=0x59092300, 
input_frame=0x58d42000) at src/libavfilter/vf_deinterlace_vaapi.c:227
#1  0x557565d2 in deint_vaapi_request_frame (link=0x590928c0) at 
src/libavfilter/vf_deinterlace_vaapi.c:342
#2  0x556ce950 in ff_request_frame_to_filter (link=0x590928c0) at 
src/libavfilter/avfilter.c:458
#3  0x556d0cd0 in forward_status_change (filter=0x59088940, 
in=0x59092300) at src/libavfilter/avfilter.c:1243
#4  0x556d0eaf in ff_filter_activate_default (filter=0x59088940) at 
src/libavfilter/avfilter.c:1274
#5  0x556d0fec in ff_filter_activate (filter=0x59088940) at 
src/libavfilter/avfilter.c:1430
#6  0x556d5d29 in ff_filter_graph_run_once (graph=0x5908ff00) at 
src/libavfilter/avfiltergraph.c:1456
#7  0x556d71d8 in push_frame (graph=0x5908ff00) at 
src/libavfilter/buffersrc.c:187
#8  0x556d77a9 in av_buffersrc_close (ctx=0x59091ac0, pts=300300, 
flags=4) at src/libavfilter/buffersrc.c:275
#9  0x5569356a in ifilter_send_eof (ifilter=0x580d0e40, pts=300300) 
at src/fftools/ffmpeg.c:2213
#10 0x556949fd in send_filter_eof (ist=0x580f3ac0) at 
src/fftools/ffmpeg.c:2562
#11 0x55695336 in process_input_packet (ist=0x580f3ac0, pkt=0x0, 
no_eof=0) at src/fftools/ffmpeg.c:2701
#12 0x5569a9db in process_input (file_index=0) at 
src/fftools/ffmpeg.c:4313
#13 0x5569c5f9 in transcode_step () at src/fftools/ffmpeg.c:4638
#14 0x5569c726 in transcode () at src/fftools/ffmpeg.c:4692
#15 0x5569cfb6 in main (argc=15, argv=0x7fffe488) at 
src/fftools/ffmpeg.c:4894
(gdb) p current_frame_index 
$1 = 2
(gdb) p i
$2 = 0
(gdb) p ctx->frame_queue[current_frame_index + i + 1]
$3 = (AVFrame *) 0x0


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

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

Re: [FFmpeg-devel] [REQUEST] avcodec/scpr: revert d70276921348

2019-08-20 Thread Michael Niedermayer
On Tue, Aug 20, 2019 at 05:09:51PM +0100, Kieran Kunhya wrote:
> On Tue, 20 Aug 2019 at 14:16, Carl Eugen Hoyos  wrote:
> 
> > Am Di., 20. Aug. 2019 um 14:48 Uhr schrieb Paul B Mahol  > >:
> >
> > > I kindly ask that following commit:
> > d702769213487923c0fb0abe4b61f4d9ebddb88b
> >
> > I still believe what the patch does is a very good idea and a revert would
> > hurt FFmpeg.
> >
> 
> We should not turn CFR streams into VFR. This would not be acceptable for
> H264 not should it be acceptable for any other codec.

All MPEG & ITU codecs i remember follow this too as far as possible, 
including H264

You can look at mpeg12dec.c:

/* first check if we must repeat the frame */
s->current_picture_ptr->f->repeat_pict = 0;
if (s->repeat_first_field) {
if (s->progressive_sequence) {
if (s->top_field_first)
s->current_picture_ptr->f->repeat_pict = 4;
else
s->current_picture_ptr->f->repeat_pict = 2;
} else if (s->progressive_frame) {
s->current_picture_ptr->f->repeat_pict = 1;
}
}

This exports the number of times to repeat the frame, it does not
output CFR with duplicated frames

But lets look at mpeg4:
/* vop coded */
if (get_bits1(gb) != 1) {
if (s->avctx->debug & FF_DEBUG_PICT_INFO)
av_log(s->avctx, AV_LOG_ERROR, "vop not coded\n");
return FRAME_SKIPPED;
}

now lets look at the spec what vop_coded is: 
vop_coded: This is a 1-bit flag which when set to '0' indicates that no 
subsequent data exists for the VOP. In this
case, the following decoding rules apply: If binary shape or alpha plane does 
exist for the VOP (i.e.
video_object_layer_shape != "rectangular"), it shall be completely transparent. 
If binary shape or alpha plane does
not exist for the VOP (i.e. video_object_layer_shape == "rectangular"), the 
luminance and chrominance planes of
the reconstructed VOP shall be filled with the forward reference VOP as defined 
in subclause 7.6.7.
   
This clearly wants us to duplicate the frame, yet we do not

But you asked for h264:
here is H264:

case H264_SEI_PIC_STRUCT_FRAME_DOUBLING:
cur->f->repeat_pict = 2;
break;
case H264_SEI_PIC_STRUCT_FRAME_TRIPLING:
cur->f->repeat_pict = 4;
break;
}

again, we return metadata we do not return the same frame 
   
same is true for msmpeg4 and every other codec which uses metadata at AVI level
that is skiped frames. The codecs are CFR at AVI level but we do not output CFR

But what is more bizare (to me at least) is that this was not a controversy
at the time CFR was the standard and all these codecs where "new". 
Please correct me if iam wrong but the "CFR must be CFR" seems to originate 
from some professional broadcast people (like you). 
But then it seems the codecs which broadcast people use
the fact they dont preserve CFR in this way isnt a problem and not even noticed 
while for codecs that broadcast has noting to do with like SCPR its a big issue.
This makes no sense to me.

Thanks


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

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


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

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

Re: [FFmpeg-devel] [REQUEST] avcodec/scpr: revert d70276921348

2019-08-20 Thread James Almer
On 8/20/2019 2:46 PM, Michael Niedermayer wrote:
> On Tue, Aug 20, 2019 at 02:49:13PM +0200, Paul B Mahol wrote:
>> Hi,
>>
>> I kindly ask that following commit: d702769213487923c0fb0abe4b61f4d9ebddb88b
>> is reverted as it does contradicts with reference decoder.
> 
> Noone is listed in MAINTAINERs for scpr.c
> the main author of scpr.c is you, so  i think you are the closest to a
> maintainer.
> 
> So if after everyone who wants to comment has commented you still want this
> reverted. Then ill revert (or you can revert too)
> but personally i think that skiping duplicated frames has many advantages
> and its better to skip them
> 
> Thanks

I suggested on IRC to add an option somewhere (new AVCodecContext field?
ffmpeg cli option? Mapping it to AV_CODEC_FLAG2_FAST?) to tell crf
decoders to instead output vrf in situations like this.

Paul didn't like the idea, but i still think it's worth considering.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [REQUEST] avcodec/scpr: revert d70276921348

2019-08-20 Thread Michael Niedermayer
On Tue, Aug 20, 2019 at 09:18:09PM +0100, Kieran Kunhya wrote:
> On Tue, 20 Aug 2019 at 18:06, Michael Niedermayer 
> wrote:
> 
> > On Tue, Aug 20, 2019 at 05:09:51PM +0100, Kieran Kunhya wrote:
> > > On Tue, 20 Aug 2019 at 14:16, Carl Eugen Hoyos 
> > wrote:
> > >
> > > > Am Di., 20. Aug. 2019 um 14:48 Uhr schrieb Paul B Mahol <
> > one...@gmail.com
[...]
> 
> 
> 
> > But what is more bizare (to me at least) is that this was not a controversy
> > at the time CFR was the standard and all these codecs where "new".
> > Please correct me if iam wrong but the "CFR must be CFR" seems to
> > originate
> > from some professional broadcast people (like you).
> >
> 
> This is what you would call an "ad-hominem"

I was in fact unsure what term to use when writing this but I belived
that "professional broadcast people" would be considered a polite term.
Apparently not and in that sense really no term i could have used would
have worked.
I mean anything thats in the dictionary would have been seen this way
probably, if this was ...

I just tried to explain the situation and the source of the viewpoints
from how i remembered it but its hard when theres no word that one can
use ... or when iam to dumb to find that word ...

Sorry but that really was not meant as an insult

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Avoid a single point of failure, be that a person or equipment.


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

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

Re: [FFmpeg-devel] [PATCH v2 1/2] vaapi_encode: ensure correct VBR bitrate is used in h264 SPS

2019-08-20 Thread Mark Thompson
On 13/08/2019 02:04, Aman Gupta wrote:
> From: Aman Gupta 
> 
> This is a regression from 2562dd9e7831743ba6dc5680501fb7d26a2ec62c
> which surfaces a pathological bug in some Intel hardware encoders,
> causing very low bitrates to be generated whenever VBR mode is used.
> 
> /cc intel/intel-vaapi-driver#480
> 
> Signed-off-by: Aman Gupta 
> ---
>  libavcodec/vaapi_encode.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c
> index e69b59fa37..231efba6cc 100644
> --- a/libavcodec/vaapi_encode.c
> +++ b/libavcodec/vaapi_encode.c
> @@ -1665,6 +1665,9 @@ rc_mode_found:
>  ctx->va_rc_mode  = rc_mode->va_mode;
>  ctx->va_bit_rate = rc_bits_per_second;
>  
> +if (ctx->va_rc_mode == VA_RC_VBR)
> +ctx->va_bit_rate = rc_bits_per_second * rc_target_percentage / 100;
> +
>  av_log(avctx, AV_LOG_VERBOSE, "RC mode: %s.\n", rc_mode->name);
>  if (rc_attr.value == VA_ATTRIB_NOT_SUPPORTED) {
>  // This driver does not want the RC mode attribute to be set.
> 

The bits_per_second value in the sequence parameters has to match the one in 
the rate control parameters.  That's the max rate value, not the target as 
modified by target_percentage.

For i965, see 
 
(lines 392, 584, 743).  When they don't match, it will repeatedly try to change 
the target bitrate and reset everything.


On 13/08/2019 03:42, Fu, Linjie wrote:
> 
> If it's a driver related issue, IMHO we'd better have it fixed in specific 
> driver.

This.

Thanks,

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

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

[FFmpeg-devel] [PATCH] lavf: Add DICOM demuxer, lavc: Add DICOM decoder

2019-08-20 Thread Shivam

Sorry, for my previous mail, i forgot to attach the patch.

The patch contains support for Dicom files. The below features are 
supported yet:-

Uncompressed DICOM files using any of the Implicit and Explicit VR formats.
Multiframe files are also supported.
To extract the metadata or info about the procedure, I have added an 
option "-metadata." (The tags present in Dicom dictionary would be demuxed).


I have also uploaded DICOM samples here.
https://1drv.ms/u/s!AosJ9_SrP4Tsh2WoPfQAI8cSsqUs?e=ZMd5fR

Please review,

Thank you,
Shivam Goyal

>From cd7ebe834278b29b0429b3f5b377154490ee159f Mon Sep 17 00:00:00 2001
From: Shivam Goyal <1998.goyal.shi...@gmail.com>
Date: Tue, 20 Aug 2019 20:03:02 +0530
Subject: [PATCH] lavc: add DICOM decoder, lavf: add DICOM demuxer

---
 Changelog|   1 +
 libavcodec/Makefile  |   1 +
 libavcodec/allcodecs.c   |   1 +
 libavcodec/avcodec.h |   1 +
 libavcodec/codec_desc.c  |   7 +
 libavcodec/dicom.c   | 189 +++
 libavcodec/version.h |   2 +-
 libavformat/Makefile |   1 +
 libavformat/allformats.c |   1 +
 libavformat/dicom.h  | 108 ++
 libavformat/dicomdec.c   | 594 
 libavformat/dicomdict.c  | 716 +++
 libavformat/version.h|   2 +-
 13 files changed, 1622 insertions(+), 2 deletions(-)
 create mode 100644 libavcodec/dicom.c
 create mode 100644 libavformat/dicom.h
 create mode 100644 libavformat/dicomdec.c
 create mode 100644 libavformat/dicomdict.c

diff --git a/Changelog b/Changelog
index c1f1237770..e04c3aa5f6 100644
--- a/Changelog
+++ b/Changelog
@@ -4,6 +4,7 @@ releases are sorted from youngest to oldest.
 version :
 - Intel QSV-accelerated MJPEG decoding
 - Intel QSV-accelerated VP9 decoding
+- DICOM decoder and demxer
 
 version 4.2:
 - tpad filter
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index e49188357b..799da8aef7 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -263,6 +263,7 @@ OBJS-$(CONFIG_DCA_DECODER) += dcadec.o dca.o dcadata.o dcahuff.o \
 OBJS-$(CONFIG_DCA_ENCODER) += dcaenc.o dca.o dcadata.o dcahuff.o \
   dcaadpcm.o
 OBJS-$(CONFIG_DDS_DECODER) += dds.o
+OBJS-$(CONFIG_DICOM_DECODER)   += dicom.o
 OBJS-$(CONFIG_DIRAC_DECODER)   += diracdec.o dirac.o diracdsp.o diractab.o \
   dirac_arith.o dirac_dwt.o dirac_vlc.o
 OBJS-$(CONFIG_DFA_DECODER) += dfa.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index 22985325e0..02a1afa7e8 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -83,6 +83,7 @@ extern AVCodec ff_cscd_decoder;
 extern AVCodec ff_cyuv_decoder;
 extern AVCodec ff_dds_decoder;
 extern AVCodec ff_dfa_decoder;
+extern AVCodec ff_dicom_decoder;
 extern AVCodec ff_dirac_decoder;
 extern AVCodec ff_dnxhd_encoder;
 extern AVCodec ff_dnxhd_decoder;
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index d234271c5b..756e168c75 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -410,6 +410,7 @@ enum AVCodecID {
 AV_CODEC_ID_SCREENPRESSO,
 AV_CODEC_ID_RSCC,
 AV_CODEC_ID_AVS2,
+AV_CODEC_ID_DICOM,
 
 AV_CODEC_ID_Y41P = 0x8000,
 AV_CODEC_ID_AVRP,
diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
index 4d033c20ff..ae9abdb2ba 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -1403,6 +1403,13 @@ static const AVCodecDescriptor codec_descriptors[] = {
 .long_name = NULL_IF_CONFIG_SMALL("AVS2-P2/IEEE1857.4"),
 .props = AV_CODEC_PROP_LOSSY,
 },
+{
+.id= AV_CODEC_ID_DICOM,
+.type  = AVMEDIA_TYPE_VIDEO,
+.name  = "dicom",
+.long_name = NULL_IF_CONFIG_SMALL("DICOM (Digital Imaging and Communications in Medicine)"),
+.props = AV_CODEC_PROP_LOSSY | AV_CODEC_PROP_LOSSLESS,
+},
 {
 .id= AV_CODEC_ID_Y41P,
 .type  = AVMEDIA_TYPE_VIDEO,
diff --git a/libavcodec/dicom.c b/libavcodec/dicom.c
new file mode 100644
index 00..eaa378d944
--- /dev/null
+++ b/libavcodec/dicom.c
@@ -0,0 +1,189 @@
+/*
+ * DICOM decoder
+ * Copyright (c) 2019 Shivam Goyal
+ *
+ * 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 

[FFmpeg-devel] [REQUEST] avcodec/scpr: revert d70276921348

2019-08-20 Thread Paul B Mahol
Hi,

I kindly ask that following commit: d702769213487923c0fb0abe4b61f4d9ebddb88b
is reverted as it does contradicts with reference decoder.

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

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

Re: [FFmpeg-devel] [PATCH v1] lavf/dump: dump the vbv_delay with N/A instead of 18446744073709551615

2019-08-20 Thread Michael Niedermayer
On Sun, Aug 18, 2019 at 10:31:20PM +0800, lance.lmw...@gmail.com wrote:
> From: Limin Wang 
> 
> Signed-off-by: Limin Wang 
> ---
>  libavformat/dump.c | 11 +++
>  1 file changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/libavformat/dump.c b/libavformat/dump.c
> index a3791a3..56814ff 100644
> --- a/libavformat/dump.c
> +++ b/libavformat/dump.c
> @@ -321,13 +321,16 @@ static void dump_cpb(void *ctx, AVPacketSideData *sd)
>  
>  av_log(ctx, AV_LOG_INFO,
>  #if FF_API_UNSANITIZED_BITRATES
> -   "bitrate max/min/avg: %d/%d/%d buffer size: %d vbv_delay: 
> %"PRIu64,
> +   "bitrate max/min/avg: %d/%d/%d buffer size: %d ",
>  #else
> -   "bitrate max/min/avg: %"PRId64"/%"PRId64"/%"PRId64" buffer size: 
> %d vbv_delay: %"PRIu64,
> +   "bitrate max/min/avg: %"PRId64"/%"PRId64"/%"PRId64" buffer size: 
> %d ",
>  #endif
> cpb->max_bitrate, cpb->min_bitrate, cpb->avg_bitrate,
> -   cpb->buffer_size,
> -   cpb->vbv_delay);
> +   cpb->buffer_size);
> +if (cpb->vbv_delay == UINT64_MAX)
> +av_log(ctx, AV_LOG_INFO, "vbv_delay: N/A");
> +else
> +av_log(ctx, AV_LOG_INFO, "vbv_delay: %"PRIu64"", cpb->vbv_delay);
>  }

LGTM

thx

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

Modern terrorism, a quick summary: Need oil, start war with country that
has oil, kill hundread thousand in war. Let country fall into chaos,
be surprised about raise of fundamantalists. Drop more bombs, kill more
people, be surprised about them taking revenge and drop even more bombs
and strip your own citizens of their rights and freedoms. to be continued


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

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

Re: [FFmpeg-devel] [PATCH 2/3] avcodec/alsdec: Fix integer overflow in decode_var_block_data()

2019-08-20 Thread Michael Niedermayer
On Mon, Aug 19, 2019 at 07:41:56AM +0200, Thilo Borgmann wrote:
> Am 19.08.19 um 01:30 schrieb Michael Niedermayer:
> > Fixes: signed integer overflow: 1927975249 - -514719744 cannot be 
> > represented in type 'int'
> > Fixes: 
> > 16413/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ALS_fuzzer-5651206856245248
> > 
> > Found-by: continuous fuzzing process 
> > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> > Signed-off-by: Michael Niedermayer 
> > ---
> >  libavcodec/alsdec.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/libavcodec/alsdec.c b/libavcodec/alsdec.c
> > index 425cf73be9..4794556aad 100644
> > --- a/libavcodec/alsdec.c
> > +++ b/libavcodec/alsdec.c
> > @@ -953,7 +953,7 @@ static int decode_var_block_data(ALSDecContext *ctx, 
> > ALSBlockData *bd)
> >  
> >  // reconstruct difference signal for prediction (joint-stereo)
> >  if (bd->js_blocks && bd->raw_other) {
> > -int32_t *left, *right;
> > +uint32_t *left, *right;
> >  
> >  if (bd->raw_other > raw_samples) {  // D = R - L
> >  left  = raw_samples;
> > 
> 
> LGTM

will apply

thx

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

If you drop bombs on a foreign country and kill a hundred thousand
innocent people, expect your government to call the consequence
"unprovoked inhuman terrorist attacks" and use it to justify dropping
more bombs and killing more people. The technology changed, the idea is old.


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

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

[FFmpeg-devel] [PATCH] lavf: ad DICOM demuxer, lavc: add DICOM decoder

2019-08-20 Thread Shivam
The patch contains support for Dicom files. I have added the below 
features:-
Uncompressed DICOM files using any of the Implicit and Explicit VR 
formats are supported.

Multiframe files are also supported.
To extract the metadata or info about the procedure, I have added an 
option "-metadata." (The tags present in Dicom dictionary would be demuxed).


I have also uploaded DICOM samples here.
https://1drv.ms/u/s!AosJ9_SrP4Tsh2WoPfQAI8cSsqUs?e=ZMd5fR

Please review,

Thank you,
Shivam Goyal

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

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

Re: [FFmpeg-devel] [REQUEST] avcodec/scpr: revert d70276921348

2019-08-20 Thread Carl Eugen Hoyos
Am Di., 20. Aug. 2019 um 14:48 Uhr schrieb Paul B Mahol :

> I kindly ask that following commit: d702769213487923c0fb0abe4b61f4d9ebddb88b

I still believe what the patch does is a very good idea and a revert would
hurt FFmpeg.

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

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

Re: [FFmpeg-devel] [PATCH v2] hevc_mp4toannexb: Insert correct parameter sets before IRAP

2019-08-20 Thread Andriy Gelman
Andreas, 

On Tue, 20. Aug 07:54, Andreas Rheinhardt wrote:
> Hello,
> 
> I have not looked at the *PS and the SEI stuff yet, but here is
> already my review of the general code.
> 
> Andriy Gelman:
> > From: Andriy Gelman 
> > 
> > Fixes #7799
> > 
> > Currently, the mp4toannexb filter always inserts the same extradata at
> > the start of the first IRAP unit. As in ticket #7799, this can lead to
> > decoding errors if modified parameter sets are signalled in-band.
> > 
> > This commit keeps track of the vps/sps/pps parameter sets during the
> > conversion. The correct combination is inserted at the start of the
> > first IRAP unit instead of the original extradata. SEI prefix nal units
> > are also cached and inserted after the parameter sets.
> > 
> > This commit also makes an update to the hevc-bsf-mp4toannexb fate
> > test since the result before this patch contained duplicate vps/sps/pps
> > parameter sets in-band.
> > ---
> >  libavcodec/hevc_mp4toannexb_bsf.c | 475 +++---
> >  tests/fate/hevc.mak   |   2 +-
> >  2 files changed, 437 insertions(+), 40 deletions(-)
> > 
> > diff --git a/libavcodec/hevc_mp4toannexb_bsf.c 
> > b/libavcodec/hevc_mp4toannexb_bsf.c
> > index 09bce5b34c..7f3d68252d 100644
> > --- a/libavcodec/hevc_mp4toannexb_bsf.c
> > +++ b/libavcodec/hevc_mp4toannexb_bsf.c
> > @@ -28,19 +28,212 @@
> >  #include "bsf.h"
> >  #include "bytestream.h"
> >  #include "hevc.h"
> > -
> > -#define MIN_HEVCC_LENGTH 23
> > +#include "h2645_parse.h"
> > +#include "hevc_ps.h"
> > +#include "golomb.h"
> > +
> > +#define MIN_HEVCC_LENGTH23
> > +#define PROFILE_WITHOUT_IDC_BITS88
> > +#define IS_IRAP(s)  ((s)->type >= 16 && (s)->type <= 23)
> > +#define IS_PARAMSET(s)  ((s)->type >= 32 && (s)->type <= 34)
> > +
> > +#define WRITE_NAL(pkt, prev_size, in_buffer) do {  
> >   \
> > +AV_WB32((pkt)->data + (prev_size), 1); 
> >   \
> > +prev_size += 4;
> >   \
> > +memcpy((pkt)->data + (prev_size), (in_buffer)->data, 
> > (in_buffer)->size); \
> > +prev_size += (in_buffer)->size;
> >   \
> > +} while (0)
> > +
> > +typedef struct Param {
> > +AVBufferRef *raw_data; /*store a copy of the raw data to construct 
> > extradata*/
> > +int ref;  /*stores the ref of the higher level parameter set*/
> > +} Param;
> > +
> > +/*modified version of HEVCParamSets to store bytestream and reference to 
> > previous level*/
> > +typedef struct ParamSets {
> > +Param vps_list[HEVC_MAX_VPS_COUNT];
> > +Param sps_list[HEVC_MAX_SPS_COUNT];
> > +Param pps_list[HEVC_MAX_PPS_COUNT];
> > +
> > +AVBufferRef *sei_prefix;
> > +} ParamSets;
> >  
> >  typedef struct HEVCBSFContext {
> > -uint8_t  length_size;
> > -int  extradata_parsed;
> > +uint8_t  length_size;
> > +int  extradata_parsed;
> > +ParamSetsps; /*make own of version of HEVCParamSets store copy of 
> > the bytestream*/
> >  } HEVCBSFContext;
> >  
> > +
> > +static int parse_vps(AVBSFContext* ctx, H2645NAL *nal)
> > +{
> > +int vps_id = 0;
> > +Param *param_ptr;
> > +
> > +HEVCBSFContext *s = ctx->priv_data;
> > +ParamSets *ps = >ps;
> > +
> > +GetBitContext *gb = >gb;
> > +int nal_size  = nal->raw_size;
> > +
> > +vps_id = get_bits(gb, 4);
> > +if (vps_id >= HEVC_MAX_VPS_COUNT) {
> > +av_log(ctx, AV_LOG_ERROR, "VPS id out of range: %d\n", vps_id);
> > +return AVERROR_INVALIDDATA;
> > +}
> > +
> > +param_ptr = >vps_list[vps_id];
> > +/*init raw_data if needed*/
> > +if (!param_ptr->raw_data) {
> > +param_ptr->raw_data = av_buffer_allocz(nal_size);
> > +param_ptr->ref  = 0;
> > +if (!param_ptr->raw_data)
> > +return AVERROR(ENOMEM);
> > +}
> > +
> > +if (param_ptr->raw_data && param_ptr->raw_data->size == nal_size &&
> > +!memcmp(param_ptr->raw_data->data, nal->raw_data, nal_size)) {
> > +av_log(ctx, AV_LOG_DEBUG, "Parsed VPS id: %d. Copy already exists 
> > in parameter set\n", vps_id);
> > +} else {
> > +AVBufferRef *vps_buf = av_buffer_allocz(nal_size);
> > +if (!vps_buf)
> > +return AVERROR(ENOMEM);
> > +
> > +/*copy raw data into vps_buf buffer and replace existing copy in 
> > ps*/
> > +memcpy(vps_buf->data, nal->raw_data, nal_size);
> > +av_buffer_unref(_ptr->raw_data);
> > +param_ptr->raw_data = vps_buf;
> > +}
> > +return 0;
> > +}
> > +
> > +static int parse_sps(AVBSFContext *ctx, H2645NAL *nal)
> > +{
> > +int sps_id, vps_ref, max_sub_layers_minus1;
> > +int i;
> > +Param *param_ptr;
> > +
> > +HEVCBSFContext *s = (HEVCBSFContext*)ctx->priv_data;
> > +ParamSets *ps = >ps;
> > +
> > +GetBitContext *gb = >gb;
> > +int 

[FFmpeg-devel] [PATCH v15 12/15] lavc/mjpegdec: Skip unknown APPx marker on bayer images

2019-08-20 Thread Nick Renieris
Samples:
- Embedded JPEG images in the DNG images here:
  https://www.photographyblog.com/previews/pentax_k1_photos

Signed-off-by: Nick Renieris 
---
 libavcodec/mjpegdec.c | 11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index 0a920a7144..1f2fabe2df 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -1807,8 +1807,15 @@ static int mjpeg_decode_app(MJpegDecodeContext *s)
 int len, id, i;
 
 len = get_bits(>gb, 16);
-if (len < 6)
-return AVERROR_INVALIDDATA;
+if (len < 6) {
+if (s->bayer) {
+// Pentax K-1 (digital camera) JPEG images embedded in DNG images 
contain unknown APP0 markers
+av_log(s->avctx, AV_LOG_WARNING, "skipping APPx (len=%"PRId32") 
for bayer-encoded image\n", len);
+skip_bits(>gb, len);
+return 0;
+} else
+return AVERROR_INVALIDDATA;
+}
 if (8 * len > get_bits_left(>gb))
 return AVERROR_INVALIDDATA;
 
-- 
2.17.1

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

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

[FFmpeg-devel] [PATCH v15 14/15] lavc/tiff: Default-initialize WhiteLevel DNG tag value

2019-08-20 Thread Nick Renieris
Initialized to `(2 ^ BitsPerSample) - 1` as per the DNG Specification.

Also make sure that `BlackLevel < WhiteLevel`.

This fixes decoding for "X7 CinemaDNG" samples here:
- https://www.dji.com/gr/zenmuse-x7/info#downloads

Signed-off-by: Nick Renieris 
---
 libavcodec/tiff.c | 22 +++---
 1 file changed, 19 insertions(+), 3 deletions(-)

diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index df2554be86..377662c897 100644
--- a/libavcodec/tiff.c
+++ b/libavcodec/tiff.c
@@ -1775,6 +1775,7 @@ static int decode_frame(AVCodecContext *avctx,
 GetByteContext stripsizes;
 GetByteContext stripdata;
 int retry_for_subifd, retry_for_page;
+int is_dng;
 
 bytestream2_init(>gb, avpkt->data, avpkt->size);
 
@@ -1843,6 +1844,10 @@ again:
 goto again;
 }
 
+/* At this point we've decided on which (Sub)IFD to process */
+
+is_dng = (s->tiff_type == TIFF_TYPE_DNG || s->tiff_type == 
TIFF_TYPE_CINEMADNG);
+
 for (i = 0; igeotag_count; i++) {
 const char *keyname = get_geokey_name(s->geotags[i].key);
 if (!keyname) {
@@ -1860,10 +1865,22 @@ again:
 }
 }
 
+if (is_dng) {
+if (s->white_level == 0)
+s->white_level = (1 << s->bpp) - 1; /* Default value as per the 
spec */
+
+if (s->white_level <= s->black_level) {
+av_log(avctx, AV_LOG_ERROR, "BlackLevel (%"PRId32") must be less 
than WhiteLevel (%"PRId32")\n",
+s->black_level, s->white_level);
+return AVERROR_INVALIDDATA;
+}
+}
+
 if (!s->is_tiled && !s->strippos && !s->stripoff) {
 av_log(avctx, AV_LOG_ERROR, "Image data is missing\n");
 return AVERROR_INVALIDDATA;
 }
+
 /* now we have the data and may start decoding */
 if ((ret = init_image(s, )) < 0)
 return ret;
@@ -1895,7 +1912,7 @@ again:
 
 /* Handle DNG images with JPEG-compressed tiles */
 
-if ((s->tiff_type == TIFF_TYPE_DNG || s->tiff_type == TIFF_TYPE_CINEMADNG) 
&& s->is_tiled) {
+if (is_dng && s->is_tiled) {
 if (!s->is_jpeg) {
 avpriv_report_missing_feature(avctx, "DNG uncompressed tiled 
images");
 return AVERROR_PATCHWELCOME;
@@ -2053,8 +2070,7 @@ again:
 FFSWAP(int,  p->linesize[0], p->linesize[1]);
 }
 
-if (s->is_bayer && s->white_level && s->bpp == 16 &&
-!(s->tiff_type == TIFF_TYPE_DNG || s->tiff_type == 
TIFF_TYPE_CINEMADNG)) {
+if (s->is_bayer && s->white_level && s->bpp == 16 && !is_dng) {
 uint16_t *dst = (uint16_t *)p->data[0];
 for (i = 0; i < s->height; i++) {
 for (j = 0; j < s->width; j++)
-- 
2.17.1

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

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

[FFmpeg-devel] [PATCH v15 08/15] lavc/tiff: Force DNG pixel data endianness on an edge case

2019-08-20 Thread Nick Renieris
Signed-off-by: Nick Renieris 
---
 libavcodec/tiff.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index 1ca9a59dbf..d9750891d4 100644
--- a/libavcodec/tiff.c
+++ b/libavcodec/tiff.c
@@ -1038,6 +1038,18 @@ static int init_image(TiffContext *s, ThreadFrame *frame)
AV_RL32(s->pattern));
 return AVERROR_PATCHWELCOME;
 }
+/* Force endianness as mentioned in 'DNG Specification: Chapter 3: 
BitsPerSample'
+NOTE: The spec actually specifies big-endian, not sure why we need 
little-endian,
+  but such images don't work otherwise. */
+if ((s->tiff_type == TIFF_TYPE_DNG || s->tiff_type == 
TIFF_TYPE_CINEMADNG)
+&& (s->bpp != 8 && s->bpp != 16 && s->bpp != 32)) {
+switch (s->avctx->pix_fmt) {
+case AV_PIX_FMT_BAYER_RGGB16BE: s->avctx->pix_fmt = 
AV_PIX_FMT_BAYER_RGGB16LE; break;
+case AV_PIX_FMT_BAYER_BGGR16BE: s->avctx->pix_fmt = 
AV_PIX_FMT_BAYER_BGGR16LE; break;
+case AV_PIX_FMT_BAYER_GBRG16BE: s->avctx->pix_fmt = 
AV_PIX_FMT_BAYER_GBRG16LE; break;
+case AV_PIX_FMT_BAYER_GRBG16BE: s->avctx->pix_fmt = 
AV_PIX_FMT_BAYER_GRBG16LE; break;
+}
+}
 break;
 case 10161:
 switch (AV_RL32(s->pattern)) {
-- 
2.17.1

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

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

[FFmpeg-devel] [PATCH v15 15/15] lavc/tiff: Enable decoding of LinearRaw images

2019-08-20 Thread Nick Renieris
"LinearRaw" is a value that the PhotometricInterpretation tag can be set
to on DNG images that contain color information for all channels instead
of being bayer-encoded ("CFA" value).

The DNG decoder is complete enough that we can enable this now.

Sample:
- http://www.rawsamples.ch/raws/nikon/SCANNER_NIKON_LS5000.DNG

Signed-off-by: Nick Renieris 
---
 libavcodec/tiff.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index 377662c897..3166a3e5c8 100644
--- a/libavcodec/tiff.c
+++ b/libavcodec/tiff.c
@@ -1495,6 +1495,7 @@ static int tiff_decode_tag(TiffContext *s, AVFrame *frame)
 case TIFF_PHOTOMETRIC_SEPARATED:
 case TIFF_PHOTOMETRIC_YCBCR:
 case TIFF_PHOTOMETRIC_CFA:
+case TIFF_PHOTOMETRIC_LINEAR_RAW: // Used by DNG images
 s->photometric = value;
 break;
 case TIFF_PHOTOMETRIC_ALPHA_MASK:
@@ -1503,7 +1504,6 @@ static int tiff_decode_tag(TiffContext *s, AVFrame *frame)
 case TIFF_PHOTOMETRIC_ITU_LAB:
 case TIFF_PHOTOMETRIC_LOG_L:
 case TIFF_PHOTOMETRIC_LOG_LUV:
-case TIFF_PHOTOMETRIC_LINEAR_RAW:
 avpriv_report_missing_feature(s->avctx,
   "PhotometricInterpretation 0x%04X",
   value);
-- 
2.17.1

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

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

Re: [FFmpeg-devel] [PATCH 1/3] avcodec/alsdec: Limit maximum channels to 64

2019-08-20 Thread Michael Niedermayer
On Tue, Aug 20, 2019 at 09:12:36AM +0200, Thilo Borgmann wrote:
> Am 19.08.19 um 23:22 schrieb Michael Niedermayer:
> > On Mon, Aug 19, 2019 at 05:09:37PM +0200, Thilo Borgmann wrote:
> >> Am 19.08.19 um 14:27 schrieb Michael Niedermayer:
> >>> On Mon, Aug 19, 2019 at 07:41:43AM +0200, Thilo Borgmann wrote:
>  Am 19.08.19 um 01:30 schrieb Michael Niedermayer:
> > There seems to be no limit in the specification and upto 64k could be 
> > stored
> > 64 is chooses as limit as thats also used for AAC and is what a int64 
> > mask
> > can handle
> >
> > An alternative to this patch would be a max_channels variable
> 
>  There's a conformance file containing 512 channels, that should be the 
>  default max value.
> >>>
> >>> will apply with that value later
> >>
> >> Decoding of that is already stopped via FF_SANE_NB_CHANNELS in 
> >> lavc/internal.h.
> >> That is currently set to 256U. I guess pushing that to 512U might already 
> >> be enough without any change to single decoders?
> > 
> > the problem of out of memory is that the als decoder allocates some pretty
> > large things per channel. A check on channels needs to happen before
> > this.
> > The existing checks didnt achieve that.
> > 
> > I can of course post a patchset that uses FF_SANE_NB_CHANNELS in als and
> > bump it to the next number if people prefer this ?
> > 
> > Note though that increasing FF_SANE_NB_CHANNELS may also increase timeouts
> > in other decoders.
> 
> I see the problem.
> However, right now alsdec is fine with any number of channels and the CLI 
> prevents decoding anything above FF_SANE_NB_CHANNELS (checks are in 
> lavc/decoding.c and lavc/utils.c; this would also stop any FATE test on 512 
> channels file).
> 
> So having alsdec check for a value higher than FF_SANE_NB_CHANNELS (like 512) 
> would have no effect for CLI users, right?

yes, just wanted to make sure the side effect of a 512 FF_SANE_NB_CHANNELS is
understood

will post the patches

thx

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The real ebay dictionary, page 2
"100% positive feedback" - "All either got their money back or didnt complain"
"Best seller ever, very honest" - "Seller refunded buyer after failed scam"


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

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

[FFmpeg-devel] [PATCH v15 01/15] lavc/mjpegdec: Decode Huffman-coded lossless JPEGs embedded in DNGs

2019-08-20 Thread Nick Renieris
Main image data in DNGs is usually comprised of tiles, each of which is a 
Huffman-encoded lossless JPEG.

Tested for ljpeg regressions with:
`ffmpeg -f lavfi -i testsrc=d=1 -vcodec ljpeg test.avi`
`ffmpeg test.avi out.avi`
The modified code in ljpeg_decode_rgb_scan runs without issues.

Signed-off-by: Nick Renieris 
---
 libavcodec/mjpegdec.c | 52 +--
 libavcodec/mjpegdec.h |  1 +
 2 files changed, 46 insertions(+), 7 deletions(-)

diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index a65bc8df15..6391107f78 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -412,6 +412,14 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
 return AVERROR_PATCHWELCOME;
 }
 
+/* Lossless JPEGs encoded in DNGs are commonly bayer-encoded. They contain 
2
+   interleaved components and the width stored in their SOF3 markers is the
+   width of each one.  We only output a single component, therefore we need
+   to adjust the output image width. */
+if (s->lossless == 1 && nb_components == 2) {
+s->bayer = 1;
+width *= 2;
+}
 
 /* if different size, realloc/alloc picture */
 if (width != s->width || height != s->height || bits != s->bits ||
@@ -488,6 +496,9 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
 }
 
 switch (pix_fmt_id) {
+case 0x: /* for bayer-encoded huffman lossless JPEGs embedded 
in DNGs */
+s->avctx->pix_fmt = AV_PIX_FMT_GRAY16LE;
+break;
 case 0x1100:
 if (s->rgb)
 s->avctx->pix_fmt = s->bits <= 9 ? AV_PIX_FMT_BGR24 : 
AV_PIX_FMT_BGR48;
@@ -1041,17 +1052,20 @@ static int handle_rstn(MJpegDecodeContext *s, int 
nb_components)
 return reset;
 }
 
+/* Handles 1 to 4 components */
 static int ljpeg_decode_rgb_scan(MJpegDecodeContext *s, int nb_components, int 
predictor, int point_transform)
 {
 int i, mb_x, mb_y;
+unsigned width;
 uint16_t (*buffer)[4];
 int left[4], top[4], topleft[4];
 const int linesize = s->linesize[0];
 const int mask = ((1 << s->bits) - 1) << point_transform;
 int resync_mb_y = 0;
 int resync_mb_x = 0;
+int vpred[6];
 
-if (s->nb_components != 3 && s->nb_components != 4)
+if (s->nb_components <= 0 || s->nb_components > 4)
 return AVERROR_INVALIDDATA;
 if (s->v_max != 1 || s->h_max != 1 || !s->lossless)
 return AVERROR_INVALIDDATA;
@@ -1059,8 +1073,15 @@ static int ljpeg_decode_rgb_scan(MJpegDecodeContext *s, 
int nb_components, int p
 
 s->restart_count = s->restart_interval;
 
-av_fast_malloc(>ljpeg_buffer, >ljpeg_buffer_size,
-   (unsigned)s->mb_width * 4 * sizeof(s->ljpeg_buffer[0][0]));
+if (s->restart_interval == 0)
+s->restart_interval = INT_MAX;
+
+if (s->bayer)
+width = s->mb_width / nb_components; /* Interleaved, width stored is 
the total so need to divide */
+else
+width = s->mb_width;
+
+av_fast_malloc(>ljpeg_buffer, >ljpeg_buffer_size, width * 4 * 
sizeof(s->ljpeg_buffer[0][0]));
 if (!s->ljpeg_buffer)
 return AVERROR(ENOMEM);
 
@@ -1078,7 +1099,12 @@ static int ljpeg_decode_rgb_scan(MJpegDecodeContext *s, 
int nb_components, int p
 for (i = 0; i < 4; i++)
 top[i] = left[i] = topleft[i] = buffer[0][i];
 
-for (mb_x = 0; mb_x < s->mb_width; mb_x++) {
+if ((mb_y * s->width) % s->restart_interval == 0) {
+for (i = 0; i < 6; i++)
+vpred[i] = 1 << (s->bits-1);
+}
+
+for (mb_x = 0; mb_x < width; mb_x++) {
 int modified_predictor = predictor;
 
 if (get_bits_left(>gb) < 1) {
@@ -1102,12 +1128,19 @@ static int ljpeg_decode_rgb_scan(MJpegDecodeContext *s, 
int nb_components, int p
 topleft[i] = top[i];
 top[i] = buffer[mb_x][i];
 
-PREDICT(pred, topleft[i], top[i], left[i], modified_predictor);
-
 dc = mjpeg_decode_dc(s, s->dc_index[i]);
 if(dc == 0xF)
 return -1;
 
+if (!s->bayer || mb_x) {
+pred = left[i];
+} else { /* This path runs only for the first line in bayer 
images */
+vpred[i] += dc;
+pred = vpred[i] - dc;
+}
+
+PREDICT(pred, topleft[i], top[i], pred, modified_predictor);
+
 left[i] = buffer[mb_x][i] =
 mask & (pred + (unsigned)(dc * (1 << point_transform)));
 }
@@ -1151,6 +1184,11 @@ static int ljpeg_decode_rgb_scan(MJpegDecodeContext *s, 
int nb_components, int p
 ptr[3*mb_x + 0] = buffer[mb_x][1] + ptr[3*mb_x + 1];
 ptr[3*mb_x + 2] = buffer[mb_x][2] + ptr[3*mb_x + 1];
 }
+} else if (s->bayer && nb_components == 2) {
+for (mb_x = 0; mb_x < width; mb_x++) {
+  

[FFmpeg-devel] [PATCH v15 03/15] lavc/tiff: Convert DNGs to sRGB color space

2019-08-20 Thread Nick Renieris
Signed-off-by: Nick Renieris 
---
 libavcodec/tiff.c | 34 +++---
 1 file changed, 23 insertions(+), 11 deletions(-)

diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index 4c6b835afe..a2102f32b5 100644
--- a/libavcodec/tiff.c
+++ b/libavcodec/tiff.c
@@ -731,14 +731,23 @@ static int tiff_unpack_strip(TiffContext *s, AVFrame *p, 
uint8_t *dst, int strid
 return 0;
 }
 
+static float av_always_inline linear_to_srgb(float value) {
+if (value <= 0.0031308)
+return value * 12.92;
+else
+return pow(value * 1.055, 1.0 / 2.4) - 0.055;
+}
+
 /**
- * Map stored raw sensor values into linear reference values.
- * See: DNG Specification - Chapter 5
+ * Map stored raw sensor values into linear reference values (see: DNG 
Specification - Chapter 5)
+ * Then convert to sRGB color space.
  */
-static uint16_t av_always_inline dng_raw_to_linear16(uint16_t value,
-const uint16_t *lut,
-uint16_t black_level,
-float scale_factor) {
+static uint16_t av_always_inline dng_process_color16(uint16_t value,
+ const uint16_t *lut,
+ uint16_t black_level,
+ float scale_factor) {
+float value_norm;
+
 // Lookup table lookup
 if (lut)
 value = lut[value];
@@ -747,16 +756,19 @@ static uint16_t av_always_inline 
dng_raw_to_linear16(uint16_t value,
 value = av_clip_uint16_c((unsigned)value - black_level);
 
 // Color scaling
-value = av_clip_uint16_c((unsigned)(((float)value * scale_factor) * 
0x));
+value_norm = (float)value * scale_factor;
+
+// Color space conversion (sRGB)
+value = av_clip_uint16_c((uint16_t)(linear_to_srgb(value_norm) * 0x));
 
 return value;
 }
 
-static uint16_t av_always_inline dng_raw_to_linear8(uint16_t value,
+static uint16_t av_always_inline dng_process_color8(uint16_t value,
 const uint16_t *lut,
 uint16_t black_level,
 float scale_factor) {
-return dng_raw_to_linear16(value, lut, black_level, scale_factor) >> 8;
+return dng_process_color16(value, lut, black_level, scale_factor) >> 8;
 }
 
 static void dng_blit(TiffContext *s, uint8_t *dst, int dst_stride,
@@ -774,7 +786,7 @@ static void dng_blit(TiffContext *s, uint8_t *dst, int 
dst_stride,
 uint16_t *src_u16 = (uint16_t *)src;
 
 for (col = 0; col < width; col++)
-*dst_u16++ = dng_raw_to_linear16(*src_u16++, s->dng_lut, 
s->black_level, scale_factor);
+*dst_u16++ = dng_process_color16(*src_u16++, s->dng_lut, 
s->black_level, scale_factor);
 
 dst += dst_stride * sizeof(uint16_t);
 src += src_stride * sizeof(uint16_t);
@@ -782,7 +794,7 @@ static void dng_blit(TiffContext *s, uint8_t *dst, int 
dst_stride,
 } else {
 for (line = 0; line < height; line++) {
 for (col = 0; col < width; col++)
-*dst++ = dng_raw_to_linear8(*src++, s->dng_lut, 
s->black_level, scale_factor);
+*dst++ = dng_process_color8(*src++, s->dng_lut, 
s->black_level, scale_factor);
 
 dst += dst_stride;
 src += src_stride;
-- 
2.17.1

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

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

[FFmpeg-devel] [PATCH v15 13/15] lavc/tiff: Support DNGs with striped (non-tiled) JPEGs images

2019-08-20 Thread Nick Renieris
DNG samples here can now be decoded:
- https://www.photographyblog.com/previews/pentax_k1_photos

Signed-off-by: Nick Renieris 
---
 libavcodec/tiff.c | 61 ---
 1 file changed, 37 insertions(+), 24 deletions(-)

diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index d5efd05d7c..df2554be86 100644
--- a/libavcodec/tiff.c
+++ b/libavcodec/tiff.c
@@ -551,6 +551,8 @@ static int tiff_unpack_fax(TiffContext *s, uint8_t *dst, 
int stride,
 return ret;
 }
 
+static int dng_decode_strip(AVCodecContext *avctx, AVFrame *frame);
+
 static int tiff_unpack_strip(TiffContext *s, AVFrame *p, uint8_t *dst, int 
stride,
  const uint8_t *src, int size, int strip_start, 
int lines)
 {
@@ -666,6 +668,17 @@ static int tiff_unpack_strip(TiffContext *s, AVFrame *p, 
uint8_t *dst, int strid
 
 is_dng = (s->tiff_type == TIFF_TYPE_DNG || s->tiff_type == 
TIFF_TYPE_CINEMADNG);
 
+/* Decode JPEG-encoded DNGs with strips */
+if (s->compr == TIFF_NEWJPEG && is_dng) {
+if (s->strips > 1) {
+av_log(s->avctx, AV_LOG_ERROR, "More than one DNG JPEG strips 
unsupported\n");
+return AVERROR_PATCHWELCOME;
+}
+if ((ret = dng_decode_strip(s->avctx, p)) < 0)
+return ret;
+return 0;
+}
+
 for (line = 0; line < lines; line++) {
 if (src - ssrc > size) {
 av_log(s->avctx, AV_LOG_ERROR, "Source data overread\n");
@@ -860,8 +873,8 @@ static void dng_blit(TiffContext *s, uint8_t *dst, int 
dst_stride,
 }
 }
 
-static int dng_decode_jpeg_tile(AVCodecContext *avctx, AVFrame *frame,
-int tile_byte_count, int x, int y, int w, int 
h)
+static int dng_decode_jpeg(AVCodecContext *avctx, AVFrame *frame,
+   int tile_byte_count, int dst_x, int dst_y, int w, 
int h)
 {
 TiffContext *s = avctx->priv_data;
 AVPacket jpkt;
@@ -913,7 +926,7 @@ static int dng_decode_jpeg_tile(AVCodecContext *avctx, 
AVFrame *frame,
 return AVERROR_PATCHWELCOME;
 }
 
-dst_offset = x + frame->linesize[0] * y / pixel_size;
+dst_offset = dst_x + frame->linesize[0] * dst_y / pixel_size;
 dst_data = frame->data[0] + dst_offset * pixel_size;
 src_data = s->jpgframe->data[0];
 
@@ -932,7 +945,7 @@ static int dng_decode_jpeg_tile(AVCodecContext *avctx, 
AVFrame *frame,
 return 0;
 }
 
-static int dng_decode_tiles(AVCodecContext *avctx, AVFrame *frame)
+static int dng_decode_tiles(AVCodecContext *avctx, AVFrame *frame, AVPacket 
*avpkt)
 {
 TiffContext *s = avctx->priv_data;
 int tile_idx;
@@ -945,6 +958,12 @@ static int dng_decode_tiles(AVCodecContext *avctx, AVFrame 
*frame)
 int pos_x = 0, pos_y = 0;
 int ret;
 
+s->jpgframe->width  = s->tile_width;
+s->jpgframe->height = s->tile_length;
+
+s->avctx_mjpeg->width = s->tile_width;
+s->avctx_mjpeg->height = s->tile_length;
+
 has_width_leftover = (s->width % s->tile_width != 0);
 has_height_leftover = (s->height % s->tile_length != 0);
 
@@ -981,7 +1000,7 @@ static int dng_decode_tiles(AVCodecContext *avctx, AVFrame 
*frame)
 bytestream2_seek(>gb, tile_offset, SEEK_SET);
 
 /* Decode JPEG tile and copy it in the reference frame */
-ret = dng_decode_jpeg_tile(avctx, frame, tile_byte_count, pos_x, 
pos_y, tile_width, tile_length);
+ret = dng_decode_jpeg(avctx, frame, tile_byte_count, pos_x, pos_y, 
tile_width, tile_length);
 
 if (ret < 0)
 return ret;
@@ -994,30 +1013,24 @@ static int dng_decode_tiles(AVCodecContext *avctx, 
AVFrame *frame)
 }
 }
 
-return 0;
-}
+/* Frame is ready to be output */
+frame->pict_type = AV_PICTURE_TYPE_I;
+frame->key_frame = 1;
 
-static int dng_decode(AVCodecContext *avctx, AVFrame *frame, AVPacket *avpkt) {
-int ret;
+return avpkt->size;
+}
 
+static int dng_decode_strip(AVCodecContext *avctx, AVFrame *frame)
+{
 TiffContext *s = avctx->priv_data;
 
-s->jpgframe->width  = s->tile_width;
-s->jpgframe->height = s->tile_length;
-
-s->avctx_mjpeg->width = s->tile_width;
-s->avctx_mjpeg->height = s->tile_length;
-
-/* Decode all tiles in a frame */
-ret = dng_decode_tiles(avctx, frame);
-if (ret < 0)
-return ret;
+s->jpgframe->width  = s->width;
+s->jpgframe->height = s->height;
 
-/* Frame is ready to be output */
-frame->pict_type = AV_PICTURE_TYPE_I;
-frame->key_frame = 1;
+s->avctx_mjpeg->width = s->width;
+s->avctx_mjpeg->height = s->height;
 
-return avpkt->size;
+return dng_decode_jpeg(avctx, frame, s->stripsize, 0, 0, s->width, 
s->height);
 }
 
 static int init_image(TiffContext *s, ThreadFrame *frame)
@@ -1890,7 +1903,7 @@ again:
 avpriv_report_missing_feature(avctx, "DNG JPG-compressed tiled 
non-bayer-encoded images");
 return AVERROR_PATCHWELCOME;
 } else {
-if ((ret = 

[FFmpeg-devel] [PATCH v15 05/15] lavc/jpegtables: Handle multiple mappings to the same value

2019-08-20 Thread Nick Renieris
Some JPEGs [1] have incorrect DHT entries that map 2 codes to
the same value.

The second (last) mapping does not ever actually appear in the
code stream, therefore ignoring any mappings after the first one
fixes this.

Without this, an "mjpeg_decode_dc: bad vlc: 0:0" error is thrown.

In all known files, the 2 codes are mapped to symbol 0 so only
that case is checked.

---

[1]: Embedded JPEGs in "X7 RAW" and "X7 CinemaDNG" samples here:
 https://www.dji.com/gr/zenmuse-x7/info#downloads

Signed-off-by: Nick Renieris 
---
 libavcodec/jpegtables.c | 17 ++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/libavcodec/jpegtables.c b/libavcodec/jpegtables.c
index cbe5523cb4..fa5c6f9fc5 100644
--- a/libavcodec/jpegtables.c
+++ b/libavcodec/jpegtables.c
@@ -130,14 +130,25 @@ void ff_mjpeg_build_huffman_codes(uint8_t *huff_size, 
uint16_t *huff_code,
 {
 int i, j, k,nb, code, sym;
 
-code = 0;
+/* Some badly encoded files [1] map 2 different codes to symbol 0.
+   Only the first one is valid, so we zero-initialize this here and
+   make sure we only set it once (the first time) in the loop below.
+
+   [1]: Embedded JPEGs in "X7 RAW" and "X7 CinemaDNG" samples here:
+https://www.dji.com/gr/zenmuse-x7/info#downloads
+ */
+huff_size[0] = 0;
+
 k = 0;
+code = 0;
 for(i=1;i<=16;i++) {
 nb = bits_table[i];
 for(j=0;jhttps://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH 1/2] avcodec/alsdec: Limit maximum channels to 512

2019-08-20 Thread Thilo Borgmann
Am 20.08.19 um 16:52 schrieb Michael Niedermayer:
> There seems to be no limit in the specification and upto 64k could be stored
> 512 is choosen as limit as thats the maximum in a conformance sample
> 
> An alternative to this patch would be a max_channels variable
> 
> Fixes: OOM
> Fixes: 
> 16200/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ALS_fuzzer-5764788793114624
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Suggested-by: Thilo Borgmann 
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/alsdec.c | 5 +
>  1 file changed, 5 insertions(+)

Patch 1 & 2 LGTM.

Will send a patch for FATE soonish after commit.

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

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

Re: [FFmpeg-devel] [REQUEST] avcodec/scpr: revert d70276921348

2019-08-20 Thread Kieran Kunhya
On Tue, 20 Aug 2019 at 14:16, Carl Eugen Hoyos  wrote:

> Am Di., 20. Aug. 2019 um 14:48 Uhr schrieb Paul B Mahol  >:
>
> > I kindly ask that following commit:
> d702769213487923c0fb0abe4b61f4d9ebddb88b
>
> I still believe what the patch does is a very good idea and a revert would
> hurt FFmpeg.
>

We should not turn CFR streams into VFR. This would not be acceptable for
H264 not should it be acceptable for any other codec.

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

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

[FFmpeg-devel] [PATCH v15 10/15] lavc/tiff: Support decoding of DNGs with single-component JPEGs

2019-08-20 Thread Nick Renieris
This enables decoding of DNG images generated by the 'DJI Zenmuse X7'
digital camera
Samples: https://www.dji.com/gr/zenmuse-x7/info#downloads

Signed-off-by: Nick Renieris 
---
 libavcodec/tiff.c | 61 +++
 1 file changed, 51 insertions(+), 10 deletions(-)

diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index 77acf9f838..35234dc05e 100644
--- a/libavcodec/tiff.c
+++ b/libavcodec/tiff.c
@@ -274,7 +274,8 @@ static int add_metadata(int count, int type,
 }
 
 static void av_always_inline dng_blit(TiffContext *s, uint8_t *dst, int 
dst_stride,
-  const uint8_t *src, int src_stride, int 
width, int height, int is_u16);
+  const uint8_t *src, int src_stride, int 
width, int height,
+  int is_single_comp, int is_u16);
 
 static void av_always_inline horizontal_fill(TiffContext *s,
  unsigned int bpp, uint8_t* dst,
@@ -698,6 +699,7 @@ static int tiff_unpack_strip(TiffContext *s, AVFrame *p, 
uint8_t *dst, int strid
  0, // no stride, only 1 line
  width / pixel_size_bytes * pixel_size_bits / s->bpp * 
s->bppcount, // need to account for [1, 16] bpp
  1,
+ 0, // single-component variation is only preset in 
JPEG-encoded DNGs
  is_u16);
 }
 
@@ -795,18 +797,32 @@ static uint16_t av_always_inline 
dng_process_color8(uint16_t value,
 
 static void dng_blit(TiffContext *s, uint8_t *dst, int dst_stride,
  const uint8_t *src, int src_stride,
- int width, int height, int is_u16)
+ int width, int height, int is_single_comp, int is_u16)
 {
 int line, col;
 float scale_factor;
 
 scale_factor = 1.0f / (s->white_level - s->black_level);
 
-if (is_u16) {
-for (line = 0; line < height; line++) {
+if (is_single_comp) {
+if (!is_u16)
+return; /* <= 8bpp unsupported */
+
+/* Image is double the width and half the height we need, each row 
comprises 2 rows of the output
+   (split vertically in the middle). */
+for (line = 0; line < height / 2; line++) {
 uint16_t *dst_u16 = (uint16_t *)dst;
 uint16_t *src_u16 = (uint16_t *)src;
 
+/* Blit first half of input row row to initial row of output */
+for (col = 0; col < width; col++)
+*dst_u16++ = dng_process_color16(*src_u16++, s->dng_lut, 
s->black_level, scale_factor);
+
+/* Advance the destination pointer by a row (source pointer 
remains in the same place) */
+dst += dst_stride * sizeof(uint16_t);
+dst_u16 = (uint16_t *)dst;
+
+/* Blit second half of input row row to next row of output */
 for (col = 0; col < width; col++)
 *dst_u16++ = dng_process_color16(*src_u16++, s->dng_lut, 
s->black_level, scale_factor);
 
@@ -814,12 +830,27 @@ static void dng_blit(TiffContext *s, uint8_t *dst, int 
dst_stride,
 src += src_stride * sizeof(uint16_t);
 }
 } else {
-for (line = 0; line < height; line++) {
-for (col = 0; col < width; col++)
-*dst++ = dng_process_color8(*src++, s->dng_lut, 
s->black_level, scale_factor);
+/* Input and output image are the same size and the MJpeg decoder has 
done per-component
+   deinterleaving, so blitting here is straightforward. */
+if (is_u16) {
+for (line = 0; line < height; line++) {
+uint16_t *dst_u16 = (uint16_t *)dst;
+uint16_t *src_u16 = (uint16_t *)src;
+
+for (col = 0; col < width; col++)
+*dst_u16++ = dng_process_color16(*src_u16++, s->dng_lut, 
s->black_level, scale_factor);
+
+dst += dst_stride * sizeof(uint16_t);
+src += src_stride * sizeof(uint16_t);
+}
+} else {
+for (line = 0; line < height; line++) {
+for (col = 0; col < width; col++)
+*dst++ = dng_process_color8(*src++, s->dng_lut, 
s->black_level, scale_factor);
 
-dst += dst_stride;
-src += src_stride;
+dst += dst_stride;
+src += src_stride;
+}
 }
 }
 }
@@ -831,7 +862,7 @@ static int dng_decode_jpeg_tile(AVCodecContext *avctx, 
AVFrame *frame,
 AVPacket jpkt;
 uint8_t *dst_data, *src_data;
 uint32_t dst_offset; /* offset from dst buffer in pixels */
-int is_u16, pixel_size;
+int is_single_comp, is_u16, pixel_size;
 int ret;
 
 /* Prepare a packet and send to the MJPEG decoder */
@@ -865,9 +896,18 @@ static int dng_decode_jpeg_tile(AVCodecContext *avctx, 
AVFrame *frame,
 
 /* Copy the outputted tile's pixels from 'jpgframe' to 

[FFmpeg-devel] [PATCH v15 11/15] lavc/tiff: Decode 10-bit and 14-bit DNG images

2019-08-20 Thread Nick Renieris
10-bit sample: http://www.rawsamples.ch/raws/phones/RAW_ONEPLUS_ONE-A0001.DNG
14-bit sample: 
https://drive.google.com/open?id=0B4JyRT3Lth5HVndyOTVOdWktM3J4TFEydTk1MnY3RWlpSzVB

Signed-off-by: Nick Renieris 
---
 libavcodec/tiff.c | 23 +++
 1 file changed, 15 insertions(+), 8 deletions(-)

diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index 35234dc05e..d5efd05d7c 100644
--- a/libavcodec/tiff.c
+++ b/libavcodec/tiff.c
@@ -309,14 +309,19 @@ static void av_always_inline horizontal_fill(TiffContext 
*s,
 dst[(width+offset)*2+0] = (usePtr ? src[width] : c) >> 4;
 }
 break;
-case 12: {
- uint16_t *dst16 = (uint16_t *)dst;
- GetBitContext gb;
- init_get_bits8(, src, width);
- for (int i = 0; i < s->width; i++) {
- dst16[i] = get_bits(, 12) << 4;
- }
- }
+case 10:
+case 12:
+case 14: {
+uint16_t *dst16 = (uint16_t *)dst;
+int is_dng = (s->tiff_type == TIFF_TYPE_DNG || s->tiff_type == 
TIFF_TYPE_CINEMADNG);
+uint8_t shift = is_dng ? 0 : 16 - bpp;
+GetBitContext gb;
+
+init_get_bits8(, src, width);
+for (int i = 0; i < s->width; i++) {
+dst16[i] = get_bits(, bpp) << shift;
+}
+}
 break;
 default:
 if (usePtr) {
@@ -1067,7 +1072,9 @@ static int init_image(TiffContext *s, ThreadFrame *frame)
 return AVERROR_PATCHWELCOME;
 }
 break;
+case 10101:
 case 10121:
+case 10141:
 switch (AV_RL32(s->pattern)) {
 case 0x02010100:
 s->avctx->pix_fmt = s->le ? AV_PIX_FMT_BAYER_RGGB16LE : 
AV_PIX_FMT_BAYER_RGGB16BE;
-- 
2.17.1

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

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

[FFmpeg-devel] [PATCH v15 06/15] lavc/tiff: Fix edge case with full-length/width tiles

2019-08-20 Thread Nick Renieris
In an image [1], the height was equal to the tile length (full-height
tile) and after `height % tile_length` was applied to them with the
current code, it resulted in the operating tile_length to be 0.  This
commit makes this leftover logic only applies if it's necessary.

Signed-off-by: Nick Renieris 
---
 libavcodec/tiff.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index dd1295fad6..257230c386 100644
--- a/libavcodec/tiff.c
+++ b/libavcodec/tiff.c
@@ -887,10 +887,14 @@ static int dng_decode_tiles(AVCodecContext *avctx, 
AVFrame *frame)
 int tile_byte_count_offset, tile_byte_count;
 int tile_count_x, tile_count_y;
 int tile_width, tile_length;
+int has_width_leftover, has_height_leftover;
 int tile_x = 0, tile_y = 0;
 int pos_x = 0, pos_y = 0;
 int ret;
 
+has_width_leftover = (s->width % s->tile_width != 0);
+has_height_leftover = (s->height % s->tile_length != 0);
+
 /* Calculate tile counts (round up) */
 tile_count_x = (s->width + s->tile_width - 1) / s->tile_width;
 tile_count_y = (s->height + s->tile_length - 1) / s->tile_length;
@@ -900,12 +904,12 @@ static int dng_decode_tiles(AVCodecContext *avctx, 
AVFrame *frame)
 tile_x = tile_idx % tile_count_x;
 tile_y = tile_idx / tile_count_x;
 
-if (tile_x == tile_count_x - 1) // If on the right edge
+if (has_width_leftover && tile_x == tile_count_x - 1) // If on the 
right-most tile
 tile_width = s->width % s->tile_width;
 else
 tile_width = s->tile_width;
 
-if (tile_y == tile_count_y - 1) // If on the bottom edge
+if (has_height_leftover && tile_y == tile_count_y - 1) // If on the 
bottom-most tile
 tile_length = s->height % s->tile_length;
 else
 tile_length = s->tile_length;
-- 
2.17.1

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

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

[FFmpeg-devel] [PATCH 2/2] avcodec/internal: Bump sane_nb_chanels

2019-08-20 Thread Michael Niedermayer
This allows decoding more als reference samples

Suggested-by: Thilo Borgmann 
Signed-off-by: Michael Niedermayer 
---
 libavcodec/internal.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/internal.h b/libavcodec/internal.h
index 5096ffa1d9..5f964148fd 100644
--- a/libavcodec/internal.h
+++ b/libavcodec/internal.h
@@ -83,7 +83,7 @@
 #define FF_QSCALE_TYPE_H264  2
 #define FF_QSCALE_TYPE_VP56  3
 
-#define FF_SANE_NB_CHANNELS 256U
+#define FF_SANE_NB_CHANNELS 512U
 
 #define FF_SIGNBIT(x) ((x) >> CHAR_BIT * sizeof(x) - 1)
 
-- 
2.23.0

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

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

[FFmpeg-devel] [LDP] FFmpeg at LinuxDays 2019 in Prague

2019-08-20 Thread Thilo Borgmann
Hi all,

FFmpeg has been accepted again for a booth at the LinuxDays 2019 in Prague, 
Czech Republic from October 5th to 6th!

Like last year, we hope to have a great conference with many users and fellow 
open-source projects attending! Find detailed information here:

https://www.linuxdays.cz/2019/en/

As of now, just me will attend for sure - any FFmpeg developer is welcome to 
join in and help with the booth duty!
We'll be provided free accomodation, so don't hesitate if you've interest in 
coming.

For all our users attending, we're always happy to collect your problematic 
samples (if you can find any ;) )!

Hope to meet you there!

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

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

Re: [FFmpeg-devel] [PATCH] avdevice/decklink: adjust for timecode lag

2019-08-20 Thread Devin Heitmueller
> A couple of follow-up Qs:
>
> Is auto-detection available for all Decklink devices?

No, but AFAIK it is for all devices which support SDI.  Generally it's
the older analog capture devices which don't support it.

> For those for which it is available, are there any edge cases in which
> it sets inaccurate mode?

I don't trust the existing detection code enough to use it in
production.  It often fails to detect and thus ffmpeg will exit at
startup.  Also, there are cases where it will misdetect 1080i59 as
1080p30 depending on the card.  It's been on my TODO list for a while
to make that code more robust (I believe I know what most of the
issues are), but it hasn't been critical for any of my use cases.

Devin

-- 
Devin J. Heitmueller - Kernel Labs
http://www.kernellabs.com
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

[FFmpeg-devel] [PATCH v15 09/15] lavc/mjpegdec: Enable decoding of single-component bayer images

2019-08-20 Thread Nick Renieris
Also, ensure no false positives when determining DNG bayer images, by
setting them in tiff.c instead of relying on a heuristic.  There's no
way to determine this just from the JPEG data, so we have to pass this
information from outside the MJPEG decoder.

Signed-off-by: Nick Renieris 
---
 libavcodec/mjpegdec.c | 32 +---
 libavcodec/tiff.c |  7 +++
 2 files changed, 28 insertions(+), 11 deletions(-)

diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index 6391107f78..0a920a7144 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -412,13 +412,17 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
 return AVERROR_PATCHWELCOME;
 }
 
-/* Lossless JPEGs encoded in DNGs are commonly bayer-encoded. They contain 
2
-   interleaved components and the width stored in their SOF3 markers is the
-   width of each one.  We only output a single component, therefore we need
-   to adjust the output image width. */
-if (s->lossless == 1 && nb_components == 2) {
-s->bayer = 1;
-width *= 2;
+if (s->bayer) {
+if (nb_components == 2) {
+/* Bayer images embedded in DNGs can contain 2 interleaved 
components and the
+   width stored in their SOF3 markers is the width of each one.  
We only output
+   a single component, therefore we need to adjust the output 
image width.  We
+   handle the deinterleaving (but not the debayering) in this 
file. */
+width *= 2;
+}
+/* They can also contain 1 component, which is double the width and 
half the height
+of the final image (rows are interleaved).  We don't handle the 
decoding in this
+file, but leave that to the TIFF/DNG decoder. */
 }
 
 /* if different size, realloc/alloc picture */
@@ -1184,10 +1188,16 @@ static int ljpeg_decode_rgb_scan(MJpegDecodeContext *s, 
int nb_components, int p
 ptr[3*mb_x + 0] = buffer[mb_x][1] + ptr[3*mb_x + 1];
 ptr[3*mb_x + 2] = buffer[mb_x][2] + ptr[3*mb_x + 1];
 }
-} else if (s->bayer && nb_components == 2) {
-for (mb_x = 0; mb_x < width; mb_x++) {
-((uint16_t*)ptr)[2*mb_x + 0] = buffer[mb_x][0];
-((uint16_t*)ptr)[2*mb_x + 1] = buffer[mb_x][1];
+} else if (s->bayer) {
+if (nb_components == 1) {
+/* Leave decoding to the TIFF/DNG decoder (see comment in 
ff_mjpeg_decode_sof) */
+for (mb_x = 0; mb_x < width; mb_x++)
+((uint16_t*)ptr)[mb_x] = buffer[mb_x][0];
+} else if (nb_components == 2) {
+for (mb_x = 0; mb_x < width; mb_x++) {
+((uint16_t*)ptr)[2*mb_x + 0] = buffer[mb_x][0];
+((uint16_t*)ptr)[2*mb_x + 1] = buffer[mb_x][1];
+}
 }
 } else {
 for(i=0; igb.buffer;
 jpkt.size = tile_byte_count;
 
+if (s->is_bayer) {
+MJpegDecodeContext *mjpegdecctx = s->avctx_mjpeg->priv_data;
+/* We have to set this information here, there is no way to know if a 
given JPEG is a DNG-embedded
+   image or not from its own data (and we need that information when 
decoding it). */
+mjpegdecctx->bayer = 1;
+}
+
 ret = avcodec_send_packet(s->avctx_mjpeg, );
 if (ret < 0) {
 av_log(avctx, AV_LOG_ERROR, "Error submitting a packet for 
decoding\n");
-- 
2.17.1

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

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

[FFmpeg-devel] [PATCH v15 04/15] lavc/tiff: Apply color scaling to uncompressed DNGs

2019-08-20 Thread Nick Renieris
Signed-off-by: Nick Renieris 
---
 libavcodec/tiff.c | 25 -
 1 file changed, 24 insertions(+), 1 deletion(-)

diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index a2102f32b5..dd1295fad6 100644
--- a/libavcodec/tiff.c
+++ b/libavcodec/tiff.c
@@ -556,6 +556,7 @@ static int tiff_unpack_strip(TiffContext *s, AVFrame *p, 
uint8_t *dst, int strid
 int is_yuv = !(desc->flags & AV_PIX_FMT_FLAG_RGB) &&
  (desc->flags & AV_PIX_FMT_FLAG_PLANAR) &&
  desc->nb_components >= 3;
+int is_dng;
 
 if (s->planar)
 width /= s->bppcount;
@@ -657,6 +658,8 @@ static int tiff_unpack_strip(TiffContext *s, AVFrame *p, 
uint8_t *dst, int strid
 bytestream2_init(>gb, src, size);
 bytestream2_init_writer(, dst, is_yuv ? s->yuv_line_size : (stride * 
lines));
 
+is_dng = (s->tiff_type == TIFF_TYPE_DNG || s->tiff_type == 
TIFF_TYPE_CINEMADNG);
+
 for (line = 0; line < lines; line++) {
 if (src - ssrc > size) {
 av_log(s->avctx, AV_LOG_ERROR, "Source data overread\n");
@@ -679,6 +682,25 @@ static int tiff_unpack_strip(TiffContext *s, AVFrame *p, 
uint8_t *dst, int strid
 for (i = 0; i < width; i++)
 dst[i] = ff_reverse[src[i]];
 }
+
+/* Color processing for DNG images with uncompressed strips 
(non-tiled) */
+if (is_dng) {
+int is_u16, pixel_size_bytes, pixel_size_bits;
+
+is_u16 = (s->bpp > 8);
+pixel_size_bits = (is_u16 ? 16 : 8);
+pixel_size_bytes = (is_u16 ? sizeof(uint16_t) : 
sizeof(uint8_t));
+
+dng_blit(s,
+ dst,
+ 0, // no stride, only 1 line
+ dst,
+ 0, // no stride, only 1 line
+ width / pixel_size_bytes * pixel_size_bits / s->bpp * 
s->bppcount, // need to account for [1, 16] bpp
+ 1,
+ is_u16);
+}
+
 src += width;
 break;
 case TIFF_PACKBITS:
@@ -1945,7 +1967,8 @@ again:
 FFSWAP(int,  p->linesize[0], p->linesize[1]);
 }
 
-if (s->is_bayer && s->white_level && s->bpp == 16) {
+if (s->is_bayer && s->white_level && s->bpp == 16 &&
+!(s->tiff_type == TIFF_TYPE_DNG || s->tiff_type == 
TIFF_TYPE_CINEMADNG)) {
 uint16_t *dst = (uint16_t *)p->data[0];
 for (i = 0; i < s->height; i++) {
 for (j = 0; j < s->width; j++)
-- 
2.17.1

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

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

[FFmpeg-devel] [PATCH v15 02/15] lavc/tiff: Decode embedded JPEGs in DNG images

2019-08-20 Thread Nick Renieris
Used a technique similar to lavc/tdsc.c for invoking the MJPEG decoder.

This commit adds support for:
- DNG tiles
- DNG tile huffman lossless JPEG decoding
- DNG 8-bpp ("packed" as dcraw calls it) decoding
- DNG color scaling [1]
  - LinearizationTable tag
  - BlackLevel tag

[1]: As specified in the DNG Specification - Chapter 5

Signed-off-by: Nick Renieris 
---
 configure   |   1 +
 libavcodec/Makefile |   2 +-
 libavcodec/tiff.c   | 313 +++-
 libavcodec/tiff.h   |   2 +
 4 files changed, 310 insertions(+), 8 deletions(-)

diff --git a/configure b/configure
index 34c2adb4a4..112b84f0ba 100755
--- a/configure
+++ b/configure
@@ -2817,6 +2817,7 @@ tdsc_decoder_deps="zlib"
 tdsc_decoder_select="mjpeg_decoder"
 theora_decoder_select="vp3_decoder"
 thp_decoder_select="mjpeg_decoder"
+tiff_decoder_select="mjpeg_decoder"
 tiff_decoder_suggest="zlib lzma"
 tiff_encoder_suggest="zlib"
 truehd_decoder_select="mlp_parser"
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 3cd73fbcc6..f814c69996 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -616,7 +616,7 @@ OBJS-$(CONFIG_TARGA_ENCODER)   += targaenc.o rle.o
 OBJS-$(CONFIG_TARGA_Y216_DECODER)  += targa_y216dec.o
 OBJS-$(CONFIG_TDSC_DECODER)+= tdsc.o
 OBJS-$(CONFIG_TIERTEXSEQVIDEO_DECODER) += tiertexseqv.o
-OBJS-$(CONFIG_TIFF_DECODER)+= tiff.o lzw.o faxcompr.o tiff_data.o 
tiff_common.o
+OBJS-$(CONFIG_TIFF_DECODER)+= tiff.o lzw.o faxcompr.o tiff_data.o 
tiff_common.o mjpegdec.o
 OBJS-$(CONFIG_TIFF_ENCODER)+= tiffenc.o rle.o lzwenc.o tiff_data.o
 OBJS-$(CONFIG_TMV_DECODER) += tmv.o cga_data.o
 OBJS-$(CONFIG_TRUEHD_DECODER)  += mlpdec.o mlpdsp.o
diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index c520d7df83..4c6b835afe 100644
--- a/libavcodec/tiff.c
+++ b/libavcodec/tiff.c
@@ -35,6 +35,7 @@
 
 #include "libavutil/attributes.h"
 #include "libavutil/avstring.h"
+#include "libavutil/error.h"
 #include "libavutil/intreadwrite.h"
 #include "libavutil/imgutils.h"
 #include "libavutil/opt.h"
@@ -46,6 +47,7 @@
 #include "mathops.h"
 #include "tiff.h"
 #include "tiff_data.h"
+#include "mjpegdec.h"
 #include "thread.h"
 #include "get_bits.h"
 
@@ -54,6 +56,10 @@ typedef struct TiffContext {
 AVCodecContext *avctx;
 GetByteContext gb;
 
+/* JPEG decoding for DNG */
+AVCodecContext *avctx_mjpeg; // wrapper context for MJPEG
+AVFrame *jpgframe;   // decoded JPEG tile
+
 int get_subimage;
 uint16_t get_page;
 int get_thumbnail;
@@ -76,7 +82,9 @@ typedef struct TiffContext {
 
 int is_bayer;
 uint8_t pattern[4];
+unsigned black_level;
 unsigned white_level;
+const uint16_t *dng_lut; // Pointer to DNG linearization table
 
 uint32_t sub_ifd;
 uint16_t cur_page;
@@ -86,6 +94,14 @@ typedef struct TiffContext {
 int stripsizesoff, stripsize, stripoff, strippos;
 LZWState *lzw;
 
+/* Tile support */
+int is_tiled;
+int tile_byte_counts_offset, tile_offsets_offset;
+int tile_width, tile_length;
+int tile_count;
+
+int is_jpeg;
+
 uint8_t *deinvert_buf;
 int deinvert_buf_size;
 uint8_t *yuv_line;
@@ -257,6 +273,9 @@ static int add_metadata(int count, int type,
 };
 }
 
+static void av_always_inline dng_blit(TiffContext *s, uint8_t *dst, int 
dst_stride,
+  const uint8_t *src, int src_stride, int 
width, int height, int is_u16);
+
 static void av_always_inline horizontal_fill(TiffContext *s,
  unsigned int bpp, uint8_t* dst,
  int usePtr, const uint8_t *src,
@@ -712,6 +731,204 @@ static int tiff_unpack_strip(TiffContext *s, AVFrame *p, 
uint8_t *dst, int strid
 return 0;
 }
 
+/**
+ * Map stored raw sensor values into linear reference values.
+ * See: DNG Specification - Chapter 5
+ */
+static uint16_t av_always_inline dng_raw_to_linear16(uint16_t value,
+const uint16_t *lut,
+uint16_t black_level,
+float scale_factor) {
+// Lookup table lookup
+if (lut)
+value = lut[value];
+
+// Black level subtraction
+value = av_clip_uint16_c((unsigned)value - black_level);
+
+// Color scaling
+value = av_clip_uint16_c((unsigned)(((float)value * scale_factor) * 
0x));
+
+return value;
+}
+
+static uint16_t av_always_inline dng_raw_to_linear8(uint16_t value,
+const uint16_t *lut,
+uint16_t black_level,
+float scale_factor) {
+return dng_raw_to_linear16(value, lut, black_level, scale_factor) >> 8;
+}
+
+static void dng_blit(TiffContext *s, uint8_t *dst, int 

[FFmpeg-devel] [PATCH v15 07/15] lavc/tiff: Don't apply strips-related logic to tiled images

2019-08-20 Thread Nick Renieris
Signed-off-by: Nick Renieris 
---
 libavcodec/tiff.c | 42 ++
 1 file changed, 22 insertions(+), 20 deletions(-)

diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index 257230c386..1ca9a59dbf 100644
--- a/libavcodec/tiff.c
+++ b/libavcodec/tiff.c
@@ -1780,7 +1780,7 @@ again:
 }
 }
 
-if (!s->strippos && !s->stripoff) {
+if (!s->is_tiled && !s->strippos && !s->stripoff) {
 av_log(avctx, AV_LOG_ERROR, "Image data is missing\n");
 return AVERROR_INVALIDDATA;
 }
@@ -1788,27 +1788,29 @@ again:
 if ((ret = init_image(s, )) < 0)
 return ret;
 
-if (s->strips == 1 && !s->stripsize) {
-av_log(avctx, AV_LOG_WARNING, "Image data size missing\n");
-s->stripsize = avpkt->size - s->stripoff;
-}
+if (!s->is_tiled) {
+if (s->strips == 1 && !s->stripsize) {
+av_log(avctx, AV_LOG_WARNING, "Image data size missing\n");
+s->stripsize = avpkt->size - s->stripoff;
+}
 
-if (s->stripsizesoff) {
-if (s->stripsizesoff >= (unsigned)avpkt->size)
-return AVERROR_INVALIDDATA;
-bytestream2_init(, avpkt->data + s->stripsizesoff,
- avpkt->size - s->stripsizesoff);
-}
-if (s->strippos) {
-if (s->strippos >= (unsigned)avpkt->size)
-return AVERROR_INVALIDDATA;
-bytestream2_init(, avpkt->data + s->strippos,
- avpkt->size - s->strippos);
-}
+if (s->stripsizesoff) {
+if (s->stripsizesoff >= (unsigned)avpkt->size)
+return AVERROR_INVALIDDATA;
+bytestream2_init(, avpkt->data + s->stripsizesoff,
+avpkt->size - s->stripsizesoff);
+}
+if (s->strippos) {
+if (s->strippos >= (unsigned)avpkt->size)
+return AVERROR_INVALIDDATA;
+bytestream2_init(, avpkt->data + s->strippos,
+avpkt->size - s->strippos);
+}
 
-if (s->rps <= 0 || s->rps % s->subsampling[1]) {
-av_log(avctx, AV_LOG_ERROR, "rps %d invalid\n", s->rps);
-return AVERROR_INVALIDDATA;
+if (s->rps <= 0 || s->rps % s->subsampling[1]) {
+av_log(avctx, AV_LOG_ERROR, "rps %d invalid\n", s->rps);
+return AVERROR_INVALIDDATA;
+}
 }
 
 /* Handle DNG images with JPEG-compressed tiles */
-- 
2.17.1

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

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

[FFmpeg-devel] [PATCH 1/2] avcodec/alsdec: Limit maximum channels to 512

2019-08-20 Thread Michael Niedermayer
There seems to be no limit in the specification and upto 64k could be stored
512 is choosen as limit as thats the maximum in a conformance sample

An alternative to this patch would be a max_channels variable

Fixes: OOM
Fixes: 
16200/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ALS_fuzzer-5764788793114624

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Suggested-by: Thilo Borgmann 
Signed-off-by: Michael Niedermayer 
---
 libavcodec/alsdec.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/libavcodec/alsdec.c b/libavcodec/alsdec.c
index 36ee164ee4..11bbd38f58 100644
--- a/libavcodec/alsdec.c
+++ b/libavcodec/alsdec.c
@@ -348,6 +348,11 @@ static av_cold int read_specific_config(ALSDecContext *ctx)
 if (als_id != MKBETAG('A','L','S','\0'))
 return AVERROR_INVALIDDATA;
 
+if (avctx->channels > FF_SANE_NB_CHANNELS) {
+avpriv_request_sample(avctx, "Huge number of channels\n");
+return AVERROR_PATCHWELCOME;
+}
+
 ctx->cur_frame_length = sconf->frame_length;
 
 // read channel config
-- 
2.23.0

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

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

Re: [FFmpeg-devel] [REQUEST] avcodec/scpr: revert d70276921348

2019-08-20 Thread Paul B Mahol
On Tue, Aug 20, 2019 at 3:16 PM Carl Eugen Hoyos  wrote:

> Am Di., 20. Aug. 2019 um 14:48 Uhr schrieb Paul B Mahol  >:
>
> > I kindly ask that following commit:
> d702769213487923c0fb0abe4b61f4d9ebddb88b
>
> I still believe what the patch does is a very good idea and a revert would
> hurt FFmpeg.
>

I strongly disagree, this kind of patches should stop.


>
> Carl Eugen
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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