Re: [FFmpeg-devel] [PATCH v2 0/2] AltiVec/VSX fixes in swscale

2019-10-03 Thread Lauri Kasanen
On Tue, 1 Oct 2019 18:26:20 +0300
Lauri Kasanen  wrote:

> Hi,
>
> I'll apply these in a couple days if no objections. Works ok in my
> tests.

Applying.

- Lauri
___
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] cuviddec: Properly check capability for chroma format

2019-10-03 Thread Holy Wu
Chroma format was not checked properly as it's always set to
cudaVideoChromaFormat_420 regardless of the input pixel format.


0001-cuviddec-Properly-check-capability-for-chroma-format.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".

Re: [FFmpeg-devel] [PATCH] avformat/matroskadec: Fix demuxing ProRes

2019-10-03 Thread James Almer
On 9/28/2019 2:54 PM, Andreas Rheinhardt wrote:
> The structure of a ProRes frame in mov/mp4 is that of a typical atom:
> First a 32 bit BE size field, then a tag detailling the content. Said
> size field includes the eight bytes of the atom header.
> 
> This header is actually redundant, as the size of the atom is already
> known from the containing atom. It is therefore stripped away when muxed
> into Matroska and so the Matroska demuxer has to recreate upon demuxing.
> But it did not account for the fact that the size field includes the
> size of the header and this can lead to problems when a decoder uses the
> in-band size field.
> 
> Fixes ticket #8210.
> 
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavformat/matroskadec.c | 9 +
>  1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
> index 10c398856b..a5f120b54d 100644
> --- a/libavformat/matroskadec.c
> +++ b/libavformat/matroskadec.c
> @@ -3280,15 +3280,16 @@ static int matroska_parse_prores(MatroskaTrack 
> *track, uint8_t *src,
>  int dstlen = *size;
>  
>  if (AV_RB32([4]) != MKBETAG('i', 'c', 'p', 'f')) {
> -dst = av_malloc(dstlen + 8 + AV_INPUT_BUFFER_PADDING_SIZE);
> +dstlen += 8;
> +
> +dst = av_malloc(dstlen + AV_INPUT_BUFFER_PADDING_SIZE);
>  if (!dst)
>  return AVERROR(ENOMEM);
>  
>  AV_WB32(dst, dstlen);
>  AV_WB32(dst + 4, MKBETAG('i', 'c', 'p', 'f'));
> -memcpy(dst + 8, src, dstlen);
> -memset(dst + 8 + dstlen, 0, AV_INPUT_BUFFER_PADDING_SIZE);
> -dstlen += 8;
> +memcpy(dst + 8, src, dstlen - 8);
> +memset(dst + dstlen, 0, AV_INPUT_BUFFER_PADDING_SIZE);
>  }
>  
>  *pdst = dst;

Pushed, 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] avformat/matroskaenc: don't rescale mastering metadata values

2019-10-03 Thread James Almer
On 10/3/2019 9:26 PM, Carl Eugen Hoyos wrote:
> Am Fr., 4. Okt. 2019 um 01:59 Uhr schrieb James Almer :
>>
>> The rescaling can be done at muxing/encoding time, for formats that require 
>> it.
> 
> Doesn't this need a micro version bump?

No. The way these readers set the values is irrelevant. Writers will
either convert them to floats (Matroska, where rescaling is ultimately
unneeded), or effectively rescale them themselves
(h264/h465/vp9/av1/mp4, where it's required).

See 00fd38f1846a3c889b6ec645107eaea415b99840.

> 
> 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 17/18] cbs_h265: Add functions to turn HDR metadata into SEI

