00001 /* 00002 * Copyright (c) 2012 Justin Ruggles <justin.ruggles@gmail.com> 00003 * 00004 * This file is part of Libav. 00005 * 00006 * Libav is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU Lesser General Public 00008 * License as published by the Free Software Foundation; either 00009 * version 2.1 of the License, or (at your option) any later version. 00010 * 00011 * Libav is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 * Lesser General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU Lesser General Public 00017 * License along with Libav; if not, write to the Free Software 00018 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00019 */ 00020 00028 #include <stdint.h> 00029 00030 #include "libavutil/intreadwrite.h" 00031 #include "parser.h" 00032 00033 typedef struct CookParseContext { 00034 int duration; 00035 } CookParseContext; 00036 00037 static int cook_parse(AVCodecParserContext *s1, AVCodecContext *avctx, 00038 const uint8_t **poutbuf, int *poutbuf_size, 00039 const uint8_t *buf, int buf_size) 00040 { 00041 CookParseContext *s = s1->priv_data; 00042 00043 if (s->duration) 00044 s1->duration = s->duration; 00045 else if (avctx->extradata && avctx->extradata_size >= 8 && avctx->channels) 00046 s->duration = AV_RB16(avctx->extradata + 4) / avctx->channels; 00047 00048 /* always return the full packet. this parser isn't doing any splitting or 00049 combining, only setting packet duration */ 00050 *poutbuf = buf; 00051 *poutbuf_size = buf_size; 00052 return buf_size; 00053 } 00054 00055 AVCodecParser ff_cook_parser = { 00056 .codec_ids = { AV_CODEC_ID_COOK }, 00057 .priv_data_size = sizeof(CookParseContext), 00058 .parser_parse = cook_parse, 00059 };