switch(st->codec.pix_fmt) { case PIX_FMT_YUV420P: packet_size = (width * height * 3) / 2; break; case PIX_FMT_YUV422: packet_size = (width * height * 2); break; case PIX_FMT_BGR24: case PIX_FMT_RGB24: packet_size = (width * height * 3); break; default:
packet_size = avpicture_get_size(st->codec.pix_fmt, width, height); if (packet_size < 0)
static int rawvideo_read_packet(AVFormatContext *s, AVPacket *pkt){    int packet_size, ret, width, height;    AVStream *st = s->streams[0];    width = st->codec.width;    height = st->codec.height;    switch(st->codec.pix_fmt) {    case PIX_FMT_YUV420P:        packet_size = (width * height * 3) / 2;        break;    case PIX_FMT_YUV422:        packet_size = (width * height * 2);        break;    case PIX_FMT_BGR24:    case PIX_FMT_RGB24:        packet_size = (width * height * 3);        break;    default:        av_abort();        break;    }    if (av_new_packet(pkt, packet_size) < 0)        return -EIO;    pkt->stream_index = 0;#if 0    /* bypass buffered I/O */    ret = url_read(url_fileno(&s->pb), pkt->data, pkt->size);#else    ret = get_buffer(&s->pb, pkt->data, pkt->size);#endif    if (ret != pkt->size) {        av_free_packet(pkt);        return -EIO;    } else {        return 0;    }}