1 /*
2 * Microsoft Windows ICO muxer
3 * Copyright (c) 2012 Michael Bradshaw <mjbshaw gmail com>
4 *
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22 /**
23 * @file
24 * Microsoft Windows ICO muxer
25 */
26
30
31 typedef struct {
38
44
46 {
57 }
62 }
63 } else {
67 }
68
73 }
74
75 return 0;
76 }
77
79 {
82 int ret;
83 int i;
84
88 }
89
92
95 avio_skip(pb, 2);
// skip the number of images
96
99 return ret;
100
101 // Fill in later when writing trailer...
103 }
104
108
110
111 return 0;
112 }
113
115 {
120 int i;
121
125 }
126
128
132
136
138 } else { // BMP
139 if (
AV_RL32(pkt->
data + 14) != 40) {
// must be BITMAPINFOHEADER
142 }
143
144 image->
bits =
AV_RL16(pkt->
data + 28);
// allows things like 1bit and 4bit images to be preserved
146
147 avio_write(pb, pkt->
data + 14, 8);
// Skip the BITMAPFILEHEADER header
150
151 for (i = 0; i < par->
height * (par->
width + 7) / 8; ++i)
152 avio_w8(pb, 0x00);
// Write bitmask (opaque)
153 }
154
155 return 0;
156 }
157
159 {
162 int i;
163
165
167
171
175 } else {
177 }
178
184 }
185
187
188 return 0;
189 }
190
195 .mime_type = "image/vnd.microsoft.icon",
196 .extensions = "ico",
203 };
static void write_packet(OutputFile *of, AVPacket *pkt, OutputStream *ost, int unqueue)
void avio_wl16(AVIOContext *s, unsigned int val)
AVOutputFormat ff_ico_muxer
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
packed RGB 5:5:5, 16bpp, (msb)1X 5R 5G 5B(lsb), little-endian, X=unused/undefined ...
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_RL16
This struct describes the properties of an encoded stream.
void avio_wl32(AVIOContext *s, unsigned int val)
8 bits with AV_PIX_FMT_RGB32 palette
AVStream ** streams
A list of all streams in the file.
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
static int ico_write_header(AVFormatContext *s)
void avio_write(AVIOContext *s, const unsigned char *buf, int size)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
static const uint8_t offset[127][2]
static void * av_mallocz_array(size_t nmemb, size_t size)
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
const AVCodecDescriptor * avcodec_descriptor_get(enum AVCodecID id)
unsigned int nb_streams
Number of elements in AVFormatContext.streams.
int seekable
A combination of AVIO_SEEKABLE_ flags or 0 when the stream is not seekable.
int void avio_flush(AVIOContext *s)
Force flushing of buffered data.
static int write_trailer(AVFormatContext *s1)
packed RGB 8:8:8, 24bpp, BGRBGR...
#define AVIO_SEEKABLE_NORMAL
Seeking works like for a local file.
AVIOContext * pb
I/O context.
void avio_w8(AVIOContext *s, int b)
static int ico_check_attributes(AVFormatContext *s, const AVCodecParameters *p)
static int ico_write_trailer(AVFormatContext *s)
const char * name
Name of the codec described by this descriptor.
This struct describes the properties of a single codec described by an AVCodecID. ...
void * priv_data
Format private data.
static void write_header(FFV1Context *f)
int bits_per_coded_sample
The number of bits per sample in the codedwords.
AVCodecParameters * codecpar
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
This structure stores compressed data.
static int ico_write_packet(AVFormatContext *s, AVPacket *pkt)