diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2014-02-05 01:18:48 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2014-02-05 01:18:48 +0100 |
commit | dcbc748ad11b7a683c54b4afc350f734adcded4e (patch) | |
tree | 9386abe2d1139c16a1f54c691ffaebc18a46475a | |
parent | 20be510887d0985c370957371025d5d7f721bb79 (diff) | |
parent | d509ae5be0a9bac35a4cedbe68b774a74446bb27 (diff) | |
download | ffmpeg-dcbc748ad11b7a683c54b4afc350f734adcded4e.tar.gz |
Merge commit 'd509ae5be0a9bac35a4cedbe68b774a74446bb27'
* commit 'd509ae5be0a9bac35a4cedbe68b774a74446bb27':
jvdec: K&R formatting cosmetics
Conflicts:
libavcodec/jvdec.c
libavformat/jvdec.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r-- | libavcodec/jvdec.c | 44 | ||||
-rw-r--r-- | libavformat/jvdec.c | 46 |
2 files changed, 48 insertions, 42 deletions
diff --git a/libavcodec/jvdec.c b/libavcodec/jvdec.c index cad053289a..03da880b7f 100644 --- a/libavcodec/jvdec.c +++ b/libavcodec/jvdec.c @@ -25,11 +25,12 @@ * @author Peter Ross <pross@xvid.org> */ +#include "libavutil/intreadwrite.h" + #include "avcodec.h" #include "dsputil.h" #include "get_bits.h" #include "internal.h" -#include "libavutil/intreadwrite.h" typedef struct JvContext { DSPContext dsp; @@ -62,19 +63,19 @@ static inline void decode2x2(GetBitContext *gb, uint8_t *dst, int linesize) case 1: v[0] = get_bits(gb, 8); for (j = 0; j < 2; j++) - memset(dst + j*linesize, v[0], 2); + memset(dst + j * linesize, v[0], 2); break; case 2: v[0] = get_bits(gb, 8); v[1] = get_bits(gb, 8); for (j = 0; j < 2; j++) for (i = 0; i < 2; i++) - dst[j*linesize + i] = v[get_bits1(gb)]; + dst[j * linesize + i] = v[get_bits1(gb)]; break; case 3: for (j = 0; j < 2; j++) for (i = 0; i < 2; i++) - dst[j*linesize + i] = get_bits(gb, 8); + dst[j * linesize + i] = get_bits(gb, 8); } } @@ -89,29 +90,30 @@ static inline void decode4x4(GetBitContext *gb, uint8_t *dst, int linesize) case 1: v[0] = get_bits(gb, 8); for (j = 0; j < 4; j++) - memset(dst + j*linesize, v[0], 4); + memset(dst + j * linesize, v[0], 4); break; case 2: v[0] = get_bits(gb, 8); v[1] = get_bits(gb, 8); for (j = 2; j >= 0; j -= 2) { for (i = 0; i < 4; i++) - dst[j*linesize + i] = v[get_bits1(gb)]; + dst[j * linesize + i] = v[get_bits1(gb)]; for (i = 0; i < 4; i++) - dst[(j+1)*linesize + i] = v[get_bits1(gb)]; + dst[(j + 1) * linesize + i] = v[get_bits1(gb)]; } break; case 3: for (j = 0; j < 4; j += 2) for (i = 0; i < 4; i += 2) - decode2x2(gb, dst + j*linesize + i, linesize); + decode2x2(gb, dst + j * linesize + i, linesize); } } /** * Decode 8x8 block */ -static inline void decode8x8(GetBitContext *gb, uint8_t *dst, int linesize, DSPContext *dsp) +static inline void decode8x8(GetBitContext *gb, uint8_t *dst, int linesize, + DSPContext *dsp) { int i, j, v[2]; @@ -124,22 +126,21 @@ static inline void decode8x8(GetBitContext *gb, uint8_t *dst, int linesize, DSPC v[0] = get_bits(gb, 8); v[1] = get_bits(gb, 8); for (j = 7; j >= 0; j--) - for (i = 0; i < 8; i++) - dst[j*linesize + i] = v[get_bits1(gb)]; + for (i = 0; i < 8; i++) + dst[j * linesize + i] = v[get_bits1(gb)]; break; case 3: for (j = 0; j < 8; j += 4) for (i = 0; i < 8; i += 4) - decode4x4(gb, dst + j*linesize + i, linesize); + decode4x4(gb, dst + j * linesize + i, linesize); } } -static int decode_frame(AVCodecContext *avctx, - void *data, int *got_frame, +static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt) { - JvContext *s = avctx->priv_data; - const uint8_t *buf = avpkt->data; + JvContext *s = avctx->priv_data; + const uint8_t *buf = avpkt->data; const uint8_t *buf_end = buf + avpkt->size; int video_size, video_type, i, j, ret; @@ -164,16 +165,19 @@ static int decode_frame(AVCodecContext *avctx, for (j = 0; j < avctx->height; j += 8) for (i = 0; i < avctx->width; i += 8) - decode8x8(&gb, s->frame->data[0] + j * s->frame->linesize[0] + i, + decode8x8(&gb, + s->frame->data[0] + j * s->frame->linesize[0] + i, s->frame->linesize[0], &s->dsp); buf += video_size; } else if (video_type == 2) { int v = *buf++; for (j = 0; j < avctx->height; j++) - memset(s->frame->data[0] + j * s->frame->linesize[0], v, avctx->width); + memset(s->frame->data[0] + j * s->frame->linesize[0], + v, avctx->width); } else { - av_log(avctx, AV_LOG_WARNING, "unsupported frame type %i\n", video_type); + av_log(avctx, AV_LOG_WARNING, + "unsupported frame type %i\n", video_type); return AVERROR_INVALIDDATA; } } @@ -191,7 +195,7 @@ static int decode_frame(AVCodecContext *avctx, s->frame->key_frame = 1; s->frame->pict_type = AV_PICTURE_TYPE_I; s->frame->palette_has_changed = s->palette_has_changed; - s->palette_has_changed = 0; + s->palette_has_changed = 0; memcpy(s->frame->data[1], s->palette, AVPALETTE_SIZE); if ((ret = av_frame_ref(data, s->frame)) < 0) diff --git a/libavformat/jvdec.c b/libavformat/jvdec.c index 27ec7ad317..e8d44b0fd8 100644 --- a/libavformat/jvdec.c +++ b/libavformat/jvdec.c @@ -27,6 +27,7 @@ #include "libavutil/channel_layout.h" #include "libavutil/intreadwrite.h" + #include "avformat.h" #include "internal.h" @@ -96,17 +97,18 @@ static int read_header(AVFormatContext *s) avio_skip(pb, 4); - ast->codec->codec_type = AVMEDIA_TYPE_AUDIO; - ast->codec->codec_id = AV_CODEC_ID_PCM_U8; - ast->codec->codec_tag = 0; /* no fourcc */ - ast->codec->sample_rate = avio_rl16(pb); - ast->codec->channels = 1; + ast->codec->codec_type = AVMEDIA_TYPE_AUDIO; + ast->codec->codec_id = AV_CODEC_ID_PCM_U8; + ast->codec->codec_tag = 0; /* no fourcc */ + ast->codec->sample_rate = avio_rl16(pb); + ast->codec->channels = 1; ast->codec->channel_layout = AV_CH_LAYOUT_MONO; avpriv_set_pts_info(ast, 64, 1, ast->codec->sample_rate); avio_skip(pb, 10); - ast->index_entries = av_malloc(ast->nb_index_entries * sizeof(*ast->index_entries)); + ast->index_entries = av_malloc(ast->nb_index_entries * + sizeof(*ast->index_entries)); if (!ast->index_entries) return AVERROR(ENOMEM); @@ -115,18 +117,18 @@ static int read_header(AVFormatContext *s) return AVERROR(ENOMEM); offset = 0x68 + ast->nb_index_entries * 16; - for(i = 0; i < ast->nb_index_entries; i++) { + for (i = 0; i < ast->nb_index_entries; i++) { AVIndexEntry *e = ast->index_entries + i; JVFrame *jvf = jv->frames + i; /* total frame size including audio, video, palette data and padding */ - e->size = avio_rl32(pb); - e->timestamp = i; - e->pos = offset; - offset += e->size; + e->size = avio_rl32(pb); + e->timestamp = i; + e->pos = offset; + offset += e->size; - jvf->audio_size = avio_rl32(pb); - jvf->video_size = avio_rl32(pb); + jvf->audio_size = avio_rl32(pb); + jvf->video_size = avio_rl32(pb); jvf->palette_size = avio_r8(pb) ? 768 : 0; if ((jvf->video_size | jvf->audio_size) & ~0xFFFFFF || @@ -137,19 +139,19 @@ static int read_header(AVFormatContext *s) read_close(s); return AVERROR_INVALIDDATA; } - jvf->audio_size = - jvf->video_size = + jvf->audio_size = + jvf->video_size = jvf->palette_size = 0; } if (avio_r8(pb)) - av_log(s, AV_LOG_WARNING, "unsupported audio codec\n"); + av_log(s, AV_LOG_WARNING, "unsupported audio codec\n"); jvf->video_type = avio_r8(pb); avio_skip(pb, 1); e->timestamp = jvf->audio_size ? audio_pts : AV_NOPTS_VALUE; - audio_pts += jvf->audio_size; + audio_pts += jvf->audio_size; e->flags = jvf->video_type != 1 ? AVINDEX_KEYFRAME : 0; } @@ -168,10 +170,10 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt) const AVIndexEntry *e = ast->index_entries + jv->pts; const JVFrame *jvf = jv->frames + jv->pts; - switch(jv->state) { + switch (jv->state) { case JV_AUDIO: jv->state++; - if (jvf->audio_size ) { + if (jvf->audio_size) { if (av_get_packet(s->pb, pkt, jvf->audio_size) < 0) return AVERROR(ENOMEM); pkt->stream_index = 0; @@ -187,7 +189,7 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt) return AVERROR(ENOMEM); AV_WL32(pkt->data, jvf->video_size); - pkt->data[4] = jvf->video_type; + pkt->data[4] = jvf->video_type; if ((size = avio_read(pb, pkt->data + JV_PREAMBLE_SIZE, size)) < 0) return AVERROR(EIO); memset(pkt->data + JV_PREAMBLE_SIZE + size, 0, FF_INPUT_BUFFER_PADDING_SIZE); @@ -220,10 +222,10 @@ static int read_seek(AVFormatContext *s, int stream_index, AVStream *ast = s->streams[0]; int i; - if (flags & (AVSEEK_FLAG_BYTE|AVSEEK_FLAG_FRAME)) + if (flags & (AVSEEK_FLAG_BYTE | AVSEEK_FLAG_FRAME)) return AVERROR(ENOSYS); - switch(stream_index) { + switch (stream_index) { case 0: i = av_index_search_timestamp(ast, ts, flags); break; |