Commit e6496ea7 authored by Luca Barbato's avatar Luca Barbato

4xm: K&R formatting cosmetics

parent 08859d19
......@@ -119,7 +119,7 @@ static int fourxm_read_header(AVFormatContext *s)
header = av_malloc(header_size);
if (!header)
return AVERROR(ENOMEM);
if (avio_read(pb, header, header_size) != header_size){
if (avio_read(pb, header, header_size) != header_size) {
av_free(header);
return AVERROR(EIO);
}
......@@ -134,7 +134,7 @@ static int fourxm_read_header(AVFormatContext *s)
} else if (fourcc_tag == vtrk_TAG) {
/* check that there is enough data */
if (size != vtrk_SIZE) {
ret= AVERROR_INVALIDDATA;
ret = AVERROR_INVALIDDATA;
goto fail;
}
fourxm->width = AV_RL32(&header[i + 36]);
......@@ -142,8 +142,8 @@ static int fourxm_read_header(AVFormatContext *s)
/* allocate a new AVStream */
st = avformat_new_stream(s, NULL);
if (!st){
ret= AVERROR(ENOMEM);
if (!st) {
ret = AVERROR(ENOMEM);
goto fail;
}
avpriv_set_pts_info(st, 60, 1, fourxm->fps);
......@@ -188,24 +188,25 @@ static int fourxm_read_header(AVFormatContext *s)
fourxm->tracks[current_track].sample_rate = AV_RL32(&header[i + 40]);
fourxm->tracks[current_track].bits = AV_RL32(&header[i + 44]);
fourxm->tracks[current_track].audio_pts = 0;
if( fourxm->tracks[current_track].channels <= 0
|| fourxm->tracks[current_track].sample_rate <= 0
|| fourxm->tracks[current_track].bits < 0){
if (fourxm->tracks[current_track].channels <= 0 ||
fourxm->tracks[current_track].sample_rate <= 0 ||
fourxm->tracks[current_track].bits < 0) {
av_log(s, AV_LOG_ERROR, "audio header invalid\n");
ret= -1;
ret = -1;
goto fail;
}
i += 8 + size;
/* allocate a new AVStream */
st = avformat_new_stream(s, NULL);
if (!st){
ret= AVERROR(ENOMEM);
if (!st) {
ret = AVERROR(ENOMEM);
goto fail;
}
st->id = current_track;
avpriv_set_pts_info(st, 60, 1, fourxm->tracks[current_track].sample_rate);
avpriv_set_pts_info(st, 60, 1,
fourxm->tracks[current_track].sample_rate);
fourxm->tracks[current_track].stream_index = st->index;
......@@ -219,17 +220,17 @@ static int fourxm_read_header(AVFormatContext *s)
st->codec->block_align = st->codec->channels * st->codec->bits_per_coded_sample;
if (fourxm->tracks[current_track].adpcm){
st->codec->codec_id = AV_CODEC_ID_ADPCM_4XM;
}else if (st->codec->bits_per_coded_sample == 8){
} else if (st->codec->bits_per_coded_sample == 8) {
st->codec->codec_id = AV_CODEC_ID_PCM_U8;
}else
} else
st->codec->codec_id = AV_CODEC_ID_PCM_S16LE;
}
}
/* skip over the LIST-MOVI chunk (which is where the stream should be */
GET_LIST_HEADER();
if (fourcc_tag != MOVI_TAG){
ret= AVERROR_INVALIDDATA;
if (fourcc_tag != MOVI_TAG) {
ret = AVERROR_INVALIDDATA;
goto fail;
}
......@@ -258,7 +259,6 @@ static int fourxm_read_packet(AVFormatContext *s,
int audio_frame_count;
while (!packet_read) {
if ((ret = avio_read(s->pb, header, 8)) < 0)
return ret;
fourcc_tag = AV_RL32(&header[0]);
......@@ -266,10 +266,9 @@ static int fourxm_read_packet(AVFormatContext *s,
if (pb->eof_reached)
return AVERROR(EIO);
switch (fourcc_tag) {
case LIST_TAG:
/* this is a good time to bump the video pts */
fourxm->video_pts ++;
fourxm->video_pts++;
/* skip the LIST-* tag and move on to the next fourcc */
avio_rl32(pb);
......@@ -291,20 +290,21 @@ static int fourxm_read_packet(AVFormatContext *s,
memcpy(pkt->data, header, 8);
ret = avio_read(s->pb, &pkt->data[8], size);
if (ret < 0){
if (ret < 0) {
av_free_packet(pkt);
}else
} else
packet_read = 1;
break;
case snd__TAG:
track_number = avio_rl32(pb);
avio_skip(pb, 4);
size-=8;
size -= 8;
if (track_number < fourxm->track_count && fourxm->tracks[track_number].channels>0) {
ret= av_get_packet(s->pb, pkt, size);
if(ret<0)
if (track_number < fourxm->track_count &&
fourxm->tracks[track_number].channels > 0) {
ret = av_get_packet(s->pb, pkt, size);
if (ret < 0)
return AVERROR(EIO);
pkt->stream_index =
fourxm->tracks[track_number].stream_index;
......@@ -314,17 +314,14 @@ static int fourxm_read_packet(AVFormatContext *s,
/* pts accounting */
audio_frame_count = size;
if (fourxm->tracks[track_number].adpcm)
audio_frame_count -=
2 * (fourxm->tracks[track_number].channels);
audio_frame_count /=
fourxm->tracks[track_number].channels;
if (fourxm->tracks[track_number].adpcm){
audio_frame_count -= 2 * (fourxm->tracks[track_number].channels);
audio_frame_count /= fourxm->tracks[track_number].channels;
if (fourxm->tracks[track_number].adpcm) {
audio_frame_count *= 2;
}else
} else
audio_frame_count /=
(fourxm->tracks[track_number].bits / 8);
fourxm->tracks[track_number].audio_pts += audio_frame_count;
} else {
avio_skip(pb, size);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment