On Thu, Oct 17, 2013 at 07:41:11PM +0200, David Kment wrote:
> Changelog | 1 +
> doc/general.texi | 3 +
> libavcodec/Makefile | 1 +
> libavcodec/allcodecs.c | 1 +
> libavcodec/avcodec.h | 1 +
> libavcodec/codec_desc.c | 7 +
> libavcodec/hnm4video.c | 459
> +++++++++++++++++++++++++++++++++++++++++++++++
> libavformat/Makefile | 1 +
> libavformat/allformats.c | 1 +
> libavformat/hnm.c | 206 +++++++++++++++++++++
> 10 files changed, 681 insertions(+)
Please also bump minor in libavcodec/version.h and libavformat/version.h.
> --- a/libavcodec/avcodec.h
> +++ b/libavcodec/avcodec.h
> @@ -274,6 +274,7 @@ enum AVCodecID {
> AV_CODEC_ID_ESCAPE130,
> AV_CODEC_ID_G2M,
> AV_CODEC_ID_WEBP,
> + AV_CODEC_ID_HNM4_VIDEO,
tabs
> --- /dev/null
> +++ b/libavcodec/hnm4video.c
> @@ -0,0 +1,459 @@
> +
> +static void unpack_intraframe(AVCodecContext *avctx, uint8_t *src, uint32_t
> size)
> +{
> + Hnm4VideoContext *hnm = avctx->priv_data;
> + GetByteContext gb;
> + uint32_t bitbuf;
> + int bits;
> +
> + uint32_t writeoffset, count;
> + uint16_t word;
> + int32_t offset;
> +
> + writeoffset = 0;
> + bitbuf = 0;
> + bits = 0;
Merge declaration and initialization.
> + while (bytestream2_tell(&gb) < size) {
> + if (getbit(&gb, &bitbuf, &bits)) {
> + if(writeoffset >= hnm->width * hnm->height) {
if (
> + if (!count) {count = bytestream2_get_byte(&gb);}
> + if (!count) {return;}
Break these lines.
> + if(offset < 0 || offset + count >= hnm->width * hnm->height) {
if (
> + if (previous) {
> + while (left > 0) {
> + if (backline) {
> + hnm->current[writeoffset++] =
> hnm->previous[offset-(2 * hnm->width)+1];
Add spaces around - and +.
> + while (left > 0) {
> + if (backline) {
> + hnm->current[writeoffset++] = hnm->current[offset-(2
> * hnm->width)+1];
same
> + if(offset + hnm->width + count >= hnm->width * hnm->height) {
if (
> + av_log(avctx, AV_LOG_ERROR, "attempting to read out of
> bounds");
> + break;
> + } else if(writeoffset + hnm->width + count >= hnm->width *
> hnm->height) {
if (
> +static av_cold int hnm_decode_init(AVCodecContext *avctx)
> +{
> + Hnm4VideoContext *hnm = avctx->priv_data;
> +
> + if(avctx->extradata_size < 1) {
if (
> + hnm->version = avctx->extradata[0];
> + avctx->pix_fmt = AV_PIX_FMT_PAL8;
> + hnm->width = avctx->width;
> + hnm->height = avctx->height;
> +
> + hnm->buffer1 = av_mallocz(avctx->width * avctx->height);
> + hnm->buffer2 = av_mallocz(avctx->width * avctx->height);
> + hnm->processed = av_mallocz(avctx->width * avctx->height);
You could vertically align the = for better readability here.
> + if (!hnm->buffer1 || !hnm->buffer2 || !hnm->processed) {
> + av_log(avctx, AV_LOG_ERROR, "av_mallocz() failed\n");
> + if(hnm->buffer1) {av_freep(&hnm->buffer1);}
> + if(hnm->buffer2) {av_freep(&hnm->buffer2);}
> + if(hnm->processed) {av_freep(&hnm->processed);}
Break these lines.
> --- /dev/null
> +++ b/libavformat/hnm.c
> @@ -0,0 +1,206 @@
> +static int hnm_read_header(AVFormatContext *s)
> +{
> + Hnm4DemuxContext *hnm = s->priv_data;
> + AVIOContext *pb = s->pb;
> + AVStream *vst;
> +
> + /* default context members */
> + hnm->pts = 0;
> + av_init_packet(&hnm->vpkt);
> + hnm->vpkt.data = NULL; hnm->vpkt.size = 0;
> +
> + hnm->superchunk_remaining = 0;
> +
> + avio_skip(pb, 8);
> + hnm->width = avio_rl16(pb);
> + hnm->height = avio_rl16(pb);
> + hnm->filesize = avio_rl32(pb);
> + hnm->frames = avio_rl32(pb);
> + hnm->taboffset = avio_rl32(pb);
> + hnm->bits = avio_rl16(pb);
> + hnm->channels = avio_rl16(pb);
> + hnm->framesize = avio_rl32(pb);
> + avio_skip(pb, 32);
> +
> + hnm->currentframe = 0;
You could vertically align the = for better readability here.
> +
> + if(hnm->width < 320 || hnm->width > 640
> + || hnm->height < 150 || hnm->height > 480) {
if (, move the || to the end of the line.
> + vst->codec->extradata = av_mallocz(1);
> + vst->codec->extradata_size = 1;
> + memcpy(vst->codec->extradata, &hnm->version, 1);
> + vst->codec->codec_type = AVMEDIA_TYPE_VIDEO;
> + vst->codec->codec_id = AV_CODEC_ID_HNM4_VIDEO;
> + vst->codec->codec_tag = 0;
> + vst->codec->width = hnm->width;
> + vst->codec->height = hnm->height;
> +
> + vst->start_time = 0;
You could vertically align the = for better readability here.
> + if(chunk_size > hnm->superchunk_remaining) {
if (
> + switch(chunk_id) {
switch (
> +
> + case HNM4_CHUNK_ID_PL:
> + case HNM4_CHUNK_ID_IZ:
> + case HNM4_CHUNK_ID_IU:
> + avio_seek(pb, -8, SEEK_CUR);
> + ret += av_get_packet(pb, pkt, chunk_size);
> + hnm->superchunk_remaining -= chunk_size;
> + if (chunk_id == HNM4_CHUNK_ID_IZ || chunk_id ==
> HNM4_CHUNK_ID_IU) {
> + hnm->currentframe++;
> + }
> + break;
> +
> + case HNM4_CHUNK_ID_SD:
> + avio_skip(pb, chunk_size - 8);
> + hnm->superchunk_remaining -= chunk_size;
> + break;
> +
> + default:
> + av_log(s, AV_LOG_WARNING, "unknown chunk found: %d, offset:
> %d\n", chunk_id, (int) avio_tell(pb));
> + avio_skip(pb, chunk_size - 8);
> + hnm->superchunk_remaining -= chunk_size;
> + break;
> + }
Indent switch/case at the same depth.
Diego
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel