[FFmpeg-devel] [RFC] Seeking in PVA files
Måns Rullgård
mans
Sun Jan 6 19:50:50 CET 2008
Ivo <ivop at euronet.nl> writes:
> On Saturday 05 January 2008 21:20, Michael Niedermayer wrote:
>> you should parse all streams and use av_add_index_entry() even if the
>> specific stream hasnt been requested
>>
>> also cant more code be factored with pva_read_packet() ?
>> this looks somewhat similar
>> if so you might even avoid the need for some of the new functions
>
> Here's a completely rewritten version. I reuse almost all of the read_packet
> code. The new code is 17 lines shorter and the compiled code is ~1kB
> smaller. Functionality is equivalent.
>
> Index: libavformat/mpeg.c
> ===================================================================
> --- libavformat/mpeg.c (revision 11412)
> +++ libavformat/mpeg.c (working copy)
> @@ -120,17 +120,12 @@
>
> static int64_t get_pts(ByteIOContext *pb, int c)
> {
> - int64_t pts;
> - int val;
> + uint8_t buf[5];
>
> - if (c < 0)
> - c = get_byte(pb);
> - pts = (int64_t)(c & 0x0e) << 29;
> - val = get_be16(pb);
> - pts |= (int64_t)(val >> 1) << 15;
> - val = get_be16(pb);
> - pts |= (int64_t)(val >> 1);
> - return pts;
> + buf[0] = c<0 ? get_byte(pb) : c;
> + AV_WB32(buf+1, get_be32(pb));
Why not use get_buffer()?
> +
> + return ff_parse_pes_pts(buf);
> }
>
> static int find_next_start_code(ByteIOContext *pb, int *size_ptr,
> Index: libavformat/mpeg.h
> ===================================================================
> --- libavformat/mpeg.h (revision 11412)
> +++ libavformat/mpeg.h (working copy)
> @@ -57,4 +57,13 @@
>
> static const int lpcm_freq_tab[4] = { 48000, 96000, 44100, 32000 };
>
> +/**
> + * Parse MPEG-PES five-byte timestamp
> + */
> +static inline int64_t ff_parse_pes_pts(uint8_t *buf) {
> + return (int64_t)(*buf & 0x0e) << 29 |
> + (AV_RB16(buf+1) >> 1) << 15 |
> + AV_RB16(buf+3) >> 1;
> +}
> +
> #endif /* FFMPEG_MPEG_H */
This bit looks OK.
--
M?ns Rullg?rd
mans at mansr.com
More information about the ffmpeg-devel
mailing list