nuv: cosmetics: pretty-printing

This commit is contained in:
Justin Ruggles 2012-11-27 15:19:00 -05:00
parent 5c7bf2ddde
commit c74f81786d
1 changed files with 151 additions and 136 deletions

View File

@ -46,7 +46,8 @@ typedef enum {
NUV_MYTHEXT = 'X'
} nuv_frametype;
static int nuv_probe(AVProbeData *p) {
static int nuv_probe(AVProbeData *p)
{
if (!memcmp(p->buf, "NuppelVideo", 12))
return AVPROBE_SCORE_MAX;
if (!memcmp(p->buf, "MythTVVideo", 12))
@ -65,12 +66,15 @@ static int nuv_probe(AVProbeData *p) {
* @return 1 if all required codec data was found
*/
static int get_codec_data(AVIOContext *pb, AVStream *vst,
AVStream *ast, int myth) {
AVStream *ast, int myth)
{
nuv_frametype frametype;
if (!vst && !myth)
return 1; // no codec data needed
while (!pb->eof_reached) {
int size, subtype;
frametype = avio_r8(pb);
switch (frametype) {
case NUV_EXTRADATA:
@ -113,8 +117,7 @@ static int get_codec_data(AVIOContext *pb, AVStream *vst,
id = ff_wav_codec_get_id(ast->codec->codec_tag,
ast->codec->bits_per_coded_sample);
if (id == AV_CODEC_ID_NONE) {
id = ff_codec_get_id(nuv_audio_tags,
ast->codec->codec_tag);
id = ff_codec_get_id(nuv_audio_tags, ast->codec->codec_tag);
if (id == AV_CODEC_ID_PCM_S16LE)
id = ff_get_pcm_codec_id(ast->codec->bits_per_coded_sample,
0, 0, ~1);
@ -138,10 +141,12 @@ static int get_codec_data(AVIOContext *pb, AVStream *vst,
}
avio_skip(pb, size);
}
return 0;
}
static int nuv_header(AVFormatContext *s) {
static int nuv_header(AVFormatContext *s)
{
NUVContext *ctx = s->priv_data;
AVIOContext *pb = s->pb;
char id_string[12];
@ -149,6 +154,7 @@ static int nuv_header(AVFormatContext *s) {
int is_mythtv, width, height, v_packs, a_packs;
int stream_nr = 0;
AVStream *vst = NULL, *ast = NULL;
avio_read(pb, id_string, 12);
is_mythtv = !memcmp(id_string, "MythTVVideo", 12);
avio_skip(pb, 5); // version string
@ -181,7 +187,8 @@ static int nuv_header(AVFormatContext *s) {
vst->codec->width = width;
vst->codec->height = height;
vst->codec->bits_per_coded_sample = 10;
vst->sample_aspect_ratio = av_d2q(aspect * height / width, 10000);
vst->sample_aspect_ratio = av_d2q(aspect * height / width,
10000);
#if FF_API_R_FRAME_RATE
vst->r_frame_rate =
#endif
@ -209,25 +216,31 @@ static int nuv_header(AVFormatContext *s) {
get_codec_data(pb, vst, ast, is_mythtv);
ctx->rtjpg_video = vst && vst->codec->codec_id == AV_CODEC_ID_NUV;
return 0;
}
#define HDRSIZE 12
static int nuv_packet(AVFormatContext *s, AVPacket *pkt) {
static int nuv_packet(AVFormatContext *s, AVPacket *pkt)
{
NUVContext *ctx = s->priv_data;
AVIOContext *pb = s->pb;
uint8_t hdr[HDRSIZE];
nuv_frametype frametype;
int ret, size;
while (!pb->eof_reached) {
int copyhdrsize = ctx->rtjpg_video ? HDRSIZE : 0;
uint64_t pos = avio_tell(pb);
ret = avio_read(pb, hdr, HDRSIZE);
if (ret < HDRSIZE)
return ret < 0 ? ret : AVERROR(EIO);
frametype = hdr[0];
size = PKTSIZE(AV_RL32(&hdr[8]));
switch (frametype) {
case NUV_EXTRADATA:
if (!ctx->rtjpg_video) {
@ -269,7 +282,8 @@ static int nuv_packet(AVFormatContext *s, AVPacket *pkt) {
pkt->pos = pos;
pkt->pts = AV_RL32(&hdr[4]);
pkt->stream_index = ctx->a_id;
if (ret < 0) return ret;
if (ret < 0)
return ret;
return 0;
case NUV_SEEKP:
// contains no data, size value is invalid
@ -279,6 +293,7 @@ static int nuv_packet(AVFormatContext *s, AVPacket *pkt) {
break;
}
}
return AVERROR(EIO);
}