X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavutil%2Fpixdesc.c;h=efc7c7ea0eadb6e4651ae9769931f6a3f3209b93;hb=812f2376eecc19c40a95ade1f7a43b762106e0f7;hp=e4ced8ebfa238b3f7a735bbc95112909f83c923c;hpb=f47a7cb7774b78be489b1fcb8459423b378d7d75;p=ffmpeg diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c index e4ced8ebfa2..efc7c7ea0ea 100644 --- a/libavutil/pixdesc.c +++ b/libavutil/pixdesc.c @@ -2,30 +2,32 @@ * 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 */ +#include +#include #include "pixfmt.h" #include "pixdesc.h" #include "intreadwrite.h" -void read_line(uint16_t *dst, const uint8_t *data[4], const int linesize[4], - const AVPixFmtDescriptor *desc, int x, int y, int c, int w, int read_pal_component) +void av_read_image_line(uint16_t *dst, const uint8_t *data[4], const int linesize[4], + const AVPixFmtDescriptor *desc, int x, int y, int c, int w, int read_pal_component) { AVComponentDescriptor comp= desc->comp[c]; int plane= comp.plane; @@ -51,11 +53,14 @@ void read_line(uint16_t *dst, const uint8_t *data[4], const int linesize[4], } } 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]; @@ -65,8 +70,8 @@ void read_line(uint16_t *dst, const uint8_t *data[4], const int linesize[4], } } -void write_line(const uint16_t *src, uint8_t *data[4], const int linesize[4], - const AVPixFmtDescriptor *desc, int x, int y, int c, int w) +void av_write_image_line(const uint16_t *src, uint8_t *data[4], const int linesize[4], + const AVPixFmtDescriptor *desc, int x, int y, int c, int w) { AVComponentDescriptor comp = desc->comp[c]; int plane = comp.plane; @@ -89,15 +94,23 @@ void write_line(const uint16_t *src, uint8_t *data[4], const int linesize[4], 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; +}