You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-07-06 06:27:36 +02:00
4xm: K&R formatting cosmetics
This commit is contained in:
@ -119,7 +119,7 @@ static int fourxm_read_header(AVFormatContext *s)
|
|||||||
header = av_malloc(header_size);
|
header = av_malloc(header_size);
|
||||||
if (!header)
|
if (!header)
|
||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
if (avio_read(pb, header, header_size) != header_size){
|
if (avio_read(pb, header, header_size) != header_size) {
|
||||||
av_free(header);
|
av_free(header);
|
||||||
return AVERROR(EIO);
|
return AVERROR(EIO);
|
||||||
}
|
}
|
||||||
@ -134,7 +134,7 @@ static int fourxm_read_header(AVFormatContext *s)
|
|||||||
} else if (fourcc_tag == vtrk_TAG) {
|
} else if (fourcc_tag == vtrk_TAG) {
|
||||||
/* check that there is enough data */
|
/* check that there is enough data */
|
||||||
if (size != vtrk_SIZE) {
|
if (size != vtrk_SIZE) {
|
||||||
ret= AVERROR_INVALIDDATA;
|
ret = AVERROR_INVALIDDATA;
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
fourxm->width = AV_RL32(&header[i + 36]);
|
fourxm->width = AV_RL32(&header[i + 36]);
|
||||||
@ -142,8 +142,8 @@ static int fourxm_read_header(AVFormatContext *s)
|
|||||||
|
|
||||||
/* allocate a new AVStream */
|
/* allocate a new AVStream */
|
||||||
st = avformat_new_stream(s, NULL);
|
st = avformat_new_stream(s, NULL);
|
||||||
if (!st){
|
if (!st) {
|
||||||
ret= AVERROR(ENOMEM);
|
ret = AVERROR(ENOMEM);
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
avpriv_set_pts_info(st, 60, 1, fourxm->fps);
|
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].sample_rate = AV_RL32(&header[i + 40]);
|
||||||
fourxm->tracks[current_track].bits = AV_RL32(&header[i + 44]);
|
fourxm->tracks[current_track].bits = AV_RL32(&header[i + 44]);
|
||||||
fourxm->tracks[current_track].audio_pts = 0;
|
fourxm->tracks[current_track].audio_pts = 0;
|
||||||
if( fourxm->tracks[current_track].channels <= 0
|
if (fourxm->tracks[current_track].channels <= 0 ||
|
||||||
|| fourxm->tracks[current_track].sample_rate <= 0
|
fourxm->tracks[current_track].sample_rate <= 0 ||
|
||||||
|| fourxm->tracks[current_track].bits < 0){
|
fourxm->tracks[current_track].bits < 0) {
|
||||||
av_log(s, AV_LOG_ERROR, "audio header invalid\n");
|
av_log(s, AV_LOG_ERROR, "audio header invalid\n");
|
||||||
ret= -1;
|
ret = -1;
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
i += 8 + size;
|
i += 8 + size;
|
||||||
|
|
||||||
/* allocate a new AVStream */
|
/* allocate a new AVStream */
|
||||||
st = avformat_new_stream(s, NULL);
|
st = avformat_new_stream(s, NULL);
|
||||||
if (!st){
|
if (!st) {
|
||||||
ret= AVERROR(ENOMEM);
|
ret = AVERROR(ENOMEM);
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
st->id = current_track;
|
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;
|
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;
|
st->codec->block_align = st->codec->channels * st->codec->bits_per_coded_sample;
|
||||||
if (fourxm->tracks[current_track].adpcm){
|
if (fourxm->tracks[current_track].adpcm){
|
||||||
st->codec->codec_id = AV_CODEC_ID_ADPCM_4XM;
|
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;
|
st->codec->codec_id = AV_CODEC_ID_PCM_U8;
|
||||||
}else
|
} else
|
||||||
st->codec->codec_id = AV_CODEC_ID_PCM_S16LE;
|
st->codec->codec_id = AV_CODEC_ID_PCM_S16LE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* skip over the LIST-MOVI chunk (which is where the stream should be */
|
/* skip over the LIST-MOVI chunk (which is where the stream should be */
|
||||||
GET_LIST_HEADER();
|
GET_LIST_HEADER();
|
||||||
if (fourcc_tag != MOVI_TAG){
|
if (fourcc_tag != MOVI_TAG) {
|
||||||
ret= AVERROR_INVALIDDATA;
|
ret = AVERROR_INVALIDDATA;
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -258,7 +259,6 @@ static int fourxm_read_packet(AVFormatContext *s,
|
|||||||
int audio_frame_count;
|
int audio_frame_count;
|
||||||
|
|
||||||
while (!packet_read) {
|
while (!packet_read) {
|
||||||
|
|
||||||
if ((ret = avio_read(s->pb, header, 8)) < 0)
|
if ((ret = avio_read(s->pb, header, 8)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
fourcc_tag = AV_RL32(&header[0]);
|
fourcc_tag = AV_RL32(&header[0]);
|
||||||
@ -266,10 +266,9 @@ static int fourxm_read_packet(AVFormatContext *s,
|
|||||||
if (pb->eof_reached)
|
if (pb->eof_reached)
|
||||||
return AVERROR(EIO);
|
return AVERROR(EIO);
|
||||||
switch (fourcc_tag) {
|
switch (fourcc_tag) {
|
||||||
|
|
||||||
case LIST_TAG:
|
case LIST_TAG:
|
||||||
/* this is a good time to bump the video pts */
|
/* 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 */
|
/* skip the LIST-* tag and move on to the next fourcc */
|
||||||
avio_rl32(pb);
|
avio_rl32(pb);
|
||||||
@ -291,20 +290,21 @@ static int fourxm_read_packet(AVFormatContext *s,
|
|||||||
memcpy(pkt->data, header, 8);
|
memcpy(pkt->data, header, 8);
|
||||||
ret = avio_read(s->pb, &pkt->data[8], size);
|
ret = avio_read(s->pb, &pkt->data[8], size);
|
||||||
|
|
||||||
if (ret < 0){
|
if (ret < 0) {
|
||||||
av_free_packet(pkt);
|
av_free_packet(pkt);
|
||||||
}else
|
} else
|
||||||
packet_read = 1;
|
packet_read = 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case snd__TAG:
|
case snd__TAG:
|
||||||
track_number = avio_rl32(pb);
|
track_number = avio_rl32(pb);
|
||||||
avio_skip(pb, 4);
|
avio_skip(pb, 4);
|
||||||
size-=8;
|
size -= 8;
|
||||||
|
|
||||||
if (track_number < fourxm->track_count && fourxm->tracks[track_number].channels>0) {
|
if (track_number < fourxm->track_count &&
|
||||||
ret= av_get_packet(s->pb, pkt, size);
|
fourxm->tracks[track_number].channels > 0) {
|
||||||
if(ret<0)
|
ret = av_get_packet(s->pb, pkt, size);
|
||||||
|
if (ret < 0)
|
||||||
return AVERROR(EIO);
|
return AVERROR(EIO);
|
||||||
pkt->stream_index =
|
pkt->stream_index =
|
||||||
fourxm->tracks[track_number].stream_index;
|
fourxm->tracks[track_number].stream_index;
|
||||||
@ -314,17 +314,14 @@ static int fourxm_read_packet(AVFormatContext *s,
|
|||||||
/* pts accounting */
|
/* pts accounting */
|
||||||
audio_frame_count = size;
|
audio_frame_count = size;
|
||||||
if (fourxm->tracks[track_number].adpcm)
|
if (fourxm->tracks[track_number].adpcm)
|
||||||
audio_frame_count -=
|
audio_frame_count -= 2 * (fourxm->tracks[track_number].channels);
|
||||||
2 * (fourxm->tracks[track_number].channels);
|
audio_frame_count /= fourxm->tracks[track_number].channels;
|
||||||
audio_frame_count /=
|
if (fourxm->tracks[track_number].adpcm) {
|
||||||
fourxm->tracks[track_number].channels;
|
|
||||||
if (fourxm->tracks[track_number].adpcm){
|
|
||||||
audio_frame_count *= 2;
|
audio_frame_count *= 2;
|
||||||
}else
|
} else
|
||||||
audio_frame_count /=
|
audio_frame_count /=
|
||||||
(fourxm->tracks[track_number].bits / 8);
|
(fourxm->tracks[track_number].bits / 8);
|
||||||
fourxm->tracks[track_number].audio_pts += audio_frame_count;
|
fourxm->tracks[track_number].audio_pts += audio_frame_count;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
avio_skip(pb, size);
|
avio_skip(pb, size);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user