Merge commit 'c74f81786d434dfaf9b3dff06aa96bfd23d0127b'

* commit 'c74f81786d434dfaf9b3dff06aa96bfd23d0127b':
  nuv: cosmetics: pretty-printing

Conflicts:
	libavformat/nuv.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Michael Niedermayer 2012-11-29 14:07:51 +01:00
commit 52066bdb30

View File

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