2
2
* pixel format descriptor
3
3
* Copyright (c) 2009 Michael Niedermayer <michaelni@gmx.at>
5
* This file is part of FFmpeg.
5
* This file is part of Libav.
7
* FFmpeg is free software; you can redistribute it and/or
7
* Libav is free software; you can redistribute it and/or
8
8
* modify it under the terms of the GNU Lesser General Public
9
9
* License as published by the Free Software Foundation; either
10
10
* version 2.1 of the License, or (at your option) any later version.
12
* FFmpeg is distributed in the hope that it will be useful,
12
* Libav is distributed in the hope that it will be useful,
13
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
15
* Lesser General Public License for more details.
17
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
18
* License along with Libav; if not, write to the Free Software
19
19
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22
24
#include "pixfmt.h"
23
25
#include "pixdesc.h"
25
27
#include "intreadwrite.h"
27
void read_line(uint16_t *dst, const uint8_t *data[4], const int linesize[4],
28
const AVPixFmtDescriptor *desc, int x, int y, int c, int w, int read_pal_component)
29
void av_read_image_line(uint16_t *dst, const uint8_t *data[4], const int linesize[4],
30
const AVPixFmtDescriptor *desc, int x, int y, int c, int w, int read_pal_component)
30
32
AVComponentDescriptor comp= desc->comp[c];
31
33
int plane= comp.plane;
53
55
const uint8_t *p = data[plane]+ y*linesize[plane] + x*step + comp.offset_plus1-1;
56
int is_8bit = shift + depth <= 8;
59
p += !!(flags & PIX_FMT_BE);
57
if(flags & PIX_FMT_BE) val= AV_RB16(p);
62
int val = is_8bit ? *p :
63
flags & PIX_FMT_BE ? AV_RB16(p) : AV_RL16(p);
59
64
val = (val>>shift) & mask;
60
65
if(read_pal_component)
61
66
val= data[1][4*val + c];
68
void write_line(const uint16_t *src, uint8_t *data[4], const int linesize[4],
69
const AVPixFmtDescriptor *desc, int x, int y, int c, int w)
73
void av_write_image_line(const uint16_t *src, uint8_t *data[4], const int linesize[4],
74
const AVPixFmtDescriptor *desc, int x, int y, int c, int w)
71
76
AVComponentDescriptor comp = desc->comp[c];
72
77
int plane = comp.plane;
89
94
int shift = comp.shift;
90
95
uint8_t *p = data[plane]+ y*linesize[plane] + x*step + comp.offset_plus1-1;
93
if (flags & PIX_FMT_BE) {
94
uint16_t val = AV_RB16(p) | (*src++<<shift);
97
uint16_t val = AV_RL16(p) | (*src++<<shift);
97
if (shift + depth <= 8) {
98
p += !!(flags & PIX_FMT_BE);
100
*p |= (*src++<<shift);
105
if (flags & PIX_FMT_BE) {
106
uint16_t val = AV_RB16(p) | (*src++<<shift);
109
uint16_t val = AV_RL16(p) | (*src++<<shift);
839
875
return bits >> log2_pixels;
878
char *av_get_pix_fmt_string (char *buf, int buf_size, enum PixelFormat pix_fmt)
882
snprintf (buf, buf_size, "name " " nb_components" " nb_bits");
884
const AVPixFmtDescriptor *pixdesc = &av_pix_fmt_descriptors[pix_fmt];
885
snprintf(buf, buf_size, "%-11s %7d %10d",
886
pixdesc->name, pixdesc->nb_components, av_get_bits_per_pixel(pixdesc));