[FFmpeg-devel] [PATCH] avformat/movenc: read track title from correct key

2018-06-16 Thread Gyan Doshi

Activates functionality added a few years ago.

Regards,
Gyan
From bead9f22630f2b8efc4a3859568cb0fc46102dd3 Mon Sep 17 00:00:00 2001
From: Gyan Doshi 
Date: Sat, 16 Jun 2018 15:31:51 +0530
Subject: [PATCH] avformat/movenc: read track title from correct key

da9cc22d5bd allowed the MOV muxer to relay a custom stream handler name,
whether populated from the input stream or user-set. However, the entry
key didn't match the key set by the MOV demuxer, so it wasn't
effective. Fixed.

Due to the change, four FATE refs have to be updated. Verified that the
target payload of the tests hasn't changed in terms of CRC.
---
 libavformat/movenc.c| 2 +-
 tests/ref/fate/binsub-movtextenc| 2 +-
 tests/ref/fate/copy-psp | 4 ++--
 tests/ref/fate/copy-trac236 | 4 ++--
 tests/ref/lavf-fate/mov_qtrle_mace6 | 4 ++--
 5 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index db266b7765..3661d24f4f 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -2599,7 +2599,7 @@ static int mov_write_hdlr_tag(AVFormatContext *s, 
AVIOContext *pb, MOVTrack *tra
 // of the track. So if an alternate handler description is
 // specified, use it.
 AVDictionaryEntry *t;
-t = av_dict_get(track->st->metadata, "handler", NULL, 0);
+t = av_dict_get(track->st->metadata, "handler_name", NULL, 0);
 if (t && utf8len(t->value))
 descr = t->value;
 }
diff --git a/tests/ref/fate/binsub-movtextenc b/tests/ref/fate/binsub-movtextenc
index 22ee85a2f8..dacee0931e 100644
--- a/tests/ref/fate/binsub-movtextenc
+++ b/tests/ref/fate/binsub-movtextenc
@@ -1 +1 @@
-af6a8f38d7c11d9af7823cc44554d2ad
+66b25412f7ca699ee525ba162246edb6
diff --git a/tests/ref/fate/copy-psp b/tests/ref/fate/copy-psp
index 81eb172549..44ec461265 100644
--- a/tests/ref/fate/copy-psp
+++ b/tests/ref/fate/copy-psp
@@ -1,5 +1,5 @@
-cada61453a2483ef8ba1fb82c8bbff25 *tests/data/fate/copy-psp.psp
-2041433 tests/data/fate/copy-psp.psp
+65a177552e03123c9a62ddb942970d05 *tests/data/fate/copy-psp.psp
+2041445 tests/data/fate/copy-psp.psp
 #extradata 0:   51, 0xaf6d1012
 #extradata 1:2, 0x00b200a1
 #tb 0: 1/9
diff --git a/tests/ref/fate/copy-trac236 b/tests/ref/fate/copy-trac236
index c5240ca3d3..6470c05a05 100644
--- a/tests/ref/fate/copy-trac236
+++ b/tests/ref/fate/copy-trac236
@@ -1,5 +1,5 @@
-d6e3d97b522ce881ed29c5da74cc7e63 *tests/data/fate/copy-trac236.mov
-630810 tests/data/fate/copy-trac236.mov
+8b57d14c14bb4cdaca660d161e08eb8f *tests/data/fate/copy-trac236.mov
+630861 tests/data/fate/copy-trac236.mov
 #tb 0: 100/2997
 #media_type 0: video
 #codec_id 0: rawvideo
diff --git a/tests/ref/lavf-fate/mov_qtrle_mace6 
b/tests/ref/lavf-fate/mov_qtrle_mace6
index f8428aaa49..3afb909574 100644
--- a/tests/ref/lavf-fate/mov_qtrle_mace6
+++ b/tests/ref/lavf-fate/mov_qtrle_mace6
@@ -1,3 +1,3 @@
-dcc9c4c182a5809dee9a9366f4533797 *./tests/data/lavf-fate/lavf.mov
-1270387 ./tests/data/lavf-fate/lavf.mov
+f9715cc38a3206bcdf105786905255af *./tests/data/lavf-fate/lavf.mov
+1270415 ./tests/data/lavf-fate/lavf.mov
 ./tests/data/lavf-fate/lavf.mov CRC=0x9320cd26
-- 
2.12.2.windows.2___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH]lavf/mov: Do not fail hard for truncated stsz atom

2018-06-16 Thread Carl Eugen Hoyos
Hi!

Attached patch fixes ticket #6433 for me, this is also what vlc does.

Please comment, Carl Eugen
From adfa5858eacbb6210e5e9da20284b3a27523e5b1 Mon Sep 17 00:00:00 2001
From: Carl Eugen Hoyos 
Date: Sat, 16 Jun 2018 14:22:52 +0200
Subject: [PATCH] lavf/mov: Do not fail hard for truncated stsz atoms.

Fixes ticket #6433.
---
 libavformat/mov.c |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 0acf981..1011763 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -2841,7 +2841,8 @@ static int mov_read_stsz(MOVContext *c, AVIOContext *pb, MOVAtom atom)
 if (ret < 0) {
 av_freep(&sc->sample_sizes);
 av_free(buf);
-return ret;
+av_log(c->fc, AV_LOG_WARNING, "STSZ atom truncated\n");
+return 0;
 }
 
 init_get_bits(&gb, buf, 8*num_bytes);
-- 
1.7.10.4

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


Re: [FFmpeg-devel] [PATCH]lavfi/avfiltergraph: Do not return ENOMEM if filter is missing

