[FFmpeg-devel] [PATCH] dpx.c: Better support for reading fps from headers

Michael Niedermayer michaelni at gmx.at
Mon Jul 7 14:18:29 CEST 2014


On Mon, Jul 07, 2014 at 12:29:43AM -0600, Bob Maple wrote:
> On 7/4/2014 7:52 AM, Michael Niedermayer wrote:
> 
> >> -    if (offset >= 1724 + 4) {
> >> -        buf = avpkt->data + 1724;
> 
> > you are removing an out of array access check
> > this is not ok unless theres some other check somewhere that makes
> > it redundant
> 
> Oops.. hmm I actually had changed the avpkt->size check at the head of
> the whole function at one point, but must not have saved or something.
> Not sure what the hell I did.
> 
> Anyway here's a new one with that change;  The whole header on a DPX
> should be at least 2k (the Film Info and TV Info headers are required to
> be present, but not required to be filled in with anything useful.)
> 

>  dpx.c |   23 +++++++++++++++--------
>  1 file changed, 15 insertions(+), 8 deletions(-)
> 06e0510c23742ee48aac9390108bf99bd3e2e8d3  0001-Better-support-for-reading-fps-from-headers.patch
> From 5943ab521672d708450614d2d8cee59d5a5c32ea Mon Sep 17 00:00:00 2001
> From: Bob Maple <bobm-ffdev at burner.com>
> Date: Sun, 6 Jul 2014 13:43:30 -0600
> Subject: [PATCH] Better support for reading fps from headers
> 
> ---
>  libavcodec/dpx.c |   23 +++++++++++++++--------
>  1 files changed, 15 insertions(+), 8 deletions(-)
> 
> diff --git a/libavcodec/dpx.c b/libavcodec/dpx.c
> index 5f05cd8..d296d73 100644
> --- a/libavcodec/dpx.c
> +++ b/libavcodec/dpx.c
> @@ -84,7 +84,7 @@ static int decode_frame(AVCodecContext *avctx,
>      unsigned int rgbBuffer = 0;
>      int n_datum = 0;
>  
> -    if (avpkt->size <= 1634) {
> +    if (avpkt->size < 2048) {
>          av_log(avctx, AV_LOG_ERROR, "Packet too small for DPX header\n");
>          return AVERROR_INVALIDDATA;
>      }

> @@ -147,14 +147,21 @@ static int decode_frame(AVCodecContext *avctx,
>      else
>          avctx->sample_aspect_ratio = (AVRational){ 0, 1 };
>  
> -    if (offset >= 1724 + 4) {
> -        buf = avpkt->data + 1724;

removing this will break if the headers after 1724 are not stored and
instead image data is there already
the tighter avpkt->size check will similarly cause problems for the
corner case of a very small image and the ommision of some headers

also see our dpxenc, which appears to generate such files


[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

I know you won't believe me, but the highest form of Human Excellence is
to question oneself and others. -- Socrates
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20140707/d8da8e38/attachment.asc>


More information about the ffmpeg-devel mailing list