2019-10-03 Thread James Almer
On 10/2/2019 8:04 PM, Mark Thompson wrote:
> ---
> With intent to add some sort of support for this in H.265 metadata, though 
> it's not in this set.
> 
> Is there any thought on what a human-usable text serialisation of 
> AVMasteringDisplayMetadata should look like?  Ideally it wants to be 
> something which would require no escaping when using it on the command-line.  
> (This is relevant to video filters as well.)
> 
> 
>  libavcodec/Makefile   |  2 +-
>  libavcodec/cbs_h265.c | 94 +++
>  libavcodec/cbs_h265.h | 18 +
>  3 files changed, 113 insertions(+), 1 deletion(-)
>  create mode 100644 libavcodec/cbs_h265.c
> 
> diff --git a/libavcodec/Makefile b/libavcodec/Makefile
> index 86e512b605..d383d4a539 100644
> --- a/libavcodec/Makefile
> +++ b/libavcodec/Makefile
> @@ -65,7 +65,7 @@ OBJS-$(CONFIG_CABAC)   += cabac.o
>  OBJS-$(CONFIG_CBS) += cbs.o
>  OBJS-$(CONFIG_CBS_AV1) += cbs_av1.o
>  OBJS-$(CONFIG_CBS_H264)+= cbs_h2645.o cbs_h264.o 
> h2645_parse.o
> -OBJS-$(CONFIG_CBS_H265)+= cbs_h2645.o h2645_parse.o
> +OBJS-$(CONFIG_CBS_H265)+= cbs_h2645.o cbs_h265.o 
> h2645_parse.o
>  OBJS-$(CONFIG_CBS_JPEG)+= cbs_jpeg.o
>  OBJS-$(CONFIG_CBS_MPEG2)   += cbs_mpeg2.o
>  OBJS-$(CONFIG_CBS_VP9) += cbs_vp9.o
> diff --git a/libavcodec/cbs_h265.c b/libavcodec/cbs_h265.c
> new file mode 100644
> index 00..b4850bd565
> --- /dev/null
> +++ b/libavcodec/cbs_h265.c
> @@ -0,0 +1,94 @@
> +/*
> + * This file is part of FFmpeg.
> + *
> + * FFmpeg is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * FFmpeg is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with FFmpeg; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 
> USA
> + */
> +
> +#include "libavutil/mathematics.h"
> +#include "libavutil/mastering_display_metadata.h"
> +
> +#include "cbs_h265.h"
> +
> +
> +static unsigned int rescale(AVRational value, unsigned int max)
> +{
> +int64_t scaled = av_rescale(max, value.num, value.den);
> +return av_clip(scaled, 0, max);
> +}
> +
> +void 
> ff_cbs_h265_fill_sei_mastering_display(H265RawSEIMasteringDisplayColourVolume 
> *mdcv,
> +const AVMasteringDisplayMetadata 
> *mdm)
> +{
> +memset(mdcv, 0, sizeof(*mdcv));
> +
> +if (mdm->has_primaries) {
> +// The values in the metadata are rationals in the range [0, 1],
> +// while the SEI structure contains fixed-point values with an
> +// increment of 0.2.  So, scale up by 5 to convert between
> +// them.
> +
> +for (int a = 0; a < 3; a++) {
> +// The metadata stores this in RGB order, but the SEI wants it
> +// in GBR order.
> +int b = (a + 1) % 3;
> +mdcv->display_primaries_x[a] =
> +rescale(mdm->display_primaries[b][0], 5);
> +mdcv->display_primaries_y[a] =
> +rescale(mdm->display_primaries[b][1], 5);
> +}
> +
> +mdcv->white_point_x = rescale(mdm->white_point[0], 5);
> +mdcv->white_point_y = rescale(mdm->white_point[1], 5);
> +}
> +
> +if (mdm->has_luminance) {
> +// Metadata are rational values in candelas per square metre, SEI
> +// contains fixed point in units of 0.0001 candelas per square
> +// metre.  So, scale up by 1 to convert between them.
> +
> +mdcv->max_display_mastering_luminance =
> +rescale(mdm->max_luminance, 1);
> +mdcv->min_display_mastering_luminance =
> +rescale(mdm->min_luminance, 1);

I don't think 1.0 is the max value for these two. The spec doesn't state
a range. I for example have a sample using WebM's Mastering Metadata
elements (also based on the CIE 1931 definition), and max_luminance is
1000.0

If i were to re-encode it to h265 using vaapi after patch 18/18 from
this set, that value would get clipped.

> +
> +// The spec has a hard requirement that min is less than the max,
> +// and the SEI-writing code enforces that.
> +if (!(mdcv->min_display_mastering_luminance <
> +  mdcv->max_display_mastering_luminance)) {
> +if (mdcv->max_display_mastering_luminance == 1)
> +mdcv->min_display_mastering_luminance =
> +  

Re: [FFmpeg-devel] [PATCH v3] avformat/movenc: split empty text sample when duration overflow

2019-10-03 Thread Jun Li
On Wed, Oct 2, 2019 at 3:42 PM Jun Li  wrote:

>
>
> On Wed, Oct 2, 2019 at 3:22 PM Carl Eugen Hoyos 
> wrote:
>
>> Am Mi., 2. Okt. 2019 um 02:21 Uhr schrieb Jun Li :
>> >
>> > On Tue, Oct 1, 2019 at 4:19 AM Carl Eugen Hoyos 
>> wrote:
>> >
>> > > Am Di., 10. Sept. 2019 um 21:12 Uhr schrieb Jun Li <
>> junli1...@gmail.com>:
>> > > >
>> > > > Fix #7637
>> > > > One empty/end sample is created and inserted between two caption
>> lines
>> > > when there is a gap.
>> > > > This patch is to split the sample into multiple ones when its
>> duration
>> > > is too long (>= INT_MAX).
>> > > > ---
>> > > >  libavformat/movenc.c  | 24
>> ++-
>> > > >  tests/fate/subtitles.mak  |  6 +
>> > > >  tests/ref/fate/binsub-movtextenc-long-dur |  1 +
>> > > >  .../fate/binsub-movtextenc-long-dur-timebase  |  1 +
>> > > >  4 files changed, 26 insertions(+), 6 deletions(-)
>> > > >  create mode 100644 tests/ref/fate/binsub-movtextenc-long-dur
>> > > >  create mode 100644
>> tests/ref/fate/binsub-movtextenc-long-dur-timebase
>> > > >
>> > > > diff --git a/libavformat/movenc.c b/libavformat/movenc.c
>> > > > index edddfeeb00..aeb7de351f 100644
>> > > > --- a/libavformat/movenc.c
>> > > > +++ b/libavformat/movenc.c
>> > > > @@ -5746,7 +5746,8 @@ static int mov_write_packet(AVFormatContext
>> *s,
>> > > AVPacket *pkt)
>> > > >   *
>> > > >   * 2) For each subtitle track, check if the current
>> packet's
>> > > >   * dts is past the duration of the last subtitle sample. If
>> > > > - * so, we now need to write an end sample for that
>> subtitle.
>> > > > + * so, we now need to write one or multiple end samples for
>> > > > + * that subtitle.
>> > > >   *
>> > > >   * This must be done conditionally to allow for subtitles
>> that
>> > > >   * immediately replace each other, in which case an end
>> sample
>> > > > @@ -5760,11 +5761,22 @@ static int mov_write_packet(AVFormatContext
>> *s,
>> > > AVPacket *pkt)
>> > > >  int ret;
>> > > >
>> > > >  if (trk->par->codec_id == AV_CODEC_ID_MOV_TEXT &&
>> > > > -trk->track_duration < pkt->dts &&
>> > > > -(trk->entry == 0 ||
>> !trk->last_sample_is_subtitle_end))
>> > > {
>> > > > -ret = mov_write_subtitle_end_packet(s, i,
>> > > trk->track_duration);
>> > > > -if (ret < 0) return ret;
>> > > > -trk->last_sample_is_subtitle_end = 1;
>> > > > +trk->track_duration < pkt->dts) {
>> > > > +int max_duration = INT_MAX - 1;
>> > > > +if (trk->entry == 0 ||
>> > > !trk->last_sample_is_subtitle_end) {
>> > > > +ret = mov_write_subtitle_end_packet(s, i,
>> > > trk->track_duration);
>> > >
>> > > > +if (ret < 0) return ret;
>> > >
>> > > > +trk->last_sample_is_subtitle_end = 1;
>> > > > +}
>> > > > +if (trk->last_sample_is_subtitle_end &&
>> > > > +pkt->dts - trk->track_duration > max_duration)
>> {
>> > > > +int64_t dts = trk->track_duration;
>> > > > +while(pkt->dts - dts > max_duration) {
>> > > > +dts += max_duration;
>> > > > +ret = mov_write_subtitle_end_packet(s, i,
>> dts);
>> > >
>> > > > +if (ret < 0) return ret;
>> > >
>> > > Please add two CRLFs and I am threatening to push this.
>> > >
>> > > 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".
>> >
>> >
>> > Thanks Carl for review. Code is updated as follows.
>>
>> git returns an error message ("corrupt line") when I try to
>> commit this patch.
>>
>> Thanks for your time, I rebased the code and re-generated a patch,
> together with the fate test file, in the attachments.
> Could you please help do a re-try ? Thanks.
>

Hi Carl, could you please help to try again ? It should work now. Thanks in
advance!


> -Jun
>
>
>> 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] avformat/matroskaenc: don't rescale mastering metadata values

2019-10-03 Thread Carl Eugen Hoyos
Am Fr., 4. Okt. 2019 um 01:59 Uhr schrieb James Almer :
>
> The rescaling can be done at muxing/encoding time, for formats that require 
> it.

Doesn't this need a micro version bump?

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] [PATCH] avformat/matroskaenc: don't rescale mastering metadata values

2019-10-03 Thread James Almer
The rescaling can be done at muxing/encoding time, for formats that require it.

Signed-off-by: James Almer 
---
 libavformat/matroskadec.c | 33 ++---
 1 file changed, 10 insertions(+), 23 deletions(-)

diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index 10c398856b..865f265c37 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -2116,9 +2116,6 @@ static int mkv_parse_video_color(AVStream *st, const 
MatroskaTrack *track) {
 }
 
 if (has_mastering_primaries || has_mastering_luminance) {
-// Use similar rationals as other standards.
-const int chroma_den = 5;
-const int luma_den = 1;
 AVMasteringDisplayMetadata *metadata =
 (AVMasteringDisplayMetadata*) av_stream_new_side_data(
 st, AV_PKT_DATA_MASTERING_DISPLAY_METADATA,
@@ -2128,29 +2125,19 @@ static int mkv_parse_video_color(AVStream *st, const 
MatroskaTrack *track) {
 }
 memset(metadata, 0, sizeof(AVMasteringDisplayMetadata));
 if (has_mastering_primaries) {
-metadata->display_primaries[0][0] = av_make_q(
-round(mastering_meta->r_x * chroma_den), chroma_den);
-metadata->display_primaries[0][1] = av_make_q(
-round(mastering_meta->r_y * chroma_den), chroma_den);
-metadata->display_primaries[1][0] = av_make_q(
-round(mastering_meta->g_x * chroma_den), chroma_den);
-metadata->display_primaries[1][1] = av_make_q(
-round(mastering_meta->g_y * chroma_den), chroma_den);
-metadata->display_primaries[2][0] = av_make_q(
-round(mastering_meta->b_x * chroma_den), chroma_den);
-metadata->display_primaries[2][1] = av_make_q(
-round(mastering_meta->b_y * chroma_den), chroma_den);
-metadata->white_point[0] = av_make_q(
-round(mastering_meta->white_x * chroma_den), chroma_den);
-metadata->white_point[1] = av_make_q(
-round(mastering_meta->white_y * chroma_den), chroma_den);
+metadata->display_primaries[0][0] = av_d2q(mastering_meta->r_x, 
INT_MAX);
+metadata->display_primaries[0][1] = av_d2q(mastering_meta->r_y, 
INT_MAX);
+metadata->display_primaries[1][0] = av_d2q(mastering_meta->g_x, 
INT_MAX);
+metadata->display_primaries[1][1] = av_d2q(mastering_meta->g_y, 
INT_MAX);
+metadata->display_primaries[2][0] = av_d2q(mastering_meta->b_x, 
INT_MAX);
+metadata->display_primaries[2][1] = av_d2q(mastering_meta->b_y, 
INT_MAX);
+metadata->white_point[0] = av_d2q(mastering_meta->white_x, 
INT_MAX);
+metadata->white_point[1] = av_d2q(mastering_meta->white_y, 
INT_MAX);
 metadata->has_primaries = 1;
 }
 if (has_mastering_luminance) {
-metadata->max_luminance = av_make_q(
-round(mastering_meta->max_luminance * luma_den), luma_den);
-metadata->min_luminance = av_make_q(
-round(mastering_meta->min_luminance * luma_den), luma_den);
+metadata->max_luminance = av_d2q(mastering_meta->max_luminance, 
INT_MAX);
+metadata->min_luminance = av_d2q(mastering_meta->min_luminance, 
INT_MAX);
 metadata->has_luminance = 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".

Re: [FFmpeg-devel] [PATCH] avcodec/tiff: add limited support for ReferenceBlackWhite and YCbCrCoefficients tags

2019-10-03 Thread James Almer
On 10/3/2019 3:42 PM, Skakov Pavel wrote:
> Add support for properly handling PC/TV ranges and Rec601/Rec709 color
> spaces.
> Example for PC range YUV, compare to ImageMagick decoding:
> https://samples.ffmpeg.org/image-samples/dscf0013.tif
> 
> 0001-avcodec-tiff-add-limited-support-for-ReferenceBlackW.patch
> 
> From 5e24edbf73f3a897fd203e36963e9cf5db5e688d Mon Sep 17 00:00:00 2001
> From: Pavel Skakov 
> Date: Thu, 3 Oct 2019 21:28:10 +0300
> Subject: [PATCH] avcodec/tiff: add limited support for ReferenceBlackWhite and
>  YCbCrCoefficients tags
> 
> Signed-off-by: Pavel Skakov 
> ---
>  libavcodec/tiff.c  | 74 
> --
>  tests/ref/fate/exif-image-tiff |  2 +-
>  2 files changed, 73 insertions(+), 3 deletions(-)
> 
> diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
> index 8b39ca1ebc..90215fce09 100644
> --- a/libavcodec/tiff.c
> +++ b/libavcodec/tiff.c
> @@ -1441,12 +1441,16 @@ static int tiff_decode_tag(TiffContext *s, AVFrame 
> *frame)
>  break;
>  case TIFF_PHOTOMETRIC:
>  switch (value) {
> +case TIFF_PHOTOMETRIC_YCBCR:
> +s->avctx->colorspace = AVCOL_SPC_BT470BG;
> +// fallthrough
> +case TIFF_PHOTOMETRIC_RGB:
> +s->avctx->color_range = AVCOL_RANGE_JPEG;
> +// fallthrough
>  case TIFF_PHOTOMETRIC_WHITE_IS_ZERO:
>  case TIFF_PHOTOMETRIC_BLACK_IS_ZERO:
> -case TIFF_PHOTOMETRIC_RGB:
>  case TIFF_PHOTOMETRIC_PALETTE:
>  case TIFF_PHOTOMETRIC_SEPARATED:
> -case TIFF_PHOTOMETRIC_YCBCR:
>  case TIFF_PHOTOMETRIC_CFA:
>  case TIFF_PHOTOMETRIC_LINEAR_RAW: // Used by DNG images
>  s->photometric = value;
> @@ -1519,6 +1523,72 @@ static int tiff_decode_tag(TiffContext *s, AVFrame 
> *frame)
>  }
>  }
>  break;
> +case TIFF_YCBCR_COEFFICIENTS:
> +if (s->photometric == TIFF_PHOTOMETRIC_YCBCR)
> +if (count != 3 || type != TIFF_RATIONAL) {
> +av_log(s->avctx, AV_LOG_ERROR, "YCbCrCoefficients are 
> invalid\n");
> +return AVERROR_INVALIDDATA;
> +} else {
> +// LibTIFF handles rational values by converting them 
> to/from floats, so we do the same in tests for equality
> +float coef[3];

You should use AVRationals instead. It's ideal seeing the way these
values are coded in the bitstream.

See libavutil/rational.h

> +for (i = 0; i < 3; i++) {
> +unsigned num = ff_tget(>gb, TIFF_LONG, s->le);
> +unsigned den = ff_tget(>gb, TIFF_LONG, s->le);
> +if (!den) {
> +av_log(s->avctx, AV_LOG_ERROR, "YCbCrCoefficients 
> divisor is zero\n");
> +return AVERROR_INVALIDDATA;
> +}
> +coef[i] = (float)num/den;

coef[i] = av_make_q(num, den);

> +}
> +if (coef[0] == 0.2125f && coef[1] == 0.7154f && coef[2] == 
> 0.0721f)

if (av_cmp_q(coef[0], (AVRational) { 17, 80 }) && ...)

> +s->avctx->colorspace = AVCOL_SPC_BT709;
> +else if (coef[0] != 0.299f || coef[1] != 0.587f || coef[2] 
> != 0.114f) {
> +av_log(s->avctx, AV_LOG_WARNING, "Unrecognized 
> YCbCrCoefficients values: %.4f %.4f %.4f\n", coef[0], coef[1], coef[2]);

av_log(... "%.4f %.4f %.4f\n", av_q2d(coef[0]), av_q2d(coef[1]),
av_q2d(coef[2]));

etc.

> +s->avctx->colorspace = AVCOL_SPC_UNSPECIFIED;
> +}
> +}
> +break;
> +case TIFF_REFERENCE_BW:
> +if (s->photometric == TIFF_PHOTOMETRIC_YCBCR || s->photometric == 
> TIFF_PHOTOMETRIC_RGB)
> +if (count != 6 || type != TIFF_RATIONAL) {
> +av_log(s->avctx, AV_LOG_ERROR, "ReferenceBlackWhite is 
> invalid\n");
> +return AVERROR_INVALIDDATA;
> +} else {
> +unsigned bpp = s->bpp/s->bppcount;
> +unsigned mul = 1 << (bpp - 8);
> +float max_val = (1 << bpp) - 1;
> +float coef[6];
> +for (i = 0; i < 6; i++) {
> +unsigned num = ff_tget(>gb, TIFF_LONG, s->le);
> +unsigned den = ff_tget(>gb, TIFF_LONG, s->le);
> +if (!den) {
> +av_log(s->avctx, AV_LOG_ERROR, "ReferenceBlackWhite 
> divisor is zero\n");
> +return AVERROR_INVALIDDATA;
> +}
> +coef[i] = (float)num/den;
> +}
> +if (s->photometric == TIFF_PHOTOMETRIC_YCBCR) {
> +if (!coef[0] && coef[1] == max_val && coef[2] == 
> (max_val + 1)/2 && coef[3] == max_val && coef[4] == coef[2] && coef[5] == 
> coef[3])
> +s->avctx->color_range = AVCOL_RANGE_JPEG;
> +// NOTE: 

Re: [FFmpeg-devel] [PATCH] avcodec/tiff: add limited support for ReferenceBlackWhite and YCbCrCoefficients tags

2019-10-03 Thread Carl Eugen Hoyos
Am Do., 3. Okt. 2019 um 20:50 Uhr schrieb Skakov Pavel :
>
> Add support for properly handling PC/TV ranges and Rec601/Rec709 color spaces.

Can't this be implemented without using floats?

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] Fix gas-preprocessor to translate .rdatasections for armasm and armasm64

2019-10-03 Thread Michael Niedermayer
On Thu, Oct 03, 2019 at 01:20:25PM +0200, Lukas Fellechner wrote:
> > > Compiling FFmpeg with gas-preprocessor.pl and armasm or armasm64 fails 
> > > since FFmpeg 4.2.
> > > 
> > > New .rdata sections have been added in ARM NEON assembly code (e.g. 
> > > libavutil/aarch64/asm.S).
> > > This fix allows gas-preprocessor to translate those sections to armasm 
> > > compatible code.
> > > 
> > > Gas-preprocessor is maintained in 
> > > https://github.com/FFmpeg/gas-preprocessor
> > > 
> > > ---
> > > gas-preprocessor.pl | 1 +
> > > 1 file changed, 1 insertion(+)
> > 
> > A fix for this issue, and a lot of other fixes as well not present in the 
> > repo referenced above, exist at 
> > https://git.libav.org/?p=gas-preprocessor.git;a=summary.
> > 
> > // Martin
> 
> Thank you, indeed the updated preprocessor fixes the build for me. 
> Maybe the changes form libav should be merged into the FFmpeg repository then?

I already merged them before martin replied when i saw your patch 
i just didnt reply because of migraine ...

Thx

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

Why not whip the teacher when the pupil misbehaves? -- Diogenes of Sinope


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 3/3] avformat/aiffenc: Remove wrong and redundant check

2019-10-03 Thread Michael Niedermayer
On Wed, Oct 02, 2019 at 09:09:28AM +0200, Matthieu Bouron wrote:
> On Wed, Oct 02, 2019 at 06:04:12AM +0200, Andreas Rheinhardt wrote:
> > The check "if (!pb->seekable & AVIO_SEEKABLE_NORMAL)" is wrong, because
> > ! has higher precendence than &. But it is also redundant, because this
> > part of the code is only ever reached when the AVIO_SEEKABLE_NORMAL flag
> > is set for pb. So simply remove the check.
> > 
> > Signed-off-by: Andreas Rheinhardt 
> > ---
> >  libavformat/aiffenc.c | 3 ---
> >  1 file changed, 3 deletions(-)
> > 
> > diff --git a/libavformat/aiffenc.c b/libavformat/aiffenc.c
> > index 0b837cd264..d09c9afb95 100644
> > --- a/libavformat/aiffenc.c
> > +++ b/libavformat/aiffenc.c
> > @@ -49,9 +49,6 @@ static int put_id3v2_tags(AVFormatContext *s, 
> > AIFFOutputContext *aiff)
> >  AVIOContext *pb = s->pb;
> >  AVPacketList *pict_list = aiff->pict_list;
> >  
> > -if (!pb->seekable & AVIO_SEEKABLE_NORMAL)
> > -return 0;
> > -
> >  if (!s->metadata && !aiff->pict_list)
> >  return 0;
> >  
> > -- 
> > 2.21.0
> 
> LGTM.

will apply

thx

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

"You are 36 times more likely to die in a bathtub than at the hands of a
terrorist. Also, you are 2.5 times more likely to become a president and
2 times more likely to become an astronaut, than to die in a terrorist
attack." -- Thoughty2



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] avformat/aiffenc: Fix potential memleak upon failure

2019-10-03 Thread Michael Niedermayer
On Wed, Oct 02, 2019 at 09:10:18AM +0200, Matthieu Bouron wrote:
> On Wed, Oct 02, 2019 at 06:04:11AM +0200, Andreas Rheinhardt wrote:
> > Signed-off-by: Andreas Rheinhardt 
> > ---
> >  libavformat/aiffenc.c | 7 ---
> >  1 file changed, 4 insertions(+), 3 deletions(-)
> > 
> > diff --git a/libavformat/aiffenc.c b/libavformat/aiffenc.c
> > index dd8b8c3d01..0b837cd264 100644
> > --- a/libavformat/aiffenc.c
> > +++ b/libavformat/aiffenc.c
> > @@ -235,7 +235,7 @@ static int aiff_write_packet(AVFormatContext *s, 
> > AVPacket *pkt)
> >  
> >  static int aiff_write_trailer(AVFormatContext *s)
> >  {
> > -int ret;
> > +int ret = 0;
> >  AVIOContext *pb = s->pb;
> >  AIFFOutputContext *aiff = s->priv_data;
> >  AVCodecParameters *par = s->streams[aiff->audio_stream_idx]->codecpar;
> > @@ -263,7 +263,7 @@ static int aiff_write_trailer(AVFormatContext *s)
> >  /* Write ID3 tags */
> >  if (aiff->write_id3v2)
> >  if ((ret = put_id3v2_tags(s, aiff)) < 0)
> > -return ret;
> > +goto free;
> >  
> >  /* File length */
> >  file_size = avio_tell(pb);
> > @@ -273,9 +273,10 @@ static int aiff_write_trailer(AVFormatContext *s)
> >  avio_flush(pb);
> >  }
> >  
> > +free:
> >  ff_packet_list_free(>pict_list, >pict_list_end);
> >  
> > -return 0;
> > +return ret;
> >  }
> >  
> >  #define OFFSET(x) offsetof(AIFFOutputContext, x)
> > -- 
> > 2.21.0
> 
> LGTM.

will apply

thx

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

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


signature.asc
Description: 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 1/3] avformat/aiffenc: Use standard packet list functions

2019-10-03 Thread Michael Niedermayer
On Wed, Oct 02, 2019 at 09:05:35AM +0200, Matthieu Bouron wrote:
> On Wed, Oct 02, 2019 at 06:04:10AM +0200, Andreas Rheinhardt wrote:
> > Up until now, aiffenc didn't rely on the standard functions for adding
> > an element to a linked list and freeing the list, but instead
> > reimplemented them. This has been changed.
> > 
> > Signed-off-by: Andreas Rheinhardt 
> > ---
> >  libavformat/aiffenc.c | 33 -
> >  1 file changed, 4 insertions(+), 29 deletions(-)
> > 
> > diff --git a/libavformat/aiffenc.c b/libavformat/aiffenc.c
> > index aab37418f0..dd8b8c3d01 100644
> > --- a/libavformat/aiffenc.c
> > +++ b/libavformat/aiffenc.c
> > @@ -36,7 +36,7 @@ typedef struct AIFFOutputContext {
> >  int64_t frames;
> >  int64_t ssnd;
> >  int audio_stream_idx;
> > -AVPacketList *pict_list;
> > +AVPacketList *pict_list, *pict_list_end;
> >  int write_id3v2;
> >  int id3v2_version;
> >  } AIFFOutputContext;
> > @@ -215,9 +215,6 @@ static int aiff_write_packet(AVFormatContext *s, 
> > AVPacket *pkt)
> >  if (pkt->stream_index == aiff->audio_stream_idx)
> >  avio_write(pb, pkt->data, pkt->size);
> >  else {
> > -int ret;
> > -AVPacketList *pict_list, *last;
> > -
> >  if (s->streams[pkt->stream_index]->codecpar->codec_type != 
> > AVMEDIA_TYPE_VIDEO)
> >  return 0;
> >  
> > @@ -229,24 +226,8 @@ static int aiff_write_packet(AVFormatContext *s, 
> > AVPacket *pkt)
> >  if (s->streams[pkt->stream_index]->nb_frames >= 1)
> >  return 0;
> >  
> > -pict_list = av_mallocz(sizeof(AVPacketList));
> > -if (!pict_list)
> > -return AVERROR(ENOMEM);
> > -
> > -ret = av_packet_ref(_list->pkt, pkt);
> > -if (ret < 0) {
> > -av_freep(_list);
> > -return ret;
> > -}
> > -
> > -if (!aiff->pict_list)
> > -aiff->pict_list = pict_list;
> > -else {
> > -last = aiff->pict_list;
> > -while (last->next)
> > -last = last->next;
> > -last->next = pict_list;
> > -}
> > +return ff_packet_list_put(>pict_list, >pict_list_end,
> > +  pkt, FF_PACKETLIST_FLAG_REF_PACKET);
> >  }
> >  
> >  return 0;
> > @@ -257,7 +238,6 @@ static int aiff_write_trailer(AVFormatContext *s)
> >  int ret;
> >  AVIOContext *pb = s->pb;
> >  AIFFOutputContext *aiff = s->priv_data;
> > -AVPacketList *pict_list = aiff->pict_list;
> >  AVCodecParameters *par = s->streams[aiff->audio_stream_idx]->codecpar;
> >  
> >  /* Chunks sizes must be even */
> > @@ -293,12 +273,7 @@ static int aiff_write_trailer(AVFormatContext *s)
> >  avio_flush(pb);
> >  }
> >  
> > -while (pict_list) {
> > -AVPacketList *next = pict_list->next;
> > -av_packet_unref(_list->pkt);
> > -av_freep(_list);
> > -pict_list = next;
> > -}
> > +ff_packet_list_free(>pict_list, >pict_list_end);
> >  
> >  return 0;
> >  }
> > -- 
> > 2.21.0
> 
> LGTM.
> 
> Fate passes and patch tested with a few remux of aiff files containing
> id3v2 tags + attached pics (ffmpeg -i input.aiff -write_id3v2 1
> output.aiff).

will apply

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

[FFmpeg-devel] [PATCH] avcodec/tiff: add limited support for ReferenceBlackWhite and YCbCrCoefficients tags

2019-10-03 Thread Skakov Pavel

Add support for properly handling PC/TV ranges and Rec601/Rec709 color spaces.
Example for PC range YUV, compare to ImageMagick decoding: 
https://samples.ffmpeg.org/image-samples/dscf0013.tif
From 5e24edbf73f3a897fd203e36963e9cf5db5e688d Mon Sep 17 00:00:00 2001
From: Pavel Skakov 
Date: Thu, 3 Oct 2019 21:28:10 +0300
Subject: [PATCH] avcodec/tiff: add limited support for ReferenceBlackWhite and
 YCbCrCoefficients tags

Signed-off-by: Pavel Skakov 
---
 libavcodec/tiff.c  | 74 --
 tests/ref/fate/exif-image-tiff |  2 +-
 2 files changed, 73 insertions(+), 3 deletions(-)

diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index 8b39ca1ebc..90215fce09 100644
--- a/libavcodec/tiff.c
+++ b/libavcodec/tiff.c
@@ -1441,12 +1441,16 @@ static int tiff_decode_tag(TiffContext *s, AVFrame *frame)
 break;
 case TIFF_PHOTOMETRIC:
 switch (value) {
+case TIFF_PHOTOMETRIC_YCBCR:
+s->avctx->colorspace = AVCOL_SPC_BT470BG;
+// fallthrough
+case TIFF_PHOTOMETRIC_RGB:
+s->avctx->color_range = AVCOL_RANGE_JPEG;
+// fallthrough
 case TIFF_PHOTOMETRIC_WHITE_IS_ZERO:
 case TIFF_PHOTOMETRIC_BLACK_IS_ZERO:
-case TIFF_PHOTOMETRIC_RGB:
 case TIFF_PHOTOMETRIC_PALETTE:
 case TIFF_PHOTOMETRIC_SEPARATED:
-case TIFF_PHOTOMETRIC_YCBCR:
 case TIFF_PHOTOMETRIC_CFA:
 case TIFF_PHOTOMETRIC_LINEAR_RAW: // Used by DNG images
 s->photometric = value;
@@ -1519,6 +1523,72 @@ static int tiff_decode_tag(TiffContext *s, AVFrame *frame)
 }
 }
 break;
+case TIFF_YCBCR_COEFFICIENTS:
+if (s->photometric == TIFF_PHOTOMETRIC_YCBCR)
+if (count != 3 || type != TIFF_RATIONAL) {
+av_log(s->avctx, AV_LOG_ERROR, "YCbCrCoefficients are invalid\n");
+return AVERROR_INVALIDDATA;
+} else {
+// LibTIFF handles rational values by converting them to/from floats, so we do the same in tests for equality
+float coef[3];
+for (i = 0; i < 3; i++) {
+unsigned num = ff_tget(>gb, TIFF_LONG, s->le);
+unsigned den = ff_tget(>gb, TIFF_LONG, s->le);
+if (!den) {
+av_log(s->avctx, AV_LOG_ERROR, "YCbCrCoefficients divisor is zero\n");
+return AVERROR_INVALIDDATA;
+}
+coef[i] = (float)num/den;
+}
+if (coef[0] == 0.2125f && coef[1] == 0.7154f && coef[2] == 0.0721f)
+s->avctx->colorspace = AVCOL_SPC_BT709;
+else if (coef[0] != 0.299f || coef[1] != 0.587f || coef[2] != 0.114f) {
+av_log(s->avctx, AV_LOG_WARNING, "Unrecognized YCbCrCoefficients values: %.4f %.4f %.4f\n", coef[0], coef[1], coef[2]);
+s->avctx->colorspace = AVCOL_SPC_UNSPECIFIED;
+}
+}
+break;
+case TIFF_REFERENCE_BW:
+if (s->photometric == TIFF_PHOTOMETRIC_YCBCR || s->photometric == TIFF_PHOTOMETRIC_RGB)
+if (count != 6 || type != TIFF_RATIONAL) {
+av_log(s->avctx, AV_LOG_ERROR, "ReferenceBlackWhite is invalid\n");
+return AVERROR_INVALIDDATA;
+} else {
+unsigned bpp = s->bpp/s->bppcount;
+unsigned mul = 1 << (bpp - 8);
+float max_val = (1 << bpp) - 1;
+float coef[6];
+for (i = 0; i < 6; i++) {
+unsigned num = ff_tget(>gb, TIFF_LONG, s->le);
+unsigned den = ff_tget(>gb, TIFF_LONG, s->le);
+if (!den) {
+av_log(s->avctx, AV_LOG_ERROR, "ReferenceBlackWhite divisor is zero\n");
+return AVERROR_INVALIDDATA;
+}
+coef[i] = (float)num/den;
+}
+if (s->photometric == TIFF_PHOTOMETRIC_YCBCR) {
+if (!coef[0] && coef[1] == max_val && coef[2] == (max_val + 1)/2 && coef[3] == max_val && coef[4] == coef[2] && coef[5] == coef[3])
+s->avctx->color_range = AVCOL_RANGE_JPEG;
+// NOTE: TIFF 6.0 specification has an example where it mistakenly shows TV range coef[0] as 15
+else if (coef[0] == 16*mul && coef[1] == 235*mul && coef[2] == 128*mul && coef[3] == 240*mul && coef[4] == coef[2] && coef[5] == coef[3])
+s->avctx->color_range = AVCOL_RANGE_MPEG;
+else {
+av_log(s->avctx, AV_LOG_WARNING, "Unrecognized ReferenceBlackWhite values: [%g;%g] [%g;%g] [%g;%g]\n", coef[0], coef[1], coef[2], coef[3], coef[4], coef[5]);
+s->avctx->color_range = AVCOL_RANGE_UNSPECIFIED;
+}
+} else {
+ 

Re: [FFmpeg-devel] [PATCH 1/5] avcodec/wmaprodec: Check if there is a stream

2019-10-03 Thread Michael Niedermayer
On Thu, Oct 03, 2019 at 08:52:49AM +0200, Paul B Mahol wrote:
> ok

will apply

thx

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

Those who are too smart to engage in politics are punished by being
governed by those who are dumber. -- Plato 


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 4/5] avcodec/tiff: Set FF_CODEC_CAP_INIT_CLEANUP

2019-10-03 Thread Michael Niedermayer
On Thu, Oct 03, 2019 at 08:54:19AM +0200, Paul B Mahol wrote:
> probably lgtm

will apply

thx

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

Those who are too smart to engage in politics are punished by being
governed by those who are dumber. -- Plato 


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/5] avcodec/vc1_block: Fix invalid left shift in vc1_decode_p_mb()

2019-10-03 Thread Michael Niedermayer
On Thu, Oct 03, 2019 at 08:56:54AM +0200, Paul B Mahol wrote:
> lgtm

will apply

thx

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

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


signature.asc
Description: 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 04/14] avformat/avidec: add logging context to log

2019-10-03 Thread Michael Niedermayer
On Wed, Oct 02, 2019 at 02:58:05PM +0800, Steven Liu wrote:
> Signed-off-by: Steven Liu 
> ---
>  libavformat/avidec.c | 14 +++---
>  1 file changed, 7 insertions(+), 7 deletions(-)

LGTM

thx

[...]
-- 
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".

[FFmpeg-devel] [PATCH 2/3] avformat/mpegts: add support for NIT extraction

2019-10-03 Thread Anthony Delannoy
---
 libavformat/mpegts.c | 45 +++-
 1 file changed, 44 insertions(+), 1 deletion(-)

diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index 587ed33327..5a3e71d9ab 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -169,7 +169,7 @@ struct MpegTSContext {
 MpegTSFilter *pids[NB_PID_MAX];
 int current_pid;
 
-AVStream *epg_stream;
+AVStream *epg_stream, *nit_stream;
 };
 
 #define MPEGTS_OPTIONS \
@@ -2426,6 +2426,46 @@ out:
 av_free(mp4_descr[i].dec_config_descr);
 }
 
+static void nit_cb(MpegTSFilter *filter, const uint8_t *section, int 
section_len)
+{
+MpegTSContext *ts = filter->u.section_filter.opaque;
+const uint8_t *p, *p_end;
+SectionHeader h1, *h = 
+
+if (!ts->nit_stream) {
+ts->nit_stream = avformat_new_stream(ts->stream, NULL);
+if (!ts->nit_stream)
+return;
+ts->nit_stream->id = NIT_PID;
+ts->nit_stream->codecpar->codec_type = AVMEDIA_TYPE_DATA;
+ts->nit_stream->codecpar->codec_id = AV_CODEC_ID_NIT;
+}
+
+if (ts->nit_stream->discard == AVDISCARD_ALL)
+return;
+
+p_end = section + section_len - 4;
+p = section;
+
+if (parse_section_header(h, , p_end) < 0)
+return;
+if (h->tid != NIT_TID && h->tid != ONIT_TID)
+return;
+
+av_log(ts->stream, AV_LOG_TRACE, "NIT: tid received = %.02x\n", h->tid);
+
+/**
+ * In case we receive a packet before mpegts context is fully
+ * initialized.
+ */
+if (!ts->pkt)
+return;
+
+new_data_packet(section, section_len, ts->pkt);
+ts->pkt->stream_index = ts->nit_stream->index;
+ts->stop_parse = 1;
+}
+
 static void pat_cb(MpegTSFilter *filter, const uint8_t *section, int 
section_len)
 {
 MpegTSContext *ts = filter->u.section_filter.opaque;
@@ -2468,6 +2508,7 @@ static void pat_cb(MpegTSFilter *filter, const uint8_t 
*section, int section_len
 
 if (sid == 0x) {
 /* NIT info */
+// XXX for now we only use default NIT_PID
 } else {
 MpegTSFilter *fil = ts->pids[pmt_pid];
 program = av_new_program(ts->stream, sid);
@@ -3043,6 +3084,7 @@ static int mpegts_read_header(AVFormatContext *s)
 mpegts_open_section_filter(ts, SDT_PID, sdt_cb, ts, 1);
 mpegts_open_section_filter(ts, PAT_PID, pat_cb, ts, 1);
 mpegts_open_section_filter(ts, EIT_PID, eit_cb, ts, 1);
+mpegts_open_section_filter(ts, NIT_PID, nit_cb, ts, 1);
 
 handle_packets(ts, probesize / ts->raw_packet_size);
 /* if could not find service, enable auto_guess */
@@ -3301,6 +3343,7 @@ MpegTSContext *avpriv_mpegts_parse_open(AVFormatContext 
*s)
 mpegts_open_section_filter(ts, SDT_PID, sdt_cb, ts, 1);
 mpegts_open_section_filter(ts, PAT_PID, pat_cb, ts, 1);
 mpegts_open_section_filter(ts, EIT_PID, eit_cb, ts, 1);
+mpegts_open_section_filter(ts, NIT_PID, nit_cb, ts, 1);
 
 return ts;
 }
-- 
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 1/3] avcodec: add NIT codec id

2019-10-03 Thread Anthony Delannoy
hi,

here the first version of NIT table extraction from DVB stream.
Patch 2/3 only open default NIT pid whereas patch 3/3 read PAT table
to open even non-standard NIT pid.

Anthony Delannoy

---
 libavcodec/avcodec.h| 1 +
 libavcodec/codec_desc.c | 6 ++
 libavcodec/version.h| 2 +-
 3 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index bcb931f0dd..92969ced83 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -691,6 +691,7 @@ enum AVCodecID {

 AV_CODEC_ID_SCTE_35, ///< Contain timestamp estimated through PCR of 
program stream.
 AV_CODEC_ID_EPG,
+AV_CODEC_ID_NIT,
 AV_CODEC_ID_BINTEXT= 0x18800,
 AV_CODEC_ID_XBIN,
 AV_CODEC_ID_IDF,
diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
index 0602ecb1b5..624befae91 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -3203,6 +3203,12 @@ static const AVCodecDescriptor codec_descriptors[] = {
 .name  = "epg",
 .long_name = NULL_IF_CONFIG_SMALL("Electronic Program Guide"),
 },
+{
+.id= AV_CODEC_ID_NIT,
+.type  = AVMEDIA_TYPE_DATA,
+.name  = "nit",
+.long_name = NULL_IF_CONFIG_SMALL("Network Information Table"),
+},
 {
 .id= AV_CODEC_ID_BINTEXT,
 .type  = AVMEDIA_TYPE_VIDEO,
diff --git a/libavcodec/version.h b/libavcodec/version.h
index 04b210371e..64e23659f4 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -28,7 +28,7 @@
 #include "libavutil/version.h"

 #define LIBAVCODEC_VERSION_MAJOR  58
-#define LIBAVCODEC_VERSION_MINOR  59
+#define LIBAVCODEC_VERSION_MINOR  60
 #define LIBAVCODEC_VERSION_MICRO 101

 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
--
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 3/3] avformat/mpegts: add support for non-standard NIT pid

2019-10-03 Thread Anthony Delannoy
---
 libavformat/mpegts.c | 32 
 1 file changed, 20 insertions(+), 12 deletions(-)

diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index 5a3e71d9ab..02da272325 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -169,6 +169,7 @@ struct MpegTSContext {
 MpegTSFilter *pids[NB_PID_MAX];
 int current_pid;
 
+int nit_pid;
 AVStream *epg_stream, *nit_stream;
 };
 
@@ -2432,15 +2433,6 @@ static void nit_cb(MpegTSFilter *filter, const uint8_t 
*section, int section_len
 const uint8_t *p, *p_end;
 SectionHeader h1, *h = 
 
-if (!ts->nit_stream) {
-ts->nit_stream = avformat_new_stream(ts->stream, NULL);
-if (!ts->nit_stream)
-return;
-ts->nit_stream->id = NIT_PID;
-ts->nit_stream->codecpar->codec_type = AVMEDIA_TYPE_DATA;
-ts->nit_stream->codecpar->codec_id = AV_CODEC_ID_NIT;
-}
-
 if (ts->nit_stream->discard == AVDISCARD_ALL)
 return;
 
@@ -2508,7 +2500,25 @@ static void pat_cb(MpegTSFilter *filter, const uint8_t 
*section, int section_len
 
 if (sid == 0x) {
 /* NIT info */
-// XXX for now we only use default NIT_PID
+if (!ts->nit_stream) {
+ts->nit_pid = pmt_pid;
+
+if (ts->nit_pid != NIT_PID)
+av_log(ts->stream, AV_LOG_WARNING,
+   "Using non-standard PID %i for NIT table.\n", 
pmt_pid);
+
+if (ts->pids[ts->nit_pid])
+mpegts_close_filter(ts, ts->pids[ts->nit_pid]);
+
+mpegts_open_section_filter(ts, ts->nit_pid, nit_cb, ts, 1);
+
+ts->nit_stream = avformat_new_stream(ts->stream, NULL);
+if (!ts->nit_stream)
+return;
+ts->nit_stream->id = ts->nit_pid;
+ts->nit_stream->codecpar->codec_type = AVMEDIA_TYPE_DATA;
+ts->nit_stream->codecpar->codec_id = AV_CODEC_ID_NIT;
+}
 } else {
 MpegTSFilter *fil = ts->pids[pmt_pid];
 program = av_new_program(ts->stream, sid);
@@ -3084,7 +3094,6 @@ static int mpegts_read_header(AVFormatContext *s)
 mpegts_open_section_filter(ts, SDT_PID, sdt_cb, ts, 1);
 mpegts_open_section_filter(ts, PAT_PID, pat_cb, ts, 1);
 mpegts_open_section_filter(ts, EIT_PID, eit_cb, ts, 1);
-mpegts_open_section_filter(ts, NIT_PID, nit_cb, ts, 1);
 
 handle_packets(ts, probesize / ts->raw_packet_size);
 /* if could not find service, enable auto_guess */
@@ -3343,7 +3352,6 @@ MpegTSContext *avpriv_mpegts_parse_open(AVFormatContext 
*s)
 mpegts_open_section_filter(ts, SDT_PID, sdt_cb, ts, 1);
 mpegts_open_section_filter(ts, PAT_PID, pat_cb, ts, 1);
 mpegts_open_section_filter(ts, EIT_PID, eit_cb, ts, 1);
-mpegts_open_section_filter(ts, NIT_PID, nit_cb, ts, 1);
 
 return ts;
 }
-- 
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] [PATCH] Fix segment muxer

2019-10-03 Thread just . one . man
It seems that my first attempt to send the patch failed (probably because my 
box where I executed "git send-email" failed reverse smtp check), so I'm going 
to re-send it to this same thread.

---

When incoming media has non-zero start PTS,
segment muxer would fail to correctly calculate
the point where to chunk segments, as it always
assumed that media starts with PTS==0.

This change removes this assumption by remembering
the PTS of the very first frame passed through the muxer.

Also fix starting points of first segment
---
 libavformat/segment.c |   12 +++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/libavformat/segment.c b/libavformat/segment.c
index e308206..2478d8f 100644
--- a/libavformat/segment.c
+++ b/libavformat/segment.c
@@ -87,6 +87,7 @@ typedef struct SegmentContext {
 int64_t last_val;  ///< remember last time for wrap around detection
 int cut_pending;
 int header_written;///< whether we've already called 
avformat_write_header
+int64_t start_pts; ///< pts of the very first packet processed, used 
to compute correct segment length

 char *entry_prefix;///< prefix to add to list entry filenames
 int list_type; ///< set the list type
@@ -702,6 +703,7 @@ static int seg_init(AVFormatContext *s)
 if ((ret = parse_frames(s, >frames, >nb_frames, 
seg->frames_str)) < 0)
 return ret;
 } else {
+seg->start_pts = -1;
 /* set default value if not specified */
 if (!seg->time_str)
 seg->time_str = av_strdup("2");
@@ -914,7 +916,15 @@ calc_times:
 seg->cut_pending = 1;
 seg->last_val = wrapped_val;
 } else {
-end_pts = seg->time * (seg->segment_count + 1);
+if (seg->start_pts != -1) {
+end_pts = seg->start_pts + seg->time * (seg->segment_count + 
1);
+} else if (pkt->stream_index == seg->reference_stream_index && 
pkt->pts != AV_NOPTS_VALUE) {
+// this is the first packet of the reference stream we see, 
initialize start point
+seg->start_pts = av_rescale_q(pkt->pts, st->time_base, 
AV_TIME_BASE_Q);
+seg->cur_entry.start_time = (double)pkt->pts * 
av_q2d(st->time_base);
+seg->cur_entry.start_pts = seg->start_pts;
+end_pts = seg->start_pts + seg->time * (seg->segment_count + 
1);
+}
 }
 }

--
1.7.9.5
___
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] Fix gas-preprocessor to translate .rdatasections for armasm and armasm64

2019-10-03 Thread Lukas Fellechner
> > Compiling FFmpeg with gas-preprocessor.pl and armasm or armasm64 fails 
> > since FFmpeg 4.2.
> > 
> > New .rdata sections have been added in ARM NEON assembly code (e.g. 
> > libavutil/aarch64/asm.S).
> > This fix allows gas-preprocessor to translate those sections to armasm 
> > compatible code.
> > 
> > Gas-preprocessor is maintained in https://github.com/FFmpeg/gas-preprocessor
> > 
> > ---
> > gas-preprocessor.pl | 1 +
> > 1 file changed, 1 insertion(+)
> 
> A fix for this issue, and a lot of other fixes as well not present in the 
> repo referenced above, exist at 
> https://git.libav.org/?p=gas-preprocessor.git;a=summary.
> 
> // Martin

Thank you, indeed the updated preprocessor fixes the build for me. 
Maybe the changes form libav should be merged into the FFmpeg repository then?

Lukas
___
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] Various build errors with armasm64 and armasmafter update to FFmpeg 4.2

2019-10-03 Thread Lukas Fellechner

> > On Oct 1, 2019, at 23:07, Lukas Fellechner  wrote:
> > 
> > This has worked very well for quite a long time. But after upgrading to 
> > FFmpeg 4.2, the build fails. A lot of changes and additions have been done 
> > for ARM/NEON 64-bit, and it looks like many of them are not compatible with 
> > armasm64. First I had to fix gas-preprocessor, a patch has been submitted 
> > today. But now, many other errors occur, which have to do with the ARM64 
> > assembly code itself. I don’t have any knowledge of ARM/NEON assembly code, 
> > so I cannot help much with the investigation or fixes.
> 
> The issue you posted about, and the other arm64 assembler issue you’ve 
> linked, are already fixed since a very long time in libav’s gas-preprocessor, 
> https://git.libav.org/?p=gas-preprocessor.git;a=summary.

Thank you, I tried with that updated gas-preprocessor and indeed all compile 
errors on ARM64 went away!

> > On ARM platform, I also see build errors. Interestingly, those files have 
> > not even changed. Only the referenced file libavutil/arm/asm.S has changed. 
> > Even when I undo the last changes there, the build still fails, so I am out 
> > of ideas here right now. When I switch back to FFmpeg 4.1.4, everything 
> > builds fine. Maybe there is a config change which causes those errors?

> > Errors with ARM target (32 bit):
> > 
> > C:\Source\FFmpegInterop-lukasf\ffmpeg\Output\Windows10\ARM\libavcodec\arm\ac3dsp_arm.o.asm(72)
> >  : error A2173: syntax error in expression
>it gt
> 
> This seems to be a new regression in armasm in MSVC 2019 16.3 (released a 
> couple weeks ago), see 
> https://developercommunity.visualstudio.com/content/problem/757709/armasm-fails-to-handle-it-instructions.html.
>  I don’t see how it would work for you with an earlier version of FFmpeg 
> though, maybe those files are around from an earlier build and you didn’t try 
> doing a full rebuild?

You are right, I was mainly testing with ARM64, so I did not notice that even 
FFmpeg 4.1.4 fails to build on ARM (32 bit). I need to roll back to the older 
build tools to build ARM platform successfully for now. 

> You can apply 
> https://lists.libav.org/pipermail/libav-devel/2019-October/086581.html on 
> your copy of gas-preprocessor to work around this issue, but I’m not sure if 
> it’s worth keeping the fix permanently (if the bug gets fixed in 16.4).

Thank you!

Best Regards
Lukas
___
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/5] avcodec/wmaprodec: Check if there is a stream

2019-10-03 Thread Paul B Mahol
ok

On 10/2/19, Michael Niedermayer  wrote:
> Fixes: null pointer dereference
> Fixes: signed integer overflow: 512 * 2147483647 cannot be represented in
> type 'int'
> Fixes:
> 17809/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_XMA1_fuzzer-5634409947987968
>
> Found-by: continuous fuzzing process
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/wmaprodec.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/libavcodec/wmaprodec.c b/libavcodec/wmaprodec.c
> index d0fa974c80..6ce2dd4adb 100644
> --- a/libavcodec/wmaprodec.c
> +++ b/libavcodec/wmaprodec.c
> @@ -1902,7 +1902,9 @@ static av_cold int xma_decode_init(AVCodecContext
> *avctx)
>  }
>
>  /* encoder supports up to 64 streams / 64*2 channels (would have to
> alloc arrays) */
> -if (avctx->channels > XMA_MAX_CHANNELS || s->num_streams >
> XMA_MAX_STREAMS) {
> +if (avctx->channels > XMA_MAX_CHANNELS || s->num_streams >
> XMA_MAX_STREAMS ||
> +s->num_streams <= 0
> +) {
>  avpriv_request_sample(avctx, "More than %d channels in %d streams",
> XMA_MAX_CHANNELS, s->num_streams);
>  return AVERROR_PATCHWELCOME;
>  }
> --
> 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 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/5] avcodec/vc1_block: Fix invalid left shift in vc1_decode_p_mb()

