0
|
1 /*
|
|
2 * BPG encoder
|
|
3 *
|
|
4 * Copyright (c) 2014 Fabrice Bellard
|
|
5 *
|
|
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7 * of this software and associated documentation files (the "Software"), to deal
|
|
8 * in the Software without restriction, including without limitation the rights
|
|
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10 * copies of the Software, and to permit persons to whom the Software is
|
|
11 * furnished to do so, subject to the following conditions:
|
|
12 *
|
|
13 * The above copyright notice and this permission notice shall be included in
|
|
14 * all copies or substantial portions of the Software.
|
|
15 *
|
|
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
22 * THE SOFTWARE.
|
|
23 */
|
|
24 #ifdef __cplusplus
|
|
25 extern "C" {
|
|
26 #endif
|
|
27
|
|
28 #include "libbpg.h"
|
|
29
|
|
30 typedef struct {
|
|
31 int w, h;
|
|
32 BPGImageFormatEnum format; /* x_VIDEO values are forbidden here */
|
|
33 uint8_t c_h_phase; /* 4:2:2 or 4:2:0 : give the horizontal chroma
|
|
34 position. 0=MPEG2, 1=JPEG. */
|
|
35 uint8_t has_alpha;
|
|
36 uint8_t has_w_plane;
|
|
37 uint8_t limited_range;
|
|
38 uint8_t premultiplied_alpha;
|
|
39 BPGColorSpaceEnum color_space;
|
|
40 uint8_t bit_depth;
|
|
41 uint8_t pixel_shift; /* (1 << pixel_shift) bytes per pixel */
|
|
42 uint8_t *data[4];
|
|
43 int linesize[4];
|
|
44 } Image;
|
|
45
|
|
46 typedef struct {
|
|
47 int width;
|
|
48 int height;
|
|
49 int chroma_format; /* 0-3 */
|
|
50 int bit_depth; /* 8-14 */
|
|
51 int intra_only; /* 0-1 */
|
|
52
|
|
53 int qp; /* quantizer 0-51 */
|
|
54 int lossless; /* 0-1 lossless mode */
|
|
55 int sei_decoded_picture_hash; /* 0=no hash, 1=MD5 hash */
|
|
56 int compress_level; /* 1-9 */
|
|
57 int verbose;
|
|
58 } HEVCEncodeParams;
|
|
59
|
33
|
60 typedef struct HEVCEncoderContext HEVCEncoderContext;
|
0
|
61
|
|
62 typedef struct {
|
|
63 HEVCEncoderContext *(*open)(const HEVCEncodeParams *params);
|
|
64 int (*encode)(HEVCEncoderContext *s, Image *img);
|
|
65 int (*close)(HEVCEncoderContext *s, uint8_t **pbuf);
|
|
66 } HEVCEncoder;
|
|
67
|
|
68 extern HEVCEncoder jctvc_encoder;
|
|
69 extern HEVCEncoder x265_hevc_encoder;
|
|
70
|
33
|
71 int x265_encode_picture(uint8_t **pbuf, Image *img,
|
0
|
72 const HEVCEncodeParams *params);
|
|
73 void save_yuv1(Image *img, FILE *f);
|
|
74 void save_yuv(Image *img, const char *filename);
|
|
75
|
|
76 #ifdef __cplusplus
|
|
77 }
|
|
78 #endif
|
|
79
|