2018-06-16 Thread Carl Eugen Hoyos
2018-02-05 3:05 GMT+01:00, James Almer :
> On 2/4/2018 10:33 PM, Carl Eugen Hoyos wrote:
>> Hi!
>>
>> OOM is unlikely as a failure for avfilter_graph_alloc_filter(), the
>> patch avoids a surprising error if a filter was not found.
>>
>> Please comment, Carl Eugen
>>
>>
>> 0001-lavfi-avfiltergraph-Do-not-return-ENOMEM-if-filterch.patch
>>
>>
>> From 6587726a5e96570bb54e49ccf0b7fd6d94b929c8 Mon Sep 17 00:00:00 2001
>> From: Carl Eugen Hoyos 
>> Date: Mon, 5 Feb 2018 01:43:08 +0100
>> Subject: [PATCH] lavfi/avfiltergraph: Do not return ENOMEM if filterchain
>>  init failed.
>>
>> A more likely reason is that the filter was not found.
>> ---
>>  libavfilter/avfiltergraph.c |2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c
>> index 4cc6892..7ccd895 100644
>> --- a/libavfilter/avfiltergraph.c
>> +++ b/libavfilter/avfiltergraph.c
>> @@ -147,7 +147,7 @@ int avfilter_graph_create_filter(AVFilterContext
>> **filt_ctx, const AVFilter *fil
>>
>>  *filt_ctx = avfilter_graph_alloc_filter(graph_ctx, filt, name);
>>  if (!*filt_ctx)
>> -return AVERROR(ENOMEM);
>> +return -1;
>
> -1 is not acceptable for a public function that states it returns an
> AVERROR value on failure.
> If the issue is that avfilter_graph_alloc_filter() may fail because of
> both OOM and an invalid value for filter, then I'm more inclined to use
> AVERROR_UNKNOWN here instead.

New patch attached.

Please comment, Carl Eugen
From 491b6f071865f4639fbf2530cd6d1a2c9aa87cda Mon Sep 17 00:00:00 2001
From: Carl Eugen Hoyos 
Date: Sat, 16 Jun 2018 14:37:55 +0200
Subject: [PATCH] lavfi/avfiltergraph: Do not return ENOMEM if filterchain
 init failed.

A more likely reason is that the filter was not found.
Improves ticket #7001.
---
 libavfilter/avfiltergraph.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c
index a149f8f..b1c88e7 100644
--- a/libavfilter/avfiltergraph.c
+++ b/libavfilter/avfiltergraph.c
@@ -147,7 +147,7 @@ int avfilter_graph_create_filter(AVFilterContext **filt_ctx, const AVFilter *fil
 
 *filt_ctx = avfilter_graph_alloc_filter(graph_ctx, filt, name);
 if (!*filt_ctx)
-return AVERROR(ENOMEM);
+return AVERROR_UNKNOWN;
 
 ret = avfilter_init_str(*filt_ctx, args);
 if (ret < 0)
-- 
1.7.10.4

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


[FFmpeg-devel] [PATCH]lavc/dpx: Support 12-bit packing method b (msbpad)

2018-06-16 Thread Carl Eugen Hoyos
Hi!

Attached patch allows to decode files that can be created with GraphicsMagick:
$ gm convert input -depth 12 -define dpx:packing-method=b out.dpx

Please comment, Carl Eugen
From 93c9de7a1ca638dfe7bb2a4108974e55ab13c9b8 Mon Sep 17 00:00:00 2001
From: Carl Eugen Hoyos 
Date: Sat, 16 Jun 2018 17:11:58 +0200
Subject: [PATCH] lavc/dpx: Support 12-bit packing method b (msbpad).

---
 libavcodec/dpx.c |   22 +-
 1 file changed, 9 insertions(+), 13 deletions(-)

diff --git a/libavcodec/dpx.c b/libavcodec/dpx.c
index 582a861..69d594b 100644
--- a/libavcodec/dpx.c
+++ b/libavcodec/dpx.c
@@ -170,10 +170,6 @@ static int decode_frame(AVCodecContext *avctx,
 packing = read16(&buf, endian);
 encoding = read16(&buf, endian);
 
-if (packing > 1) {
-avpriv_report_missing_feature(avctx, "Packing %d", packing);
-return AVERROR_PATCHWELCOME;
-}
 if (encoding) {
 avpriv_report_missing_feature(avctx, "Encoding %d", encoding);
 return AVERROR_PATCHWELCOME;
@@ -225,7 +221,7 @@ static int decode_frame(AVCodecContext *avctx,
 stride = avctx->width * elements;
 break;
 case 10:
-if (!packing) {
+if (!packing || packing > 1) {
 av_log(avctx, AV_LOG_ERROR, "Packing to 32bit required\n");
 return -1;
 }
@@ -387,16 +383,16 @@ static int decode_frame(AVCodecContext *avctx,
 (uint16_t*)ptr[1],
 (uint16_t*)ptr[2],
 (uint16_t*)ptr[3]};
+int shift = packing == 1 ? 4 : 0;
 for (y = 0; y < avctx->width; y++) {
 if (packing) {
-if (elements >= 3)
-*dst[2]++ = read16(&buf, endian) >> 4;
-*dst[0] = read16(&buf, endian) >> 4;
-dst[0]++;
-if (elements >= 2)
-*dst[1]++ = read16(&buf, endian) >> 4;
-if (elements == 4)
-*dst[3]++ = read16(&buf, endian) >> 4;
+if (elements >= 3)
+*dst[2]++ = read16(&buf, endian) >> shift;
+*dst[0]++ = read16(&buf, endian) >> shift;
+if (elements >= 2)
+*dst[1]++ = read16(&buf, endian) >> shift;
+if (elements == 4)
+*dst[3]++ = read16(&buf, endian) >> shift;
 } else {
 *dst[2]++ = read12in32(&buf, &rgbBuffer,
&n_datum, endian);
-- 
1.7.10.4

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


[FFmpeg-devel] [PATCH]lavc/dpx: Support 10-bit packing method b (msbpad)

2018-06-16 Thread Carl Eugen Hoyos
Hi!

Attached patch allows to decode 10-bit dpx files with packing method
b, needs the 12-bit patch.

Please comment, Carl Eugen
From 401bdebba6dc8fa2253c720107a971b3fbf2c312 Mon Sep 17 00:00:00 2001
From: Carl Eugen Hoyos 
Date: Sat, 16 Jun 2018 17:47:46 +0200
Subject: [PATCH] lavc/dpx: Support 10-bit packing method b (msbpad).

---
 libavcodec/dpx.c |   15 ---
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/libavcodec/dpx.c b/libavcodec/dpx.c
index 69d594b..0650a20 100644
--- a/libavcodec/dpx.c
+++ b/libavcodec/dpx.c
@@ -51,7 +51,7 @@ static unsigned int read32(const uint8_t **ptr, int is_big)
 }
 
 static uint16_t read10in32(const uint8_t **ptr, uint32_t * lbuf,
-  int * n_datum, int is_big)
+  int * n_datum, int is_big, int shift)
 {
 if (*n_datum)
 (*n_datum)--;
@@ -60,7 +60,7 @@ static uint16_t read10in32(const uint8_t **ptr, uint32_t * lbuf,
 *n_datum = 2;
 }
 
-*lbuf = (*lbuf << 10) | (*lbuf >> 22);
+*lbuf = (*lbuf << 10) | (*lbuf >> shift);
 
 return *lbuf & 0x3FF;
 }
@@ -221,7 +221,7 @@ static int decode_frame(AVCodecContext *avctx,
 stride = avctx->width * elements;
 break;
 case 10:
-if (!packing || packing > 1) {
+if (!packing) {
 av_log(avctx, AV_LOG_ERROR, "Packing to 32bit required\n");
 return -1;
 }
@@ -360,17 +360,18 @@ static int decode_frame(AVCodecContext *avctx,
 (uint16_t*)ptr[1],
 (uint16_t*)ptr[2],
 (uint16_t*)ptr[3]};
+int shift = packing == 1 ? 22 : 20;
 for (y = 0; y < avctx->width; y++) {
 *dst[2]++ = read10in32(&buf, &rgbBuffer,
-   &n_datum, endian);
+   &n_datum, endian, shift);
 *dst[0]++ = read10in32(&buf, &rgbBuffer,
-   &n_datum, endian);
+   &n_datum, endian, shift);
 *dst[1]++ = read10in32(&buf, &rgbBuffer,
-   &n_datum, endian);
+   &n_datum, endian, shift);
 if (elements == 4)
 *dst[3]++ =
 read10in32(&buf, &rgbBuffer,
-   &n_datum, endian);
+   &n_datum, endian, shift);
 }
 n_datum = 0;
 for (i = 0; i < elements; i++)
-- 
1.7.10.4

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


Re: [FFmpeg-devel] Fw: [PATCH] Refactor two near-identical clauses.

2018-06-16 Thread Shlomi Fish
On Tue, 12 Jun 2018 12:53:20 +0300
Shlomi Fish  wrote:

> This message did not arrive to the list after three submissions.
> 

hi all!

Ping! Can this patch please be reviewed?

> Begin forwarded message:
> 
> Date: Tue, 12 Jun 2018 12:42:52 +0300
> From: Shlomi Fish 
> To: ffmpeg-devel@ffmpeg.org
> Cc: Shlomi Fish 
> Subject: [PATCH] Refactor two near-identical clauses.
> 
> 
> Placed under the Expat licence . All tests pass.
> ---
>  libavfilter/vf_weave.c | 33 ++---
>  1 file changed, 14 insertions(+), 19 deletions(-)
> 
> diff --git a/libavfilter/vf_weave.c b/libavfilter/vf_weave.c
> index 037f5d1cf2..be371201e1 100644
> --- a/libavfilter/vf_weave.c
> +++ b/libavfilter/vf_weave.c
> @@ -23,6 +23,7 @@
>  #include "libavutil/pixdesc.h"
>  #include "avfilter.h"
>  #include "internal.h"
> +#include 
>  
>  typedef struct WeaveContext {
>  const AVClass *class;
> @@ -84,6 +85,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
>  AVFilterLink *outlink = ctx->outputs[0];
>  AVFrame *out;
>  int i;
> +bool weave;
> +int field1, field2;
>  
>  if (!s->prev) {
>  s->prev = in;
> @@ -98,26 +101,18 @@ static int filter_frame(AVFilterLink *inlink, AVFrame
> *in) }
>  av_frame_copy_props(out, in);
>  
> +weave = (s->double_weave && !(inlink->frame_count_out & 1));
> +field1 = s->first_field * weave;
> +field2 = s->first_field * !weave;
>  for (i = 0; i < s->nb_planes; i++) {
> -if (s->double_weave && !(inlink->frame_count_out & 1)) {
> -av_image_copy_plane(out->data[i] + out->linesize[i] *
> s->first_field,
> -out->linesize[i] * 2,
> -in->data[i], in->linesize[i],
> -s->linesize[i], s->planeheight[i]);
> -av_image_copy_plane(out->data[i] + out->linesize[i]
> * !s->first_field,
> -out->linesize[i] * 2,
> -s->prev->data[i], s->prev->linesize[i],
> -s->linesize[i], s->planeheight[i]);
> -} else {
> -av_image_copy_plane(out->data[i] + out->linesize[i]
> * !s->first_field,
> -out->linesize[i] * 2,
> -in->data[i], in->linesize[i],
> -s->linesize[i], s->planeheight[i]);
> -av_image_copy_plane(out->data[i] + out->linesize[i] *
> s->first_field,
> -out->linesize[i] * 2,
> -s->prev->data[i], s->prev->linesize[i],
> -s->linesize[i], s->planeheight[i]);
> -}
> +av_image_copy_plane(out->data[i] + out->linesize[i] * field1,
> +out->linesize[i] * 2,
> +in->data[i], in->linesize[i],
> +s->linesize[i], s->planeheight[i]);
> +av_image_copy_plane(out->data[i] + out->linesize[i] * field2,
> +out->linesize[i] * 2,
> +s->prev->data[i], s->prev->linesize[i],
> +s->linesize[i], s->planeheight[i]);
>  }
>  
>  out->pts = s->double_weave ? s->prev->pts : in->pts / 2;



-- 
-
Shlomi Fish   http://www.shlomifish.org/
https://github.com/shlomif/PySolFC - open source Solitaire games

Larry Wall has more dollars in the bank than in his Perl code.
— http://www.shlomifish.org/humour/bits/facts/Larry-Wall/

Please reply to list if it's a mailing list post - http://shlom.in/reply .
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH v2] avcodec/vc1: fix overlap smoothing filter for P frames

2018-06-16 Thread Carl Eugen Hoyos
2018-05-30 13:53 GMT+02:00, Jerome Borsboom :
> The v_overlap_filter needs to run on the colocated block of the previous
> macroblock. For the luma plane, the colocated block is located two blocks
> on the left instead of one. In addition, the overlap filter needs to run
> on the non-edge blocks of the first macroblock row and column.
>
> Signed-off-by: Jerome Borsboom 
> ---
> This is an improved patch that should also fix the remaining frames in
> SSL0013.rcv.

Patch applied.

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


Re: [FFmpeg-devel] [PATCH 1/4] avcodec/vc1: fix overlap filtering for Simple and Main profile

2018-06-16 Thread Carl Eugen Hoyos
2018-06-06 21:20 GMT+02:00, Carl Eugen Hoyos :
> 2018-06-06 20:47 GMT+02:00, Jerome Borsboom :
>> Overlap filtering I and BI frames for Simple and Main profile is only
>> dependent on PQUANT. Restrict testing for CONDOVER and OVERFLAGS to
>> advanced profile.
>>
>> Signed-off-by: Jerome Borsboom 
>> ---
>> This patch set should fix decoding of the SSL0015.rcv test file to make
>> it
>> bit-equal to the reference decoder.
>
> I can confirm that this patchset fixes the file.

Patchset applied, thank you!

> The following three files all seem to have the same issues both
> with software and hardware decoder, frame re-ordering?
> SA10125.vc1, SA10126.vc1, SA10127.vc1

I believe this affects some more reference samples, also
reproducible with hardware decoding, may be the last known
"bug", other issues like "pan-scan" and "Luma scaling, chroma
scaling" are reported as missing features on the console.

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


Re: [FFmpeg-devel] [PATCH 1/2] avcodec/vaapi: slice_vertical_position starts from zero for the second field

2018-06-16 Thread Carl Eugen Hoyos
2018-06-08 11:09 GMT+02:00, Jerome Borsboom :
> If there are no more issues or remarks with these two patches, could
> someone please commit them?

I cannot test, sorry!

Perhaps you could send your public git key to Michael and push yourself?

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


Re: [FFmpeg-devel] [PATCH]lavc/dpx: Support 10-bit packing method b (msbpad)

2018-06-16 Thread Jerome Martinez

On 16/06/2018 17:49, Carl Eugen Hoyos wrote:

Hi!

Attached patch allows to decode 10-bit dpx files with packing method
b, needs the 12-bit patch.


Great to see the support of Method B.



Please comment, Carl Eugen
[...]

+    *lbuf = (*lbuf << 10) | (*lbuf >> shift);



Padding bits are 0 in all DPX files I have seen up to now but in theory 
padding bits are not defined (they are set to 0 in an informative part 
of the spec, the one containing diagrams, which does not mean that they 
must be 0 as it is only an informative part; I don't see elsewhere in 
the spec that padding bits must be 0, I understand that value of padding 
bits are not defined so could be any)


Example of impact on the suggested patch if padding bits are 1:

Method A (shift is 22), hat is currently in FFmpeg:
CCBBAA11 initial after read32 then
BBAA11CC so CC with 0x3FF mask then
AA11CCBB so BB with 0x3FF mask then
11CCBBAA so AA with 0x3FF mask
Padding bits are never used, so they can have any value without impact 
on the pixels


Method B (shift is 20)
11CCBBAA initial after read32 then
CCBB11CC so CC with 0x3FF mask then
BB11??BB so BB with 0x3FF mask then
11????11 so 11 with 0x3FF mask
the last component is "corrupted" by the padding bits if they are not 0.

I suggest to not expect that padding bits are 0 (to not depend on their 
value for filling the pixel content).

For example, by using:
int shift = packing == 1 ? 0 : 2;
then in read10in32() add "<< shift" after read32 call:
*lbuf = read32(ptr, is_big) << shift;
in order to transform Method B in Method A.

Similar issue with 12-bit Method B support (No 0xFFF mask so MSB bits 
may contain 1, which is maybe not expected in other parts of FFmpeg and 
may lead to weird output if padding bits are not 0, by having pixel 
content greater than 1^12-1)


Jérôme

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


Re: [FFmpeg-devel] [PATCH] avformat/movenc: read track title from correct key

2018-06-16 Thread John Stebbins
On 06/16/2018 03:49 AM, Gyan Doshi wrote:
> Activates functionality added a few years ago.
>
> Regards,
> Gyan
>

FYI, HandBrake has been using the "handler" metadata key since 2014 when I 
added this code.  And it was completely self-consistent (since it was the only 
occurrence of usage of this key) until Hendrik Leppkes added support for 
reading the handler name in
2015 but used handler_name metadata key instead.  I'm not against the change.  
Just need to make a note to myself to fix HandBrake when we update to a version 
of ffmpeg with the change.

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




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


Re: [FFmpeg-devel] [PATCH]lavc/dpx: Support 12-bit packing method b (msbpad)

2018-06-16 Thread Carl Eugen Hoyos
2018-06-16 17:18 GMT+02:00, Carl Eugen Hoyos :

> Attached patch allows to decode files that can be created with
> GraphicsMagick:
> $ gm convert input -depth 12 -define dpx:packing-method=b out.dpx

Updated patch attached, hoping I understood Jerome's comment correctly.

Please comment, Carl Eugen
From 93c9de7a1ca638dfe7bb2a4108974e55ab13c9b8 Mon Sep 17 00:00:00 2001
From: Carl Eugen Hoyos 
Date: Sat, 16 Jun 2018 17:11:58 +0200
Subject: [PATCH] lavc/dpx: Support 12-bit packing method b (msbpad).

---
 libavcodec/dpx.c |   22 +-
 1 file changed, 9 insertions(+), 13 deletions(-)

diff --git a/libavcodec/dpx.c b/libavcodec/dpx.c
index 582a861..69d594b 100644
--- a/libavcodec/dpx.c
+++ b/libavcodec/dpx.c
@@ -170,10 +170,6 @@ static int decode_frame(AVCodecContext *avctx,
 packing = read16(&buf, endian);
 encoding = read16(&buf, endian);
 
-if (packing > 1) {
-avpriv_report_missing_feature(avctx, "Packing %d", packing);
-return AVERROR_PATCHWELCOME;
-}
 if (encoding) {
 avpriv_report_missing_feature(avctx, "Encoding %d", encoding);
 return AVERROR_PATCHWELCOME;
@@ -225,7 +221,7 @@ static int decode_frame(AVCodecContext *avctx,
 stride = avctx->width * elements;
 break;
 case 10:
-if (!packing) {
+if (!packing || packing > 1) {
 av_log(avctx, AV_LOG_ERROR, "Packing to 32bit required\n");
 return -1;
 }
@@ -387,16 +383,16 @@ static int decode_frame(AVCodecContext *avctx,
 (uint16_t*)ptr[1],
 (uint16_t*)ptr[2],
 (uint16_t*)ptr[3]};
+int shift = packing == 1 ? 4 : 0;
 for (y = 0; y < avctx->width; y++) {
 if (packing) {
-if (elements >= 3)
-*dst[2]++ = read16(&buf, endian) >> 4;
-*dst[0] = read16(&buf, endian) >> 4;
-dst[0]++;
-if (elements >= 2)
-*dst[1]++ = read16(&buf, endian) >> 4;
-if (elements == 4)
-*dst[3]++ = read16(&buf, endian) >> 4;
+if (elements >= 3)
+*dst[2]++ = read16(&buf, endian) >> shift & 0xFFF;
+*dst[0]++ = read16(&buf, endian) >> shift & 0xFFF;
+if (elements >= 2)
+*dst[1]++ = read16(&buf, endian) >> shift & 0xFFF;
+if (elements == 4)
+*dst[3]++ = read16(&buf, endian) >> shift & 0xFFF;
 } else {
 *dst[2]++ = read12in32(&buf, &rgbBuffer,
&n_datum, endian);
-- 
1.7.10.4

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


Re: [FFmpeg-devel] [PATCH]lavc/dpx: Support 10-bit packing method b (msbpad)

2018-06-16 Thread Carl Eugen Hoyos
2018-06-16 21:32 GMT+02:00, Jerome Martinez :
> On 16/06/2018 17:49, Carl Eugen Hoyos wrote:

>> +*lbuf = (*lbuf << 10) | (*lbuf >> shift);
>
> Padding bits are 0 in all DPX files I have seen up to now
> but in theory padding bits are not defined

Of course not, new patch attached.
Thank you!

Please comment, Carl Eugen
From 401bdebba6dc8fa2253c720107a971b3fbf2c312 Mon Sep 17 00:00:00 2001
From: Carl Eugen Hoyos 
Date: Sat, 16 Jun 2018 17:47:46 +0200
Subject: [PATCH] lavc/dpx: Support 10-bit packing method b (msbpad).

---
 libavcodec/dpx.c |   15 ---
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/libavcodec/dpx.c b/libavcodec/dpx.c
index 69d594b..0650a20 100644
--- a/libavcodec/dpx.c
+++ b/libavcodec/dpx.c
@@ -51,7 +51,7 @@ static unsigned int read32(const uint8_t **ptr, int is_big)
 }
 
 static uint16_t read10in32(const uint8_t **ptr, uint32_t * lbuf,
-  int * n_datum, int is_big)
+  int * n_datum, int is_big, int shift)
 {
 if (*n_datum)
 (*n_datum)--;
@@ -60,7 +60,7 @@ static uint16_t read10in32(const uint8_t **ptr, uint32_t * lbuf,
 *n_datum = 2;
 }
 
-*lbuf = (*lbuf << 10) | (*lbuf >> 22);
+*lbuf = *lbuf << 10 | *lbuf >> shift & 0x3F;
 
 return *lbuf & 0x3FF;
 }
@@ -221,7 +221,7 @@ static int decode_frame(AVCodecContext *avctx,
 stride = avctx->width * elements;
 break;
 case 10:
-if (!packing || packing > 1) {
+if (!packing) {
 av_log(avctx, AV_LOG_ERROR, "Packing to 32bit required\n");
 return -1;
 }
@@ -360,17 +360,18 @@ static int decode_frame(AVCodecContext *avctx,
 (uint16_t*)ptr[1],
 (uint16_t*)ptr[2],
 (uint16_t*)ptr[3]};
+int shift = packing == 1 ? 22 : 20;
 for (y = 0; y < avctx->width; y++) {
 *dst[2]++ = read10in32(&buf, &rgbBuffer,
-   &n_datum, endian);
+   &n_datum, endian, shift);
 *dst[0]++ = read10in32(&buf, &rgbBuffer,
-   &n_datum, endian);
+   &n_datum, endian, shift);
 *dst[1]++ = read10in32(&buf, &rgbBuffer,
-   &n_datum, endian);
+   &n_datum, endian, shift);
 if (elements == 4)
 *dst[3]++ =
 read10in32(&buf, &rgbBuffer,
-   &n_datum, endian);
+   &n_datum, endian, shift);
 }
 n_datum = 0;
 for (i = 0; i < elements; i++)
-- 
1.7.10.4

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


[FFmpeg-devel] [PATCH] lavc/libopusenc: add support for specifying signal type

2018-06-16 Thread Takayuki 'January June' Suwa
---
 doc/encoders.texi   | 14 ++
 libavcodec/libopusenc.c | 11 +++
 2 files changed, 25 insertions(+)

diff --git a/doc/encoders.texi b/doc/encoders.texi
index 7b095754d1..6d0fc8e63e 100644
--- a/doc/encoders.texi
+++ b/doc/encoders.texi
@@ -986,6 +986,20 @@ If set to 0, disables the use of phase inversion for 
intensity stereo,
 improving the quality of mono downmixes, but slightly reducing normal stereo
 quality. The default is 1 (phase inversion enabled).
 
+@item signal (@emph{music} and @emph{speech})
+Set signal type. This option acts as a tuning bias for low bitrates encoding.
+Valid options are listed below:
+
+@table @samp
+@item auto (N.A.)
+No bias, automatic signal type detection (the default).
+
+@item voice (@emph{speech})
+Bias thresholds towards choosing LPC or Hybrid modes.
+
+@item music (@emph{music})
+Bias thresholds towards choosing MDCT modes.
+@end table
 @end table
 
 @anchor{libshine}
diff --git a/libavcodec/libopusenc.c b/libavcodec/libopusenc.c
index 4ae81b0bb2..21ce89d288 100644
--- a/libavcodec/libopusenc.c
+++ b/libavcodec/libopusenc.c
@@ -42,6 +42,7 @@ typedef struct LibopusEncOpts {
 #ifdef OPUS_SET_PHASE_INVERSION_DISABLED_REQUEST
 int apply_phase_inv;
 #endif
+int signal_type;
 } LibopusEncOpts;
 
 typedef struct LibopusEncContext {
@@ -165,6 +166,12 @@ static int libopus_configure_encoder(AVCodecContext 
*avctx, OpusMSEncoder *enc,
"Unable to set phase inversion: %s\n",
opus_strerror(ret));
 #endif
+ret = opus_multistream_encoder_ctl(enc,
+   OPUS_SET_SIGNAL(opts->signal_type));
+if (ret != OPUS_OK)
+av_log(avctx, AV_LOG_WARNING,
+   "Unable to set signal type: %s\n", opus_strerror(ret));
+
 return OPUS_OK;
 }
 
@@ -544,6 +551,10 @@ static const AVOption libopus_options[] = {
 #ifdef OPUS_SET_PHASE_INVERSION_DISABLED_REQUEST
 { "apply_phase_inv", "Apply intensity stereo phase inversion", 
OFFSET(apply_phase_inv), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, FLAGS },
 #endif
+{ "signal", "Signal type", 
OFFSET(signal_type),AV_OPT_TYPE_INT,   { .i64 = OPUS_AUTO }, OPUS_AUTO, 
OPUS_SIGNAL_MUSIC, FLAGS, "signal" },
+{ "auto",   "Automatic detection", 0, AV_OPT_TYPE_CONST, { 
.i64 = OPUS_AUTO }, 0, 0, FLAGS, "signal" },
+{ "voice",  "Tune for speech", 0, AV_OPT_TYPE_CONST, { 
.i64 = OPUS_SIGNAL_VOICE }, 0, 0, FLAGS, "signal" },
+{ "music",  "Tune for music",  0, AV_OPT_TYPE_CONST, { 
.i64 = OPUS_SIGNAL_MUSIC }, 0, 0, FLAGS, "signal" },
 { NULL },
 };
 
-- 
2.11.0

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


Re: [FFmpeg-devel] Fw: [PATCH] Refactor two near-identical clauses.

2018-06-16 Thread Michael Niedermayer
On Tue, Jun 12, 2018 at 12:53:20PM +0300, Shlomi Fish wrote:
> This message did not arrive to the list after three submissions.
> 
> Begin forwarded message:
> 
> Date: Tue, 12 Jun 2018 12:42:52 +0300
> From: Shlomi Fish 
> To: ffmpeg-devel@ffmpeg.org
> Cc: Shlomi Fish 
> Subject: [PATCH] Refactor two near-identical clauses.
> 
> 
> Placed under the Expat licence . All tests pass.
> ---
>  libavfilter/vf_weave.c | 33 ++---
>  1 file changed, 14 insertions(+), 19 deletions(-)
> 
> diff --git a/libavfilter/vf_weave.c b/libavfilter/vf_weave.c
> index 037f5d1cf2..be371201e1 100644
> --- a/libavfilter/vf_weave.c
> +++ b/libavfilter/vf_weave.c
> @@ -23,6 +23,7 @@
>  #include "libavutil/pixdesc.h"
>  #include "avfilter.h"
>  #include "internal.h"
> +#include 
>  
>  typedef struct WeaveContext {
>  const AVClass *class;
> @@ -84,6 +85,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
>  AVFilterLink *outlink = ctx->outputs[0];
>  AVFrame *out;
>  int i;
> +bool weave;
> +int field1, field2;
>  
>  if (!s->prev) {
>  s->prev = in;
> @@ -98,26 +101,18 @@ static int filter_frame(AVFilterLink *inlink, AVFrame 
> *in)
>  }
>  av_frame_copy_props(out, in);
>  
> +weave = (s->double_weave && !(inlink->frame_count_out & 1));
> +field1 = s->first_field * weave;
> +field2 = s->first_field * !weave;
>  for (i = 0; i < s->nb_planes; i++) {
> -if (s->double_weave && !(inlink->frame_count_out & 1)) {
> -av_image_copy_plane(out->data[i] + out->linesize[i] *
> s->first_field,

this seems to be corrupted by line breaks

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The greatest way to live with honor in this world is to be what we pretend
to be. -- Socrates


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


[FFmpeg-devel] [PATCH 1/4] lavu/frame: add mb_types side data

2018-06-16 Thread Ramiro Polla
---
 libavcodec/avcodec.h   |  4 
 libavcodec/mpegutils.c | 20 
 libavcodec/options_table.h |  1 +
 libavutil/frame.c  |  1 +
 libavutil/frame.h  |  9 +
 5 files changed, 35 insertions(+)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index c90166deb6..7fe4fc9347 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -929,6 +929,10 @@ typedef struct RcOverride{
  */
 #define AV_CODEC_FLAG2_SHOW_ALL   (1 << 22)
 /**
+ * Export macroblock types through frame side data
+ */
+#define AV_CODEC_FLAG2_EXPORT_MB_TYPES (1 << 27)
+/**
  * Export motion vectors through frame side data
  */
 #define AV_CODEC_FLAG2_EXPORT_MVS (1 << 28)
diff --git a/libavcodec/mpegutils.c b/libavcodec/mpegutils.c
index 3f94540616..0fbe5f8c9d 100644
--- a/libavcodec/mpegutils.c
+++ b/libavcodec/mpegutils.c
@@ -188,6 +188,26 @@ void ff_print_debug_info2(AVCodecContext *avctx, AVFrame 
*pict, uint8_t *mbskip_
 av_freep(&mvs);
 }
 
+if ((avctx->flags2 & AV_CODEC_FLAG2_EXPORT_MB_TYPES) && mbtype_table) {
+int size = (2 + mb_height * mb_width) * sizeof(uint32_t);
+int mb_x, mb_y;
+
+AVFrameSideData *sd;
+uint32_t *out;
+
+sd = av_frame_new_side_data(pict, AV_FRAME_DATA_MB_TYPES, size);
+if (!sd)
+return;
+
+out = (uint32_t *) sd->data;
+*out++ = mb_height;
+*out++ = mb_width;
+
+for (mb_y = 0; mb_y < mb_height; mb_y++)
+for (mb_x = 0; mb_x < mb_width; mb_x++)
+*out++ = mbtype_table[mb_x + mb_y * mb_stride];
+}
+
 /* TODO: export all the following to make them accessible for users (and 
filters) */
 if (avctx->hwaccel || !mbtype_table)
 return;
diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h
index 099261e168..25c84de321 100644
--- a/libavcodec/options_table.h
+++ b/libavcodec/options_table.h
@@ -76,6 +76,7 @@ static const AVOption avcodec_options[] = {
 {"export_mvs", "export motion vectors through frame side data", 0, 
AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG2_EXPORT_MVS}, INT_MIN, INT_MAX, V|D, 
"flags2"},
 {"skip_manual", "do not skip samples and export skip information as frame side 
data", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG2_SKIP_MANUAL}, INT_MIN, 
INT_MAX, V|D, "flags2"},
 {"ass_ro_flush_noop", "do not reset ASS ReadOrder field on flush", 0, 
AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG2_RO_FLUSH_NOOP}, INT_MIN, INT_MAX, 
S|D, "flags2"},
+{"export_mb_types", "export macroblock types through frame side data", 0, 
AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG2_EXPORT_MB_TYPES}, INT_MIN, INT_MAX, 
V|D, "flags2"},
 {"time_base", NULL, OFFSET(time_base), AV_OPT_TYPE_RATIONAL, {.dbl = 0}, 0, 
INT_MAX},
 {"g", "set the group of picture (GOP) size", OFFSET(gop_size), 
AV_OPT_TYPE_INT, {.i64 = 12 }, INT_MIN, INT_MAX, V|E},
 {"ar", "set audio sampling rate (in Hz)", OFFSET(sample_rate), 
AV_OPT_TYPE_INT, {.i64 = DEFAULT }, 0, INT_MAX, A|D|E},
diff --git a/libavutil/frame.c b/libavutil/frame.c
index deb9b6f334..577d4f6e6d 100644
--- a/libavutil/frame.c
+++ b/libavutil/frame.c
@@ -834,6 +834,7 @@ const char *av_frame_side_data_name(enum 
AVFrameSideDataType type)
 case AV_FRAME_DATA_ICC_PROFILE: return "ICC profile";
 case AV_FRAME_DATA_QP_TABLE_PROPERTIES: return "QP table 
properties";
 case AV_FRAME_DATA_QP_TABLE_DATA:   return "QP table data";
+case AV_FRAME_DATA_MB_TYPES:return "Macroblock types";
 }
 return NULL;
 }
diff --git a/libavutil/frame.h b/libavutil/frame.h
index 9d57d6ce66..ce1231b03b 100644
--- a/libavutil/frame.h
+++ b/libavutil/frame.h
@@ -158,6 +158,15 @@ enum AVFrameSideDataType {
  */
 AV_FRAME_DATA_QP_TABLE_DATA,
 #endif
+
+/**
+ * Macroblock types exported by some codecs (on demand through the
+ * export_mb_types flag set in the libavcodec AVCodecContext flags2 
option).
+ * The data is composed by a header consisting of uint32_t mb_height and
+ * uint32_t mb_width, followed by a uint32_t mb_types[mb_height][mb_width]
+ * array.
+ */
+AV_FRAME_DATA_MB_TYPES,
 };
 
 enum AVActiveFormatDescription {
-- 
2.11.0

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


Re: [FFmpeg-devel] [PATCH] mpegvideo_enc: add option to disable intra mbs in p frames

2018-06-16 Thread Ramiro Polla
On Sun, Jun 10, 2018 at 2:32 AM, Michael Niedermayer
 wrote:
> On Sat, Jun 09, 2018 at 05:09:13PM +0200, Ramiro Polla wrote:
>> On Thu, May 10, 2018 at 11:01 PM, Michael Niedermayer
>>  wrote:
>> > On Wed, May 09, 2018 at 08:44:25PM +0200, Ramiro Polla wrote:
>> >> This option prevents the mpv encoders from using intra macroblocks in
>> >> predictive frames.
>> >>
>> >> It is useful for glitch artists to generate input material. This option
>> >> allows them to split and merge two video files while maintaining fluid
>> >> motion from the second video without having intra macroblocks restoring
>> >> chunks of the first video.
>> >
>> > maybe a continuous variable like snows intra_penalty could achieve this
>> > too but give more flexibility in doing it also just partially if wanted
>>
>> I like this idea better. I wanted a simple way to be able to entirely
>> disable intra macroblocks, but "-intra_penalty max" could cause an
>> overflow, so I set the max value to INT_MAX/2.
>>
>> New patch attached.
>
> LGTM
>
> a fate test may also make sense

I sent a new patch set that includes a fate test.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 2/4] mpegutils: split debug function that prints mb_type so it may be used by ffprobe

2018-06-16 Thread Ramiro Polla
---
 libavcodec/mpegutils.c | 115 +
 libavcodec/mpegutils.h |   7 +++
 2 files changed, 76 insertions(+), 46 deletions(-)

diff --git a/libavcodec/mpegutils.c b/libavcodec/mpegutils.c
index 0fbe5f8c9d..12c2468797 100644
--- a/libavcodec/mpegutils.c
+++ b/libavcodec/mpegutils.c
@@ -100,6 +100,72 @@ void ff_draw_horiz_band(AVCodecContext *avctx,
 }
 }
 
+int ff_mb_type_str(char *str, int size, int mb_type)
+{
+char *ptr = str;
+
+if (size <= 0)
+return 0;
+
+if (--size <= 0)
+goto end;
+
+// Type & MV direction
+if (IS_PCM(mb_type))
+*ptr++ = 'P';
+else if (IS_INTRA(mb_type) && IS_ACPRED(mb_type))
+*ptr++ = 'A';
+else if (IS_INTRA4x4(mb_type))
+*ptr++ = 'i';
+else if (IS_INTRA16x16(mb_type))
+*ptr++ = 'I';
+else if (IS_DIRECT(mb_type) && IS_SKIP(mb_type))
+*ptr++ = 'd';
+else if (IS_DIRECT(mb_type))
+*ptr++ = 'D';
+else if (IS_GMC(mb_type) && IS_SKIP(mb_type))
+*ptr++ = 'g';
+else if (IS_GMC(mb_type))
+*ptr++ = 'G';
+else if (IS_SKIP(mb_type))
+*ptr++ = 'S';
+else if (!USES_LIST(mb_type, 1))
+*ptr++ = '>';
+else if (!USES_LIST(mb_type, 0))
+*ptr++ = '<';
+else {
+av_assert2(USES_LIST(mb_type, 0) && USES_LIST(mb_type, 1));
+*ptr++ = 'X';
+}
+
+if (--size <= 0)
+goto end;
+
+// segmentation
+if (IS_8X8(mb_type))
+*ptr++ = '+';
+else if (IS_16X8(mb_type))
+*ptr++ = '-';
+else if (IS_8X16(mb_type))
+*ptr++ = '|';
+else if (IS_INTRA(mb_type) || IS_16X16(mb_type))
+*ptr++ = ' ';
+else
+*ptr++ = '?';
+
+if (--size <= 0)
+goto end;
+
+if (IS_INTERLACED(mb_type))
+*ptr++ = '=';
+else
+*ptr++ = ' ';
+
+end:
+*ptr = '\0';
+return ptr - str;
+}
+
 void ff_print_debug_info2(AVCodecContext *avctx, AVFrame *pict, uint8_t 
*mbskip_table,
  uint32_t *mbtype_table, int8_t *qscale_table, int16_t 
(*motion_val[2])[2],
  int *low_delay,
@@ -231,52 +297,9 @@ void ff_print_debug_info2(AVCodecContext *avctx, AVFrame 
*pict, uint8_t *mbskip_
qscale_table[x + y * mb_stride]);
 }
 if (avctx->debug & FF_DEBUG_MB_TYPE) {
-int mb_type = mbtype_table[x + y * mb_stride];
-// Type & MV direction
-if (IS_PCM(mb_type))
-av_log(avctx, AV_LOG_DEBUG, "P");
-else if (IS_INTRA(mb_type) && IS_ACPRED(mb_type))
-av_log(avctx, AV_LOG_DEBUG, "A");
-else if (IS_INTRA4x4(mb_type))
-av_log(avctx, AV_LOG_DEBUG, "i");
-else if (IS_INTRA16x16(mb_type))
-av_log(avctx, AV_LOG_DEBUG, "I");
-else if (IS_DIRECT(mb_type) && IS_SKIP(mb_type))
-av_log(avctx, AV_LOG_DEBUG, "d");
-else if (IS_DIRECT(mb_type))
-av_log(avctx, AV_LOG_DEBUG, "D");
-else if (IS_GMC(mb_type) && IS_SKIP(mb_type))
-av_log(avctx, AV_LOG_DEBUG, "g");
-else if (IS_GMC(mb_type))
-av_log(avctx, AV_LOG_DEBUG, "G");
-else if (IS_SKIP(mb_type))
-av_log(avctx, AV_LOG_DEBUG, "S");
-else if (!USES_LIST(mb_type, 1))
-av_log(avctx, AV_LOG_DEBUG, ">");
-else if (!USES_LIST(mb_type, 0))
-av_log(avctx, AV_LOG_DEBUG, "<");
-else {
-av_assert2(USES_LIST(mb_type, 0) && USES_LIST(mb_type, 
1));
-av_log(avctx, AV_LOG_DEBUG, "X");
-}
-
-// segmentation
-if (IS_8X8(mb_type))
-av_log(avctx, AV_LOG_DEBUG, "+");
-else if (IS_16X8(mb_type))
-av_log(avctx, AV_LOG_DEBUG, "-");
-else if (IS_8X16(mb_type))
-av_log(avctx, AV_LOG_DEBUG, "|");
-else if (IS_INTRA(mb_type) || IS_16X16(mb_type))
-av_log(avctx, AV_LOG_DEBUG, " ");
-else
-av_log(avctx, AV_LOG_DEBUG, "?");
-
-
-if (IS_INTERLACED(mb_type))
-av_log(avctx, AV_LOG_DEBUG, "=");
-else
-av_log(avctx, AV_LOG_DEBUG, " ");
+char str[4];
+ff_mb_type_str(str, sizeof(str), mbtype_table[x + y * 
mb_stride]);
+av_log(avctx, AV_LOG_DEBUG, str);
 }
 }
 av_log(avctx, AV_LOG_DEBUG, "\n");
diff --git a/lib

[FFmpeg-devel] [PATCH 3/4] ffprobe: print mb_types frame side data

2018-06-16 Thread Ramiro Polla
---
 fftools/ffprobe.c | 19 +++
 1 file changed, 19 insertions(+)

diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
index 544786ec72..5bd14ebfdb 100644
--- a/fftools/ffprobe.c
+++ b/fftools/ffprobe.c
@@ -30,6 +30,7 @@
 
 #include "libavformat/avformat.h"
 #include "libavcodec/avcodec.h"
+#include "libavcodec/mpegutils.h"
 #include "libavutil/avassert.h"
 #include "libavutil/avstring.h"
 #include "libavutil/bprint.h"
@@ -,6 +2223,24 @@ static void show_frame(WriterContext *w, AVFrame *frame, 
AVStream *stream,
 AVContentLightMetadata *metadata = (AVContentLightMetadata 
*)sd->data;
 print_int("max_content", metadata->MaxCLL);
 print_int("max_average", metadata->MaxFALL);
+} else if (sd->type == AV_FRAME_DATA_MB_TYPES) {
+uint32_t *mb_types = (uint32_t *)sd->data;
+int mb_height = *mb_types++;
+int mb_width = *mb_types++;
+int size = mb_height * mb_width * 3 + 1;
+char *str = av_malloc(size);
+int mb_y, mb_x;
+print_int("mb_height", mb_height);
+print_int("mb_width", mb_width);
+if (str) {
+char *ptr = str;
+const char *end = str + size;
+for (mb_y = 0; mb_y < mb_height; mb_y++)
+for (mb_x = 0; mb_x < mb_width; mb_x++)
+ptr += ff_mb_type_str(ptr, end - str, *mb_types++);
+print_str("mb_types", str);
+av_free(str);
+}
 } else if (sd->type == AV_FRAME_DATA_ICC_PROFILE) {
 AVDictionaryEntry *tag = av_dict_get(sd->metadata, "name", 
NULL, AV_DICT_MATCH_CASE);
 if (tag)
-- 
2.11.0

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


[FFmpeg-devel] [PATCH 4/4] mpegvideo_enc: add intra_penalty option for p frames

2018-06-16 Thread Ramiro Polla
This option allows more control over the use of intra macroblocks in
predictive frames.

By using '-intra_penalty max', intra macroblocks are never used in
predictive frames.

It is useful for glitch artists to generate input material. This option
allows them to split and merge two video files while maintaining fluid
motion from the second video without having intra macroblocks restoring
chunks of the first video.
---
 libavcodec/motion_est.c   | 10 
 libavcodec/motion_est.h   |  2 +-
 libavcodec/mpegvideo.h|  3 +++
 libavcodec/mpegvideo_enc.c|  6 ++---
 libavcodec/svq1enc.c  |  2 +-
 tests/fate-run.sh |  8 +++
 tests/fate/mpeg4.mak  |  5 
 tests/fate/seek.mak   |  1 +
 tests/fate/vcodec.mak |  4 
 tests/ref/fate/mpeg4-nopimb   |  1 +
 tests/ref/seek/vsynth_lena-mpeg4-nopimb   | 40 +++
 tests/ref/vsynth/vsynth1-mpeg4-nopimb |  4 
 tests/ref/vsynth/vsynth2-mpeg4-nopimb |  4 
 tests/ref/vsynth/vsynth3-mpeg4-nopimb |  4 
 tests/ref/vsynth/vsynth_lena-mpeg4-nopimb |  4 
 15 files changed, 88 insertions(+), 10 deletions(-)
 create mode 100644 tests/ref/fate/mpeg4-nopimb
 create mode 100644 tests/ref/seek/vsynth_lena-mpeg4-nopimb
 create mode 100644 tests/ref/vsynth/vsynth1-mpeg4-nopimb
 create mode 100644 tests/ref/vsynth/vsynth2-mpeg4-nopimb
 create mode 100644 tests/ref/vsynth/vsynth3-mpeg4-nopimb
 create mode 100644 tests/ref/vsynth/vsynth_lena-mpeg4-nopimb

diff --git a/libavcodec/motion_est.c b/libavcodec/motion_est.c
index 8b5ce2117a..fa750e39ec 100644
--- a/libavcodec/motion_est.c
+++ b/libavcodec/motion_est.c
@@ -971,7 +971,7 @@ void ff_estimate_p_frame_motion(MpegEncContext * s,
 int i_score= varc-500+(s->lambda2>>FF_LAMBDA_SHIFT)*20;
 c->scene_change_score+= ff_sqrt(p_score) - ff_sqrt(i_score);
 
-if (vard*2 + 200*256 > varc)
+if (vard*2 + 200*256 > varc && !s->intra_penalty)
 mb_type|= CANDIDATE_MB_TYPE_INTRA;
 if (varc*2 + 200*256 > vard || s->qscale > 24){
 //if (varc*2 + 200*256 + 50*(s->lambda2>>FF_LAMBDA_SHIFT) > vard){
@@ -1040,7 +1040,7 @@ void ff_estimate_p_frame_motion(MpegEncContext * s,
 
 intra_score= s->mecc.mb_cmp[0](s, c->scratchpad, pix, s->linesize, 
16);
 }
-intra_score += c->mb_penalty_factor*16;
+intra_score += c->mb_penalty_factor*16 + s->intra_penalty;
 
 if(intra_score < dmin){
 mb_type= CANDIDATE_MB_TYPE_INTRA;
@@ -1648,7 +1648,7 @@ int ff_get_best_fcode(MpegEncContext * s, int16_t 
(*mv_table)[2], int type)
 }
 }
 
-void ff_fix_long_p_mvs(MpegEncContext * s)
+void ff_fix_long_p_mvs(MpegEncContext * s, int type)
 {
 MotionEstContext * const c= &s->me;
 const int f_code= s->f_code;
@@ -1682,8 +1682,8 @@ void ff_fix_long_p_mvs(MpegEncContext * s)
 if(   mx >=range || mx <-range
|| my >=range || my <-range){
 s->mb_type[i] &= ~CANDIDATE_MB_TYPE_INTER4V;
-s->mb_type[i] |= CANDIDATE_MB_TYPE_INTRA;
-s->current_picture.mb_type[i] = 
CANDIDATE_MB_TYPE_INTRA;
+s->mb_type[i] |= type;
+s->current_picture.mb_type[i] = type;
 }
 }
 }
diff --git a/libavcodec/motion_est.h b/libavcodec/motion_est.h
index 3b3a8d7341..817220f340 100644
--- a/libavcodec/motion_est.h
+++ b/libavcodec/motion_est.h
@@ -127,7 +127,7 @@ int ff_get_mb_score(struct MpegEncContext *s, int mx, int 
my, int src_index,
 int ff_get_best_fcode(struct MpegEncContext *s,
   int16_t (*mv_table)[2], int type);
 
-void ff_fix_long_p_mvs(struct MpegEncContext *s);
+void ff_fix_long_p_mvs(struct MpegEncContext *s, int type);
 void ff_fix_long_mvs(struct MpegEncContext *s, uint8_t *field_select_table,
  int field_select, int16_t (*mv_table)[2], int f_code,
  int type, int truncate);
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index e16deb64e7..7eda962ba7 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -577,6 +577,8 @@ typedef struct MpegEncContext {
 
 int scenechange_threshold;
 int noise_reduction;
+
+int intra_penalty;
 } MpegEncContext;
 
 /* mpegvideo_enc common options */
@@ -661,6 +663,7 @@ FF_MPV_OPT_CMP_FUNC, \
 {"ps", "RTP payload size in bytes", 
FF_MPV_OFFSET(rtp_payload_size), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, 
INT_MAX, FF_MPV_OPT_FLAGS }, \
 {"mepc", "Motion estimation bitrate penalty compensation (1.0 = 256)", 
FF_MPV_OFFSET(me_penalty_compensation), AV_OPT_TYPE_INT, {.i64 = 256 }, 
INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \
 {"mepre", "pre motion estima

Re: [FFmpeg-devel] [PATCH] avformat/movenc: read track title from correct key

2018-06-16 Thread Gyan Doshi



On 17-06-2018 01:23 AM, John Stebbins wrote:

On 06/16/2018 03:49 AM, Gyan Doshi wrote:

Activates functionality added a few years ago.

Regards,
Gyan



FYI, HandBrake has been using the "handler" metadata key since 2014 when I 
added this code.  And it was completely self-consistent (since it was the only occurrence 
of usage of this key) until Hendrik Leppkes added support for reading the handler name in
2015 but used handler_name metadata key instead.  I'm not against the change.  
Just need to make a note to myself to fix HandBrake when we update to a version 
of ffmpeg with the change.


I can just use an if-else to check for both, giving priority to 'handler'.

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