2019-10-03 Thread Paul B Mahol
lgtm

On 10/2/19, Michael Niedermayer  wrote:
> Fixes: left shift of negative value -6
> Fixes:
> 17810/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VC1_fuzzer-5638541240958976
>
> Found-by: continuous fuzzing process
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/vc1_block.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libavcodec/vc1_block.c b/libavcodec/vc1_block.c
> index fe7dbf8b1d..f1c9f41f30 100644
> --- a/libavcodec/vc1_block.c
> +++ b/libavcodec/vc1_block.c
> @@ -1481,7 +1481,7 @@ static int vc1_decode_p_mb(VC1Context *v)
>
> v->vc1dsp.vc1_inv_trans_8x8(v->block[v->cur_blk_idx][block_map[i]]);
>  if (v->rangeredfrm)
>  for (j = 0; j < 64; j++)
> -v->block[v->cur_blk_idx][block_map[i]][j] <<=
> 1;
> +v->block[v->cur_blk_idx][block_map[i]][j] *= 2;
>  block_cbp   |= 0xF << (i << 2);
>  block_intra |= 1 << i;
>  } else if (is_coded[i]) {
> --
> 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 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] avformat/amr: reduce raw amr false positive detection

2019-10-03 Thread Paul B Mahol
On 10/2/19, Carl Eugen Hoyos  wrote:
> Am Mi., 2. Okt. 2019 um 22:27 Uhr schrieb Carl Eugen Hoyos
> :
>
>> Another idea is to require different modes
>
> This would work for amr-wb but not amr-nb:
> Silence encoded with libopencore_amrnb looks
> similar to the provided sample that decodes to
> noise.

