summaryrefslogtreecommitdiff
path: root/libavformat/icoenc.c
diff options
context:
space:
mode:
authorDerek Buitenhuis <derek.buitenhuis@gmail.com>2016-04-10 20:58:15 +0100
committerDerek Buitenhuis <derek.buitenhuis@gmail.com>2016-04-10 20:59:55 +0100
commit6f69f7a8bf6a0d013985578df2ef42ee6b1c7994 (patch)
tree0c2ec8349ff1763d5f48454b8b9f26374dbd80b0 /libavformat/icoenc.c
parent60b75186b2c878b6257b43c8fcc0b1356ada218e (diff)
parent9200514ad8717c63f82101dc394f4378854325bf (diff)
Merge commit '9200514ad8717c63f82101dc394f4378854325bf'
* commit '9200514ad8717c63f82101dc394f4378854325bf': lavf: replace AVStream.codec with AVStream.codecpar This has been a HUGE effort from: - Derek Buitenhuis <derek.buitenhuis@gmail.com> - Hendrik Leppkes <h.leppkes@gmail.com> - wm4 <nfxjfg@googlemail.com> - Clément Bœsch <clement@stupeflix.com> - James Almer <jamrial@gmail.com> - Michael Niedermayer <michael@niedermayer.cc> - Rostislav Pehlivanov <atomnuker@gmail.com> Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
Diffstat (limited to 'libavformat/icoenc.c')
-rw-r--r--libavformat/icoenc.c46
1 files changed, 23 insertions, 23 deletions
diff --git a/libavformat/icoenc.c b/libavformat/icoenc.c
index 53d4420f37..a7ada19fcd 100644
--- a/libavformat/icoenc.c
+++ b/libavformat/icoenc.c
@@ -42,33 +42,33 @@ typedef struct {
IcoImage *images;
} IcoMuxContext;
-static int ico_check_attributes(AVFormatContext *s, const AVCodecContext *c)
+static int ico_check_attributes(AVFormatContext *s, const AVCodecParameters *p)
{
- if (c->codec_id == AV_CODEC_ID_BMP) {
- if (c->pix_fmt == AV_PIX_FMT_PAL8 && AV_PIX_FMT_RGB32 != AV_PIX_FMT_BGRA) {
+ if (p->codec_id == AV_CODEC_ID_BMP) {
+ if (p->format == AV_PIX_FMT_PAL8 && AV_PIX_FMT_RGB32 != AV_PIX_FMT_BGRA) {
av_log(s, AV_LOG_ERROR, "Wrong endianness for bmp pixel format\n");
return AVERROR(EINVAL);
- } else if (c->pix_fmt != AV_PIX_FMT_PAL8 &&
- c->pix_fmt != AV_PIX_FMT_RGB555LE &&
- c->pix_fmt != AV_PIX_FMT_BGR24 &&
- c->pix_fmt != AV_PIX_FMT_BGRA) {
+ } else if (p->format != AV_PIX_FMT_PAL8 &&
+ p->format != AV_PIX_FMT_RGB555LE &&
+ p->format != AV_PIX_FMT_BGR24 &&
+ p->format != AV_PIX_FMT_BGRA) {
av_log(s, AV_LOG_ERROR, "BMP must be 1bit, 4bit, 8bit, 16bit, 24bit, or 32bit\n");
return AVERROR(EINVAL);
}
- } else if (c->codec_id == AV_CODEC_ID_PNG) {
- if (c->pix_fmt != AV_PIX_FMT_RGBA) {
+ } else if (p->codec_id == AV_CODEC_ID_PNG) {
+ if (p->format != AV_PIX_FMT_RGBA) {
av_log(s, AV_LOG_ERROR, "PNG in ico requires pixel format to be rgba\n");
return AVERROR(EINVAL);
}
} else {
- const AVCodecDescriptor *codesc = avcodec_descriptor_get(c->codec_id);
+ const AVCodecDescriptor *codesc = avcodec_descriptor_get(p->codec_id);
av_log(s, AV_LOG_ERROR, "Unsupported codec %s\n", codesc ? codesc->name : "");
return AVERROR(EINVAL);
}
- if (c->width > 256 ||
- c->height > 256) {
- av_log(s, AV_LOG_ERROR, "Unsupported dimensions %dx%d (dimensions cannot exceed 256x256)\n", c->width, c->height);
+ if (p->width > 256 ||
+ p->height > 256) {
+ av_log(s, AV_LOG_ERROR, "Unsupported dimensions %dx%d (dimensions cannot exceed 256x256)\n", p->width, p->height);
return AVERROR(EINVAL);
}
@@ -95,7 +95,7 @@ static int ico_write_header(AVFormatContext *s)
avio_skip(pb, 2); // skip the number of images
for (i = 0; i < s->nb_streams; i++) {
- if (ret = ico_check_attributes(s, s->streams[i]->codec))
+ if (ret = ico_check_attributes(s, s->streams[i]->codecpar))
return ret;
// Fill in later when writing trailer...
@@ -116,7 +116,7 @@ static int ico_write_packet(AVFormatContext *s, AVPacket *pkt)
IcoMuxContext *ico = s->priv_data;
IcoImage *image;
AVIOContext *pb = s->pb;
- AVCodecContext *c = s->streams[pkt->stream_index]->codec;
+ AVCodecParameters *par = s->streams[pkt->stream_index]->codecpar;
int i;
if (ico->current_image >= ico->nb_images) {
@@ -127,11 +127,11 @@ static int ico_write_packet(AVFormatContext *s, AVPacket *pkt)
image = &ico->images[ico->current_image++];
image->offset = avio_tell(pb);
- image->width = (c->width == 256) ? 0 : c->width;
- image->height = (c->height == 256) ? 0 : c->height;
+ image->width = (par->width == 256) ? 0 : par->width;
+ image->height = (par->height == 256) ? 0 : par->height;
- if (c->codec_id == AV_CODEC_ID_PNG) {
- image->bits = c->bits_per_coded_sample;
+ if (par->codec_id == AV_CODEC_ID_PNG) {
+ image->bits = par->bits_per_coded_sample;
image->size = pkt->size;
avio_write(pb, pkt->data, pkt->size);
@@ -142,13 +142,13 @@ static int ico_write_packet(AVFormatContext *s, AVPacket *pkt)
}
image->bits = AV_RL16(pkt->data + 28); // allows things like 1bit and 4bit images to be preserved
- image->size = pkt->size - 14 + c->height * (c->width + 7) / 8;
+ image->size = pkt->size - 14 + par->height * (par->width + 7) / 8;
avio_write(pb, pkt->data + 14, 8); // Skip the BITMAPFILEHEADER header
avio_wl32(pb, AV_RL32(pkt->data + 22) * 2); // rewrite height as 2 * height
avio_write(pb, pkt->data + 26, pkt->size - 26);
- for (i = 0; i < c->height * (c->width + 7) / 8; ++i)
+ for (i = 0; i < par->height * (par->width + 7) / 8; ++i)
avio_w8(pb, 0x00); // Write bitmask (opaque)
}
@@ -169,8 +169,8 @@ static int ico_write_trailer(AVFormatContext *s)
avio_w8(pb, ico->images[i].width);
avio_w8(pb, ico->images[i].height);
- if (s->streams[i]->codec->codec_id == AV_CODEC_ID_BMP &&
- s->streams[i]->codec->pix_fmt == AV_PIX_FMT_PAL8) {
+ if (s->streams[i]->codecpar->codec_id == AV_CODEC_ID_BMP &&
+ s->streams[i]->codecpar->format == AV_PIX_FMT_PAL8) {
avio_w8(pb, (ico->images[i].bits >= 8) ? 0 : 1 << ico->images[i].bits);
} else {
avio_w8(pb, 0);