[FFmpeg-devel] [PATCH 2/2] g2meet: factor out chunk seeking

Michael Niedermayer michaelni at gmx.at
Sat Feb 8 23:24:42 CET 2014

On Sat, Feb 08, 2014 at 11:03:23PM +0100, Maxim Polijakowski wrote:
> Am 08.02.2014 22:45, schrieb Michael Niedermayer:
> >On Sat, Feb 08, 2014 at 10:27:51PM +0100, Maxim Poliakovski wrote:
> >>This version requires fewer code and is safer.
> >>---
> >>  libavcodec/g2meet.c |   21 ++++++++-------------
> >>  1 file changed, 8 insertions(+), 13 deletions(-)
> >>
> >>diff --git a/libavcodec/g2meet.c b/libavcodec/g2meet.c
> >>index b982eab..c2fceda 100644
> >>--- a/libavcodec/g2meet.c
> >>+++ b/libavcodec/g2meet.c
> >>@@ -646,7 +646,7 @@ static int g2m_decode_frame(AVCodecContext *avctx, void *data,
> >>      int magic;
> >>      int got_header = 0;
> >>      uint32_t chunk_size;
> >>-    int chunk_type;
> >>+    int chunk_type, chunk_start;
> >chunk_start should be 64bit as file positions could be 64bit in theory
> >also chunk_start + chunk_size could overflow if they are both 32bit
> Because we're working with frame data wrapped into a bytestream,
> chunk_start and chunk_size indicate some position within a single
> frame, which data size is very unlikely to be bigger than 2^32 bits.
> There are no file operations performed at all. Perhaps the word
> "seeking" was abit misleading here...

true its ok as is but still a bit risky
sizes in C generally should be size_t which can be 64bit
AVPacket uses int instead and the bytestream api also uses int
so theres no problem ATM
if bytestream and AVPacket get upgraded to 64bit or size_t the there
is a probem though, so it might still make sense to use 64bit for
saftey ...

anyway, if you prefer it as it is, ill apply it, its not wrong


Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Rewriting code that is poorly written but fully understood is good.
Rewriting code that one doesnt understand is a sign that one is less smart
then the original author, trying to rewrite it will not make it better.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20140208/24fcec67/attachment.asc>

More information about the ffmpeg-devel mailing list