[FFmpeg-cvslog] Add .bit (de)muxer
Reimar Döffinger
Reimar.Doeffinger at gmx.de
Sun Sep 25 02:46:30 CEST 2011
On 24 Sep 2011, at 22:12, git at videolan.org (Vladimir Voroshilov) wrote:
> ffmpeg | branch: master | Vladimir Voroshilov <voroshil at gmail.com> | Sat Sep 24 22:08:16 2011 +0200| [0f2297a9b958b8598b17f139e7ec2d7e593a0a7c] | committer: Michael Niedermayer
>
> Add .bit (de)muxer
>
>> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=0f2297a9b958b8598b17f139e7ec2d7e593a0a7c
> ---
>
> libavformat/bit.c | 150 +++++++++++++++++++++++++++++++++++++++++++++++++++++
> 1 files changed, 150 insertions(+), 0 deletions(-)
>
> diff --git a/libavformat/bit.c b/libavformat/bit.c
> new file mode 100644
> index 0000000..ad55a55
> --- /dev/null
> +++ b/libavformat/bit.c
> @@ -0,0 +1,150 @@
> +#include "avformat.h"
> +#include "libavcodec/get_bits.h"
> +#include "libavcodec/put_bits.h"
> +
> +#define MAX_FRAME_SIZE 10
> +
> +#define SYNC_WORD 0x6b21
> +#define BIT_0 0x7f
> +#define BIT_1 0x81
> +
> +static int probe(AVProbeData *p)
> +{
> + int i;
> + i=AV_RL16(&p->buf[0]);
> +av_log(NULL, AV_LOG_ERROR, "bit probe: %x\n", i);
Left-over debug stuff.
> + if(i != SYNC_WORD)
> + return 0;
> +
> + switch(AV_RL16(&p->buf[2]))
> + {
> + case 0x40:
> + case 0x50:
> + return AVPROBE_SCORE_MAX/2;
That is not much data to go by.
Since the second packet should start at most 128 bytes further, it should probably be tested as well, and the first match should at most give max/4.
> + av_set_pts_info(st, 64, 1, 100);
> + url_fseek(pb, 0, SEEK_SET);
Not very nice, might cause problems when piping the format.
I mostly say this because you could probably set those values you need it for like bit rate in the read_packet function and avoid reading here completely.
> + if(url_feof(pb))
> + return AVERROR(EIO);
I think this must be AVERROR_EOF.
> + sync = get_le16(pb); // sync word
> + packet_size = get_le16(pb) / 8;
> + assert(packet_size < 8 * MAX_FRAME_SIZE);
assert is not appropriate here.
> + pkt->duration=1;
Is that really necessary? Either way, you should also set pos. Then you can and should enable generic seeking support.
More information about the ffmpeg-cvslog
mailing list