1 /*
2 * Alias PIX image encoder
3 * Copyright (C) 2014 Vittorio Giovara <vittorio.giovara@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
23
27
28 #define ALIAS_HEADER_SIZE 10
29
32 {
35
36 #if FF_API_CODED_FRAME
41 #endif
42
45
46 if (width > 65535 || height > 65535 ||
50 }
51
54 bits_pixel = 8;
55 break;
57 bits_pixel = 24;
58 break;
59 default:
61 }
62
66 return ret;
67 }
68
70
71 /* Encode header. */
72 bytestream_put_be16(&buf, width);
73 bytestream_put_be16(&buf, height);
74 bytestream_put_be32(&buf, 0); /* X, Y offset */
75 bytestream_put_be16(&buf, bits_pixel);
76
77 for (j = 0; j <
height; j++) {
79 for (i = 0; i <
width; ) {
82
84 pixel = *in_buf;
85 while (count < 255 && count + i < width && pixel == *in_buf) {
86 count++;
87 in_buf++;
88 }
89 bytestream_put_byte(&buf, count);
90 bytestream_put_byte(&buf, pixel);
91 } else { /* AV_PIX_FMT_BGR24 */
93 while (count < 255 && count + i < width &&
95 count++;
96 in_buf += 3;
97 }
98 bytestream_put_byte(&buf, count);
99 bytestream_put_be24(&buf, pixel);
100 }
102 }
103 }
104
105 /* Total length */
108 *got_packet = 1;
109
110 return 0;
111 }
112
121 },
122 };
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
This structure describes decoded (raw) audio or video data.
void av_shrink_packet(AVPacket *pkt, int size)
Reduce packet size, correctly zeroing padding.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
#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. ...
#define ALIAS_HEADER_SIZE
const char * name
Name of the codec implementation.
int flags
A combination of AV_PKT_FLAG values.
enum AVPictureType pict_type
Picture type of the frame.
int width
picture width / height.
packed RGB 8:8:8, 24bpp, BGRBGR...
AVCodec ff_alias_pix_encoder
Libavcodec external API header.
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_WB32 unsigned int_TMPL AV_RB24
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
main external API structure.
BYTE int const BYTE int int int height
int ff_alloc_packet2(AVCodecContext *avctx, AVPacket *avpkt, int64_t size, int64_t min_size)
Check AVPacket size and/or allocate data.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
#define FF_DISABLE_DEPRECATION_WARNINGS
common internal api header.
attribute_deprecated AVFrame * coded_frame
the picture in the bitstream
#define FF_ENABLE_DEPRECATION_WARNINGS
int key_frame
1 -> keyframe, 0-> not
static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame, int *got_packet)
AVPixelFormat
Pixel format.
This structure stores compressed data.