Message ID | 20210718012204.97733-1-zane@zanevaniperen.com |
---|---|
State | Superseded |
Headers | show |
Series | [FFmpeg-devel,1/8] avcodec/argo: use pixel format provided by the demuxer | expand |
Context | Check | Description |
---|---|---|
andriy/x86_make | success | Make finished |
andriy/x86_make_fate | success | Make fate finished |
andriy/PPC64_make | success | Make finished |
andriy/PPC64_make_fate | success | Make fate finished |
On Sun, Jul 18, 2021 at 3:22 AM Zane van Iperen <zane@zanevaniperen.com> wrote: > But fall back to bits_per_raw_sample, in case we're with older > libavformat. > > Signed-off-by: Zane van Iperen <zane@zanevaniperen.com> > --- > libavcodec/argo.c | 21 ++++++++++++++------- > libavcodec/version.h | 2 +- > 2 files changed, 15 insertions(+), 8 deletions(-) > > diff --git a/libavcodec/argo.c b/libavcodec/argo.c > index 87c646f56c..9df5b8a8d3 100644 > --- a/libavcodec/argo.c > +++ b/libavcodec/argo.c > @@ -676,13 +676,20 @@ static av_cold int decode_init(AVCodecContext *avctx) > { > ArgoContext *s = avctx->priv_data; > > - switch (avctx->bits_per_raw_sample) { > - case 8: s->bpp = 1; > - avctx->pix_fmt = AV_PIX_FMT_PAL8; break; > - case 24: s->bpp = 4; > - avctx->pix_fmt = AV_PIX_FMT_BGR0; break; > - default: avpriv_request_sample(s, "depth == %u", > avctx->bits_per_raw_sample); > - return AVERROR_PATCHWELCOME; > + if (avctx->pix_fmt == AV_PIX_FMT_NONE) { > + /* For compat with older libavformat. */ > + switch (avctx->bits_per_raw_sample) { > + case 8: s->bpp = 1; > + avctx->pix_fmt = AV_PIX_FMT_PAL8; break; > + case 24: s->bpp = 4; > + avctx->pix_fmt = AV_PIX_FMT_BGR0; break; > + default: avpriv_request_sample(s, "depth == %u", > avctx->bits_per_raw_sample); > + return AVERROR_PATCHWELCOME; > + } > + } > + > + if (avctx->pix_fmt != AV_PIX_FMT_PAL8 && avctx->pix_fmt != > AV_PIX_FMT_BGR0) { > + return AVERROR_INVALIDDATA; > } > > s->frame = av_frame_alloc(); > diff --git a/libavcodec/version.h b/libavcodec/version.h > index c660f70669..91325ce4e7 100644 > --- a/libavcodec/version.h > +++ b/libavcodec/version.h > @@ -29,7 +29,7 @@ > > #define LIBAVCODEC_VERSION_MAJOR 59 > #define LIBAVCODEC_VERSION_MINOR 3 > -#define LIBAVCODEC_VERSION_MICRO 101 > +#define LIBAVCODEC_VERSION_MICRO 102 > > #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ > LIBAVCODEC_VERSION_MINOR, \ > -- > 2.31.1 > > I really doubt this is correct approach. No other video decoder use pix format set from demuxer. > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". >
> I really doubt this is correct approach. No other video decoder use pix > format set from demuxer. > I could change it to use bits_per_coded_sample instead, would that be better? I see that's what Cinepak does. Zane
On Sun, Jul 18, 2021 at 10:35 AM Zane van Iperen <zane@zanevaniperen.com> wrote: > > I really doubt this is correct approach. No other video decoder use pix > > format set from demuxer. > > > > I could change it to use bits_per_coded_sample instead, would that be > better? > I see that's what Cinepak does. > > Probably, as some users use own (de)muxers, thought that is very unlikely for niche game formats. > Zane > > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". >
On 7/17/2021 10:21 PM, Zane van Iperen wrote: > But fall back to bits_per_raw_sample, in case we're with older > libavformat. What older libavformat? We bumped major version a few months ago, so you can't link git head lavc with lavf <= 58. Or is this about changes in the following patches? If so, the bump is recent and we haven't made a release yet, so don't bother with this kind of backwards compat. > > Signed-off-by: Zane van Iperen <zane@zanevaniperen.com> > --- > libavcodec/argo.c | 21 ++++++++++++++------- > libavcodec/version.h | 2 +- > 2 files changed, 15 insertions(+), 8 deletions(-) > > diff --git a/libavcodec/argo.c b/libavcodec/argo.c > index 87c646f56c..9df5b8a8d3 100644 > --- a/libavcodec/argo.c > +++ b/libavcodec/argo.c > @@ -676,13 +676,20 @@ static av_cold int decode_init(AVCodecContext *avctx) > { > ArgoContext *s = avctx->priv_data; > > - switch (avctx->bits_per_raw_sample) { > - case 8: s->bpp = 1; > - avctx->pix_fmt = AV_PIX_FMT_PAL8; break; > - case 24: s->bpp = 4; > - avctx->pix_fmt = AV_PIX_FMT_BGR0; break; > - default: avpriv_request_sample(s, "depth == %u", avctx->bits_per_raw_sample); > - return AVERROR_PATCHWELCOME; > + if (avctx->pix_fmt == AV_PIX_FMT_NONE) { > + /* For compat with older libavformat. */ > + switch (avctx->bits_per_raw_sample) { > + case 8: s->bpp = 1; > + avctx->pix_fmt = AV_PIX_FMT_PAL8; break; > + case 24: s->bpp = 4; > + avctx->pix_fmt = AV_PIX_FMT_BGR0; break; > + default: avpriv_request_sample(s, "depth == %u", avctx->bits_per_raw_sample); > + return AVERROR_PATCHWELCOME; > + } > + } > + > + if (avctx->pix_fmt != AV_PIX_FMT_PAL8 && avctx->pix_fmt != AV_PIX_FMT_BGR0) { > + return AVERROR_INVALIDDATA; > } > > s->frame = av_frame_alloc(); > diff --git a/libavcodec/version.h b/libavcodec/version.h > index c660f70669..91325ce4e7 100644 > --- a/libavcodec/version.h > +++ b/libavcodec/version.h > @@ -29,7 +29,7 @@ > > #define LIBAVCODEC_VERSION_MAJOR 59 > #define LIBAVCODEC_VERSION_MINOR 3 > -#define LIBAVCODEC_VERSION_MICRO 101 > +#define LIBAVCODEC_VERSION_MICRO 102 > > #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ > LIBAVCODEC_VERSION_MINOR, \ >
On 18/7/21 11:18 pm, James Almer wrote: > On 7/17/2021 10:21 PM, Zane van Iperen wrote: >> But fall back to bits_per_raw_sample, in case we're with older >> libavformat. > > What older libavformat? We bumped major version a few months ago, so you can't link git head lavc with lavf <= 58. > Or is this about changes in the following patches? If so, the bump is recent and we haven't made a release yet, so don't bother with this kind of backwards compat. > Yup, I've already changed this. See v2 of parts 1 & 2: https://ffmpeg.org/pipermail/ffmpeg-devel/2021-July/282401.html
diff --git a/libavcodec/argo.c b/libavcodec/argo.c index 87c646f56c..9df5b8a8d3 100644 --- a/libavcodec/argo.c +++ b/libavcodec/argo.c @@ -676,13 +676,20 @@ static av_cold int decode_init(AVCodecContext *avctx) { ArgoContext *s = avctx->priv_data; - switch (avctx->bits_per_raw_sample) { - case 8: s->bpp = 1; - avctx->pix_fmt = AV_PIX_FMT_PAL8; break; - case 24: s->bpp = 4; - avctx->pix_fmt = AV_PIX_FMT_BGR0; break; - default: avpriv_request_sample(s, "depth == %u", avctx->bits_per_raw_sample); - return AVERROR_PATCHWELCOME; + if (avctx->pix_fmt == AV_PIX_FMT_NONE) { + /* For compat with older libavformat. */ + switch (avctx->bits_per_raw_sample) { + case 8: s->bpp = 1; + avctx->pix_fmt = AV_PIX_FMT_PAL8; break; + case 24: s->bpp = 4; + avctx->pix_fmt = AV_PIX_FMT_BGR0; break; + default: avpriv_request_sample(s, "depth == %u", avctx->bits_per_raw_sample); + return AVERROR_PATCHWELCOME; + } + } + + if (avctx->pix_fmt != AV_PIX_FMT_PAL8 && avctx->pix_fmt != AV_PIX_FMT_BGR0) { + return AVERROR_INVALIDDATA; } s->frame = av_frame_alloc(); diff --git a/libavcodec/version.h b/libavcodec/version.h index c660f70669..91325ce4e7 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -29,7 +29,7 @@ #define LIBAVCODEC_VERSION_MAJOR 59 #define LIBAVCODEC_VERSION_MINOR 3 -#define LIBAVCODEC_VERSION_MICRO 101 +#define LIBAVCODEC_VERSION_MICRO 102 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ LIBAVCODEC_VERSION_MINOR, \
But fall back to bits_per_raw_sample, in case we're with older libavformat. Signed-off-by: Zane van Iperen <zane@zanevaniperen.com> --- libavcodec/argo.c | 21 ++++++++++++++------- libavcodec/version.h | 2 +- 2 files changed, 15 insertions(+), 8 deletions(-)