[FFmpeg-devel] [PATCH 2/3] rtpdec_jpeg: use framesize from SDP if present

Michael Niedermayer michael at niedermayer.cc
Tue Jan 26 03:51:38 CET 2016


On Tue, Dec 08, 2015 at 02:10:32PM +0200, Andrey Utkin wrote:
> This enables us to process pics larger than 2040 pixels in dimensions,
> overcoming the limitation of RFC 2435.
> 
> Signed-off-by: Andrey Utkin <andrey.utkin at corp.bluecherry.net>
> ---
>  libavformat/rtpdec_jpeg.c | 46 +++++++++++++++++++++++++++++++++++++++++++---
>  1 file changed, 43 insertions(+), 3 deletions(-)
> 
> diff --git a/libavformat/rtpdec_jpeg.c b/libavformat/rtpdec_jpeg.c
> index 6bf88f8..0a83468 100644
> --- a/libavformat/rtpdec_jpeg.c
> +++ b/libavformat/rtpdec_jpeg.c
> @@ -24,9 +24,11 @@
>  #include "rtpdec.h"
>  #include "rtpdec_formats.h"
>  #include "libavutil/intreadwrite.h"
> +#include "libavutil/avstring.h"
>  #include "libavcodec/jpegtables.h"
>  #include "libavcodec/mjpeg.h"
>  #include "libavcodec/bytestream.h"
> +#include "libavformat/rtpdec_formats.h"
>  
>  /**
>   * RTP/JPEG specific private data.
> @@ -35,6 +37,14 @@ struct PayloadContext {
>      AVIOContext *frame;         ///< current frame buffer
>      uint32_t    timestamp;      ///< current frame timestamp
>      int         hdr_size;       ///< size of the current frame header
> +    /**
> +     * Flag, shows whether we got framesize explicitly from SDP.
> +     * If set, override dimensions from RTP header.
> +     * Workaround for dimensions larger than 2040 (limitation of RFC 2435).
> +     */
> +    int         sdp_framesize_set;
> +    int         sdp_width;
> +    int         sdp_height;
>      uint8_t     qtables[128][128];
>      uint8_t     qtables_len[128];
>  };
> @@ -215,7 +225,8 @@ static int jpeg_parse_packet(AVFormatContext *ctx, PayloadContext *jpeg,
>                               const uint8_t *buf, int len, uint16_t seq,
>                               int flags)
>  {
> -    uint8_t type, q, width, height;
> +    uint8_t type, q;
> +    uint32_t width, height;
>      const uint8_t *qtables = NULL;
>      uint16_t qtable_len;
>      uint32_t off;

> @@ -230,8 +241,13 @@ static int jpeg_parse_packet(AVFormatContext *ctx, PayloadContext *jpeg,
>      off    = AV_RB24(buf + 1);  /* fragment byte offset */
>      type   = AV_RB8(buf + 4);   /* id of jpeg decoder params */
>      q      = AV_RB8(buf + 5);   /* quantization factor (or table id) */
> -    width  = AV_RB8(buf + 6);   /* frame width in 8 pixel blocks */
> -    height = AV_RB8(buf + 7);   /* frame height in 8 pixel blocks */
> +    if (jpeg->sdp_framesize_set) {
> +        width  = FF_CEIL_RSHIFT(jpeg->sdp_width, 3);
> +        height = FF_CEIL_RSHIFT(jpeg->sdp_height, 3);

i dont think the lowest 3 bits should be discarded


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

Awnsering whenever a program halts or runs forever is
On a turing machine, in general impossible (turings halting problem).
On any real computer, always possible as a real computer has a finite number
of states N, and will either halt in less than N cycles or never halt.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20160126/e715c443/attachment.sig>


More information about the ffmpeg-devel mailing list