Nope. Please fix it.

>
> 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 4/5] avcodec/tiff: Set FF_CODEC_CAP_INIT_CLEANUP

2019-10-03 Thread Paul B Mahol
probably lgtm

On 10/2/19, Michael Niedermayer  wrote:
> Fixes: memleaks
> Fixes:
> 17813/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TIFF_fuzzer-5145600206569472
>
> Found-by: continuous fuzzing process
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/tiff.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
> index 9f24796a88..f537e99b5a 100644
> --- a/libavcodec/tiff.c
> +++ b/libavcodec/tiff.c
> @@ -2090,8 +2090,6 @@ static av_cold int tiff_init(AVCodecContext *avctx)
>  s->avctx_mjpeg->idct_algo = avctx->idct_algo;
>  ret = ff_codec_open2_recursive(s->avctx_mjpeg, codec, NULL);
>  if (ret < 0) {
> -av_frame_free(>jpgframe);
> -avcodec_free_context(>avctx_mjpeg);
>  return ret;
>  }
>
> @@ -2142,5 +2140,6 @@ AVCodec ff_tiff_decoder = {
>  .decode = decode_frame,
>  .init_thread_copy = ONLY_IF_THREADS_ENABLED(tiff_init),
>  .capabilities   = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS,
> +.caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
>  .priv_class = _decoder_class,
>  };
> --
> 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 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".