X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavutil%2Fpixdesc.c;h=2b5c2fd27d0ff2defa4384b3eeee6c55b9e6df94;hb=6b0768e2021b90215a2ab55ed427bce91d148148;hp=e2bc6491dafd3fae284c27ce1c89d23b15105af6;hpb=47bfd50a4b4af1b220bc9b9e09cfd56f97be2900;p=ffmpeg diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c index e2bc6491daf..2b5c2fd27d0 100644 --- a/libavutil/pixdesc.c +++ b/libavutil/pixdesc.c @@ -2,20 +2,20 @@ * pixel format descriptor * Copyright (c) 2009 Michael Niedermayer * - * This file is part of FFmpeg. + * This file is part of Libav. * - * FFmpeg is free software; you can redistribute it and/or + * Libav is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * - * FFmpeg is distributed in the hope that it will be useful, + * Libav is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software + * License along with Libav; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -53,11 +53,14 @@ void av_read_image_line(uint16_t *dst, const uint8_t *data[4], const int linesiz } } else { const uint8_t *p = data[plane]+ y*linesize[plane] + x*step + comp.offset_plus1-1; + int is_8bit = shift + depth <= 8; + + if (is_8bit) + p += !!(flags & PIX_FMT_BE); while(w--){ - int val; - if(flags & PIX_FMT_BE) val= AV_RB16(p); - else val= AV_RL16(p); + int val = is_8bit ? *p : + flags & PIX_FMT_BE ? AV_RB16(p) : AV_RL16(p); val = (val>>shift) & mask; if(read_pal_component) val= data[1][4*val + c]; @@ -91,15 +94,23 @@ void av_write_image_line(const uint16_t *src, uint8_t *data[4], const int linesi int shift = comp.shift; uint8_t *p = data[plane]+ y*linesize[plane] + x*step + comp.offset_plus1-1; - while (w--) { - if (flags & PIX_FMT_BE) { - uint16_t val = AV_RB16(p) | (*src++<> log2_pixels; } + +char *av_get_pix_fmt_string (char *buf, int buf_size, enum PixelFormat pix_fmt) +{ + /* print header */ + if (pix_fmt < 0) { + snprintf (buf, buf_size, "name " " nb_components" " nb_bits"); + } else { + const AVPixFmtDescriptor *pixdesc = &av_pix_fmt_descriptors[pix_fmt]; + snprintf(buf, buf_size, "%-11s %7d %10d", + pixdesc->name, pixdesc->nb_components, av_get_bits_per_pixel(pixdesc)); + } + + return buf; +}