| 161 | } |
| 162 | |
| 163 | AVFormatContext *avformat_alloc_context(void) |
| 164 | { |
| 165 | FormatContextInternal *fci; |
| 166 | FFFormatContext *si; |
| 167 | AVFormatContext *s; |
| 168 | |
| 169 | fci = av_mallocz(sizeof(*fci)); |
| 170 | if (!fci) |
| 171 | return NULL; |
| 172 | |
| 173 | si = &fci->fc; |
| 174 | s = &si->pub; |
| 175 | s->av_class = &av_format_context_class; |
| 176 | s->io_open = io_open_default; |
| 177 | s->io_close2= io_close2_default; |
| 178 | |
| 179 | av_opt_set_defaults(s); |
| 180 | |
| 181 | si->pkt = av_packet_alloc(); |
| 182 | si->parse_pkt = av_packet_alloc(); |
| 183 | if (!si->pkt || !si->parse_pkt) { |
| 184 | avformat_free_context(s); |
| 185 | return NULL; |
| 186 | } |
| 187 | |
| 188 | return s; |
| 189 | } |
| 190 | |
| 191 | const AVClass *avformat_get_class(void) |
| 192 | { |