You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

642 lines
21KB

  1. /*
  2. * Copyright (c) 2010 Stefano Sabatini
  3. * Copyright (c) 2008 Victor Paesa
  4. *
  5. * This file is part of FFmpeg.
  6. *
  7. * FFmpeg is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2.1 of the License, or (at your option) any later version.
  11. *
  12. * FFmpeg is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with FFmpeg; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  20. */
  21. /**
  22. * @file
  23. * movie video source
  24. *
  25. * @todo use direct rendering (no allocation of a new frame)
  26. * @todo support a PTS correction mechanism
  27. */
  28. /* #define DEBUG */
  29. #include <float.h>
  30. #include "libavutil/avstring.h"
  31. #include "libavutil/avassert.h"
  32. #include "libavutil/opt.h"
  33. #include "libavutil/imgutils.h"
  34. #include "libavutil/timestamp.h"
  35. #include "libavformat/avformat.h"
  36. #include "audio.h"
  37. #include "avcodec.h"
  38. #include "avfilter.h"
  39. #include "formats.h"
  40. #include "internal.h"
  41. #include "video.h"
  42. typedef struct {
  43. AVStream *st;
  44. int done;
  45. } MovieStream;
  46. typedef struct {
  47. /* common A/V fields */
  48. const AVClass *class;
  49. int64_t seek_point; ///< seekpoint in microseconds
  50. double seek_point_d;
  51. char *format_name;
  52. char *file_name;
  53. char *stream_specs; /**< user-provided list of streams, separated by + */
  54. int stream_index; /**< for compatibility */
  55. int loop_count;
  56. AVFormatContext *format_ctx;
  57. int eof;
  58. AVPacket pkt, pkt0;
  59. AVFrame *frame; ///< video frame to store the decoded images in
  60. int max_stream_index; /**< max stream # actually used for output */
  61. MovieStream *st; /**< array of all streams, one per output */
  62. int *out_index; /**< stream number -> output number map, or -1 */
  63. } MovieContext;
  64. #define OFFSET(x) offsetof(MovieContext, x)
  65. static const AVOption movie_options[]= {
  66. {"format_name", "set format name", OFFSET(format_name), AV_OPT_TYPE_STRING, {.str = 0}, CHAR_MIN, CHAR_MAX },
  67. {"f", "set format name", OFFSET(format_name), AV_OPT_TYPE_STRING, {.str = 0}, CHAR_MIN, CHAR_MAX },
  68. {"streams", "set streams", OFFSET(stream_specs), AV_OPT_TYPE_STRING, {.str = 0}, CHAR_MAX, CHAR_MAX },
  69. {"s", "set streams", OFFSET(stream_specs), AV_OPT_TYPE_STRING, {.str = 0}, CHAR_MAX, CHAR_MAX },
  70. {"si", "set stream index", OFFSET(stream_index), AV_OPT_TYPE_INT, {.dbl = -1}, -1, INT_MAX },
  71. {"stream_index", "set stream index", OFFSET(stream_index), AV_OPT_TYPE_INT, {.dbl = -1}, -1, INT_MAX },
  72. {"seek_point", "set seekpoint (seconds)", OFFSET(seek_point_d), AV_OPT_TYPE_DOUBLE, {.dbl = 0}, 0, (INT64_MAX-1) / 1000000 },
  73. {"sp", "set seekpoint (seconds)", OFFSET(seek_point_d), AV_OPT_TYPE_DOUBLE, {.dbl = 0}, 0, (INT64_MAX-1) / 1000000 },
  74. {"loop", "set loop count", OFFSET(loop_count), AV_OPT_TYPE_INT, {.dbl = 1}, 0, INT_MAX },
  75. {NULL},
  76. };
  77. static int movie_config_output_props(AVFilterLink *outlink);
  78. static int movie_request_frame(AVFilterLink *outlink);
  79. static AVStream *find_stream(void *log, AVFormatContext *avf, const char *spec)
  80. {
  81. int i, ret, already = 0, stream_id = -1;
  82. char type_char, dummy;
  83. AVStream *found = NULL;
  84. enum AVMediaType type;
  85. ret = sscanf(spec, "d%[av]%d%c", &type_char, &stream_id, &dummy);
  86. if (ret >= 1 && ret <= 2) {
  87. type = type_char == 'v' ? AVMEDIA_TYPE_VIDEO : AVMEDIA_TYPE_AUDIO;
  88. ret = av_find_best_stream(avf, type, stream_id, -1, NULL, 0);
  89. if (ret < 0) {
  90. av_log(log, AV_LOG_ERROR, "No %s stream with index '%d' found\n",
  91. av_get_media_type_string(type), stream_id);
  92. return NULL;
  93. }
  94. return avf->streams[ret];
  95. }
  96. for (i = 0; i < avf->nb_streams; i++) {
  97. ret = avformat_match_stream_specifier(avf, avf->streams[i], spec);
  98. if (ret < 0) {
  99. av_log(log, AV_LOG_ERROR,
  100. "Invalid stream specifier \"%s\"\n", spec);
  101. return NULL;
  102. }
  103. if (!ret)
  104. continue;
  105. if (avf->streams[i]->discard != AVDISCARD_ALL) {
  106. already++;
  107. continue;
  108. }
  109. if (found) {
  110. av_log(log, AV_LOG_WARNING,
  111. "Ambiguous stream specifier \"%s\", using #%d\n", spec, i);
  112. break;
  113. }
  114. found = avf->streams[i];
  115. }
  116. if (!found) {
  117. av_log(log, AV_LOG_WARNING, "Stream specifier \"%s\" %s\n", spec,
  118. already ? "matched only already used streams" :
  119. "did not match any stream");
  120. return NULL;
  121. }
  122. if (found->codec->codec_type != AVMEDIA_TYPE_VIDEO &&
  123. found->codec->codec_type != AVMEDIA_TYPE_AUDIO) {
  124. av_log(log, AV_LOG_ERROR, "Stream specifier \"%s\" matched a %s stream,"
  125. "currently unsupported by libavfilter\n", spec,
  126. av_get_media_type_string(found->codec->codec_type));
  127. return NULL;
  128. }
  129. return found;
  130. }
  131. static int open_stream(void *log, MovieStream *st)
  132. {
  133. AVCodec *codec;
  134. int ret;
  135. codec = avcodec_find_decoder(st->st->codec->codec_id);
  136. if (!codec) {
  137. av_log(log, AV_LOG_ERROR, "Failed to find any codec\n");
  138. return AVERROR(EINVAL);
  139. }
  140. if ((ret = avcodec_open2(st->st->codec, codec, NULL)) < 0) {
  141. av_log(log, AV_LOG_ERROR, "Failed to open codec\n");
  142. return ret;
  143. }
  144. return 0;
  145. }
  146. static int guess_channel_layout(MovieStream *st, int st_index, void *log_ctx)
  147. {
  148. AVCodecContext *dec_ctx = st->st->codec;
  149. char buf[256];
  150. int64_t chl = av_get_default_channel_layout(dec_ctx->channels);
  151. if (!chl) {
  152. av_log(log_ctx, AV_LOG_ERROR,
  153. "Channel layout is not set in stream %d, and could not "
  154. "be guessed from the number of channels (%d)\n",
  155. st_index, dec_ctx->channels);
  156. return AVERROR(EINVAL);
  157. }
  158. av_get_channel_layout_string(buf, sizeof(buf), dec_ctx->channels, chl);
  159. av_log(log_ctx, AV_LOG_WARNING,
  160. "Channel layout is not set in output stream %d, "
  161. "guessed channel layout is '%s'\n",
  162. st_index, buf);
  163. dec_ctx->channel_layout = chl;
  164. return 0;
  165. }
  166. static av_cold int movie_common_init(AVFilterContext *ctx, const char *args, const AVClass *class)
  167. {
  168. MovieContext *movie = ctx->priv;
  169. AVInputFormat *iformat = NULL;
  170. int64_t timestamp;
  171. int nb_streams, ret, i;
  172. char default_streams[16], *stream_specs, *spec, *cursor;
  173. char name[16];
  174. AVStream *st;
  175. movie->class = class;
  176. av_opt_set_defaults(movie);
  177. if (args)
  178. movie->file_name = av_get_token(&args, ":");
  179. if (!movie->file_name || !*movie->file_name) {
  180. av_log(ctx, AV_LOG_ERROR, "No filename provided!\n");
  181. return AVERROR(EINVAL);
  182. }
  183. if (*args++ == ':' && (ret = av_set_options_string(movie, args, "=", ":")) < 0)
  184. return ret;
  185. movie->seek_point = movie->seek_point_d * 1000000 + 0.5;
  186. stream_specs = movie->stream_specs;
  187. if (!stream_specs) {
  188. snprintf(default_streams, sizeof(default_streams), "d%c%d",
  189. !strcmp(ctx->filter->name, "amovie") ? 'a' : 'v',
  190. movie->stream_index);
  191. stream_specs = default_streams;
  192. }
  193. for (cursor = stream_specs, nb_streams = 1; *cursor; cursor++)
  194. if (*cursor == '+')
  195. nb_streams++;
  196. if (movie->loop_count != 1 && nb_streams != 1) {
  197. av_log(ctx, AV_LOG_ERROR,
  198. "Loop with several streams is currently unsupported\n");
  199. return AVERROR_PATCHWELCOME;
  200. }
  201. av_register_all();
  202. // Try to find the movie format (container)
  203. iformat = movie->format_name ? av_find_input_format(movie->format_name) : NULL;
  204. movie->format_ctx = NULL;
  205. if ((ret = avformat_open_input(&movie->format_ctx, movie->file_name, iformat, NULL)) < 0) {
  206. av_log(ctx, AV_LOG_ERROR,
  207. "Failed to avformat_open_input '%s'\n", movie->file_name);
  208. return ret;
  209. }
  210. if ((ret = avformat_find_stream_info(movie->format_ctx, NULL)) < 0)
  211. av_log(ctx, AV_LOG_WARNING, "Failed to find stream info\n");
  212. // if seeking requested, we execute it
  213. if (movie->seek_point > 0) {
  214. timestamp = movie->seek_point;
  215. // add the stream start time, should it exist
  216. if (movie->format_ctx->start_time != AV_NOPTS_VALUE) {
  217. if (timestamp > INT64_MAX - movie->format_ctx->start_time) {
  218. av_log(ctx, AV_LOG_ERROR,
  219. "%s: seek value overflow with start_time:%"PRId64" seek_point:%"PRId64"\n",
  220. movie->file_name, movie->format_ctx->start_time, movie->seek_point);
  221. return AVERROR(EINVAL);
  222. }
  223. timestamp += movie->format_ctx->start_time;
  224. }
  225. if ((ret = av_seek_frame(movie->format_ctx, -1, timestamp, AVSEEK_FLAG_BACKWARD)) < 0) {
  226. av_log(ctx, AV_LOG_ERROR, "%s: could not seek to position %"PRId64"\n",
  227. movie->file_name, timestamp);
  228. return ret;
  229. }
  230. }
  231. for (i = 0; i < movie->format_ctx->nb_streams; i++)
  232. movie->format_ctx->streams[i]->discard = AVDISCARD_ALL;
  233. movie->st = av_calloc(nb_streams, sizeof(*movie->st));
  234. if (!movie->st)
  235. return AVERROR(ENOMEM);
  236. for (i = 0; i < nb_streams; i++) {
  237. spec = av_strtok(stream_specs, "+", &cursor);
  238. if (!spec)
  239. return AVERROR_BUG;
  240. stream_specs = NULL; /* for next strtok */
  241. st = find_stream(ctx, movie->format_ctx, spec);
  242. if (!st)
  243. return AVERROR(EINVAL);
  244. st->discard = AVDISCARD_DEFAULT;
  245. movie->st[i].st = st;
  246. movie->max_stream_index = FFMAX(movie->max_stream_index, st->index);
  247. }
  248. if (av_strtok(NULL, "+", &cursor))
  249. return AVERROR_BUG;
  250. movie->out_index = av_calloc(movie->max_stream_index + 1,
  251. sizeof(*movie->out_index));
  252. if (!movie->out_index)
  253. return AVERROR(ENOMEM);
  254. for (i = 0; i <= movie->max_stream_index; i++)
  255. movie->out_index[i] = -1;
  256. for (i = 0; i < nb_streams; i++)
  257. movie->out_index[movie->st[i].st->index] = i;
  258. for (i = 0; i < nb_streams; i++) {
  259. AVFilterPad pad = { 0 };
  260. snprintf(name, sizeof(name), "out%d", i);
  261. pad.type = movie->st[i].st->codec->codec_type;
  262. pad.name = av_strdup(name);
  263. pad.config_props = movie_config_output_props;
  264. pad.request_frame = movie_request_frame;
  265. ff_insert_outpad(ctx, i, &pad);
  266. ret = open_stream(ctx, &movie->st[i]);
  267. if (ret < 0)
  268. return ret;
  269. if ( movie->st[i].st->codec->codec->type == AVMEDIA_TYPE_AUDIO &&
  270. !movie->st[i].st->codec->channel_layout) {
  271. ret = guess_channel_layout(&movie->st[i], i, ctx);
  272. if (ret < 0)
  273. return ret;
  274. }
  275. }
  276. if (!(movie->frame = avcodec_alloc_frame()) ) {
  277. av_log(log, AV_LOG_ERROR, "Failed to alloc frame\n");
  278. return AVERROR(ENOMEM);
  279. }
  280. av_log(ctx, AV_LOG_VERBOSE, "seek_point:%"PRIi64" format_name:%s file_name:%s stream_index:%d\n",
  281. movie->seek_point, movie->format_name, movie->file_name,
  282. movie->stream_index);
  283. return 0;
  284. }
  285. static av_cold void movie_uninit(AVFilterContext *ctx)
  286. {
  287. MovieContext *movie = ctx->priv;
  288. int i;
  289. for (i = 0; i < ctx->nb_outputs; i++) {
  290. av_freep(&ctx->output_pads[i].name);
  291. if (movie->st[i].st)
  292. avcodec_close(movie->st[i].st->codec);
  293. }
  294. av_opt_free(movie);
  295. av_freep(&movie->file_name);
  296. av_freep(&movie->st);
  297. av_freep(&movie->out_index);
  298. av_freep(&movie->frame);
  299. if (movie->format_ctx)
  300. avformat_close_input(&movie->format_ctx);
  301. }
  302. static int movie_query_formats(AVFilterContext *ctx)
  303. {
  304. MovieContext *movie = ctx->priv;
  305. int list[] = { 0, -1 };
  306. int64_t list64[] = { 0, -1 };
  307. int i;
  308. for (i = 0; i < ctx->nb_outputs; i++) {
  309. MovieStream *st = &movie->st[i];
  310. AVCodecContext *c = st->st->codec;
  311. AVFilterLink *outlink = ctx->outputs[i];
  312. switch (c->codec_type) {
  313. case AVMEDIA_TYPE_VIDEO:
  314. list[0] = c->pix_fmt;
  315. ff_formats_ref(ff_make_format_list(list), &outlink->in_formats);
  316. break;
  317. case AVMEDIA_TYPE_AUDIO:
  318. list[0] = c->sample_fmt;
  319. ff_formats_ref(ff_make_format_list(list), &outlink->in_formats);
  320. list[0] = c->sample_rate;
  321. ff_formats_ref(ff_make_format_list(list), &outlink->in_samplerates);
  322. list64[0] = c->channel_layout;
  323. ff_channel_layouts_ref(avfilter_make_format64_list(list64),
  324. &outlink->in_channel_layouts);
  325. break;
  326. }
  327. }
  328. return 0;
  329. }
  330. static int movie_config_output_props(AVFilterLink *outlink)
  331. {
  332. AVFilterContext *ctx = outlink->src;
  333. MovieContext *movie = ctx->priv;
  334. unsigned out_id = FF_OUTLINK_IDX(outlink);
  335. MovieStream *st = &movie->st[out_id];
  336. AVCodecContext *c = st->st->codec;
  337. outlink->time_base = st->st->time_base;
  338. switch (c->codec_type) {
  339. case AVMEDIA_TYPE_VIDEO:
  340. outlink->w = c->width;
  341. outlink->h = c->height;
  342. outlink->frame_rate = st->st->r_frame_rate;
  343. break;
  344. case AVMEDIA_TYPE_AUDIO:
  345. break;
  346. }
  347. return 0;
  348. }
  349. static AVFilterBufferRef *frame_to_buf(enum AVMediaType type, AVFrame *frame,
  350. AVFilterLink *outlink)
  351. {
  352. AVFilterBufferRef *buf, *copy;
  353. buf = avfilter_get_buffer_ref_from_frame(type, frame,
  354. AV_PERM_WRITE |
  355. AV_PERM_PRESERVE |
  356. AV_PERM_REUSE2);
  357. if (!buf)
  358. return NULL;
  359. buf->pts = av_frame_get_best_effort_timestamp(frame);
  360. copy = ff_copy_buffer_ref(outlink, buf);
  361. if (!copy)
  362. return NULL;
  363. buf->buf->data[0] = NULL; /* it belongs to the frame */
  364. avfilter_unref_buffer(buf);
  365. return copy;
  366. }
  367. static char *describe_bufref_to_str(char *dst, size_t dst_size,
  368. AVFilterBufferRef *buf,
  369. AVFilterLink *link)
  370. {
  371. switch (buf->type) {
  372. case AVMEDIA_TYPE_VIDEO:
  373. snprintf(dst, dst_size,
  374. "video pts:%s time:%s pos:%"PRId64" size:%dx%d aspect:%d/%d",
  375. av_ts2str(buf->pts), av_ts2timestr(buf->pts, &link->time_base),
  376. buf->pos, buf->video->w, buf->video->h,
  377. buf->video->sample_aspect_ratio.num,
  378. buf->video->sample_aspect_ratio.den);
  379. break;
  380. case AVMEDIA_TYPE_AUDIO:
  381. snprintf(dst, dst_size,
  382. "audio pts:%s time:%s pos:%"PRId64" samples:%d",
  383. av_ts2str(buf->pts), av_ts2timestr(buf->pts, &link->time_base),
  384. buf->pos, buf->audio->nb_samples);
  385. break;
  386. default:
  387. snprintf(dst, dst_size, "%s BUG", av_get_media_type_string(buf->type));
  388. break;
  389. }
  390. return dst;
  391. }
  392. #define describe_bufref(buf, link) \
  393. describe_bufref_to_str((char[1024]){0}, 1024, buf, link)
  394. static int rewind_file(AVFilterContext *ctx)
  395. {
  396. MovieContext *movie = ctx->priv;
  397. int64_t timestamp = movie->seek_point;
  398. int ret, i;
  399. if (movie->format_ctx->start_time != AV_NOPTS_VALUE)
  400. timestamp += movie->format_ctx->start_time;
  401. ret = av_seek_frame(movie->format_ctx, -1, timestamp, AVSEEK_FLAG_BACKWARD);
  402. if (ret < 0) {
  403. av_log(ctx, AV_LOG_ERROR, "Unable to loop: %s\n", av_err2str(ret));
  404. movie->loop_count = 1; /* do not try again */
  405. return ret;
  406. }
  407. for (i = 0; i < ctx->nb_outputs; i++) {
  408. avcodec_flush_buffers(movie->st[i].st->codec);
  409. movie->st[i].done = 0;
  410. }
  411. movie->eof = 0;
  412. return 0;
  413. }
  414. /**
  415. * Try to push a frame to the requested output.
  416. *
  417. * @param ctx filter context
  418. * @param out_id number of output where a frame is wanted;
  419. * if the frame is read from file, used to set the return value;
  420. * if the codec is being flushed, flush the corresponding stream
  421. * @return 1 if a frame was pushed on the requested output,
  422. * 0 if another attempt is possible,
  423. * <0 AVERROR code
  424. */
  425. static int movie_push_frame(AVFilterContext *ctx, unsigned out_id)
  426. {
  427. MovieContext *movie = ctx->priv;
  428. AVPacket *pkt = &movie->pkt;
  429. MovieStream *st;
  430. int ret, got_frame = 0, pkt_out_id;
  431. AVFilterLink *outlink;
  432. AVFilterBufferRef *buf;
  433. if (!pkt->size) {
  434. if (movie->eof) {
  435. if (movie->st[out_id].done) {
  436. if (movie->loop_count != 1) {
  437. ret = rewind_file(ctx);
  438. if (ret < 0)
  439. return ret;
  440. movie->loop_count -= movie->loop_count > 1;
  441. av_log(ctx, AV_LOG_VERBOSE, "Stream finished, looping.\n");
  442. return 0; /* retry */
  443. }
  444. return AVERROR_EOF;
  445. }
  446. pkt->stream_index = movie->st[out_id].st->index;
  447. /* packet is already ready for flushing */
  448. } else {
  449. ret = av_read_frame(movie->format_ctx, &movie->pkt0);
  450. if (ret < 0) {
  451. av_init_packet(&movie->pkt0); /* ready for flushing */
  452. *pkt = movie->pkt0;
  453. if (ret == AVERROR_EOF) {
  454. movie->eof = 1;
  455. return 0; /* start flushing */
  456. }
  457. return ret;
  458. }
  459. *pkt = movie->pkt0;
  460. }
  461. }
  462. pkt_out_id = pkt->stream_index > movie->max_stream_index ? -1 :
  463. movie->out_index[pkt->stream_index];
  464. if (pkt_out_id < 0) {
  465. av_free_packet(&movie->pkt0);
  466. pkt->size = 0; /* ready for next run */
  467. pkt->data = NULL;
  468. return 0;
  469. }
  470. st = &movie->st[pkt_out_id];
  471. outlink = ctx->outputs[pkt_out_id];
  472. switch (st->st->codec->codec_type) {
  473. case AVMEDIA_TYPE_VIDEO:
  474. ret = avcodec_decode_video2(st->st->codec, movie->frame, &got_frame, pkt);
  475. break;
  476. case AVMEDIA_TYPE_AUDIO:
  477. ret = avcodec_decode_audio4(st->st->codec, movie->frame, &got_frame, pkt);
  478. break;
  479. default:
  480. ret = AVERROR(ENOSYS);
  481. break;
  482. }
  483. if (ret < 0) {
  484. av_log(ctx, AV_LOG_WARNING, "Decode error: %s\n", av_err2str(ret));
  485. return 0;
  486. }
  487. if (!ret)
  488. ret = pkt->size;
  489. pkt->data += ret;
  490. pkt->size -= ret;
  491. if (pkt->size <= 0) {
  492. av_free_packet(&movie->pkt0);
  493. pkt->size = 0; /* ready for next run */
  494. pkt->data = NULL;
  495. }
  496. if (!got_frame) {
  497. if (!ret)
  498. st->done = 1;
  499. return 0;
  500. }
  501. buf = frame_to_buf(st->st->codec->codec_type, movie->frame, outlink);
  502. if (!buf)
  503. return AVERROR(ENOMEM);
  504. av_dlog(ctx, "movie_push_frame(): file:'%s' %s\n", movie->file_name,
  505. describe_bufref(buf, outlink));
  506. switch (st->st->codec->codec_type) {
  507. case AVMEDIA_TYPE_VIDEO:
  508. if (!movie->frame->sample_aspect_ratio.num)
  509. buf->video->sample_aspect_ratio = st->st->sample_aspect_ratio;
  510. ff_start_frame(outlink, buf);
  511. ff_draw_slice(outlink, 0, outlink->h, 1);
  512. ff_end_frame(outlink);
  513. break;
  514. case AVMEDIA_TYPE_AUDIO:
  515. ff_filter_samples(outlink, buf);
  516. break;
  517. }
  518. return pkt_out_id == out_id;
  519. }
  520. static int movie_request_frame(AVFilterLink *outlink)
  521. {
  522. AVFilterContext *ctx = outlink->src;
  523. unsigned out_id = FF_OUTLINK_IDX(outlink);
  524. int ret;
  525. while (1) {
  526. ret = movie_push_frame(ctx, out_id);
  527. if (ret)
  528. return FFMIN(ret, 0);
  529. }
  530. }
  531. #if CONFIG_MOVIE_FILTER
  532. AVFILTER_DEFINE_CLASS(movie);
  533. static av_cold int movie_init(AVFilterContext *ctx, const char *args)
  534. {
  535. return movie_common_init(ctx, args, &movie_class);
  536. }
  537. AVFilter avfilter_avsrc_movie = {
  538. .name = "movie",
  539. .description = NULL_IF_CONFIG_SMALL("Read from a movie source."),
  540. .priv_size = sizeof(MovieContext),
  541. .init = movie_init,
  542. .uninit = movie_uninit,
  543. .query_formats = movie_query_formats,
  544. .inputs = (const AVFilterPad[]) {{ .name = NULL }},
  545. .outputs = (const AVFilterPad[]) {{ .name = NULL }},
  546. };
  547. #endif /* CONFIG_MOVIE_FILTER */
  548. #if CONFIG_AMOVIE_FILTER
  549. #define amovie_options movie_options
  550. AVFILTER_DEFINE_CLASS(amovie);
  551. static av_cold int amovie_init(AVFilterContext *ctx, const char *args)
  552. {
  553. return movie_common_init(ctx, args, &amovie_class);
  554. }
  555. AVFilter avfilter_avsrc_amovie = {
  556. .name = "amovie",
  557. .description = NULL_IF_CONFIG_SMALL("Read audio from a movie source."),
  558. .priv_size = sizeof(MovieContext),
  559. .init = amovie_init,
  560. .uninit = movie_uninit,
  561. .query_formats = movie_query_formats,
  562. .inputs = (const AVFilterPad[]) {{ .name = NULL }},
  563. .outputs = (const AVFilterPad[]) {{ .name = NULL }},
  564. };
  565. #endif /* CONFIG_AMOVIE_FILTER */