Permalink
Browse files

Merge commit '9d3009c6c4b9b6734f07df7c88f6a42ded6cdf38'

* commit '9d3009c6c4b9b6734f07df7c88f6a42ded6cdf38':
  avconv: print an error on applying options of the wrong type.
  atomic: Check for __sync_val_compare_and_swap instead of __sync_synchronize
  output-example: Update to use encode_video2 instead of the now dropped encode_video

Conflicts:
	doc/examples/muxing.c
	ffmpeg_opt.c
	libavutil/atomic.h

Merged-by: Michael Niedermayer <michaelni@gmx.at>
  • Loading branch information...
2 parents 6b6b0e9 + 9d3009c commit 5743095ca9566db981b8fe113fc4f330dda5798a @michaelni michaelni committed Mar 12, 2013
Showing with 136 additions and 87 deletions.
  1. +10 −0 cmdutils.c
  2. +7 −0 cmdutils.h
  3. +5 −11 doc/examples/muxing.c
  4. +114 −76 ffmpeg_opt.c
View
@@ -378,6 +378,16 @@ int parse_optgroup(void *optctx, OptionGroup *g)
for (i = 0; i < g->nb_opts; i++) {
Option *o = &g->opts[i];
+ if (g->group_def->flags &&
+ !(g->group_def->flags & o->opt->flags)) {
+ av_log(NULL, AV_LOG_ERROR, "Option %s (%s) cannot be applied to "
+ "%s %s -- you are trying to apply an input option to an "
+ "output file or vice versa. Move this option before the "
+ "file it belongs to.\n", o->key, o->opt->help,
+ g->group_def->name, g->arg);
+ return AVERROR(EINVAL);
+ }
+
av_log(NULL, AV_LOG_DEBUG, "Applying option %s (%s) with argument %s.\n",
o->key, o->opt->help, o->val);
View
@@ -162,6 +162,8 @@ typedef struct OptionDef {
an int containing element count in the array. */
#define OPT_TIME 0x10000
#define OPT_DOUBLE 0x20000
+#define OPT_INPUT 0x40000
+#define OPT_OUTPUT 0x80000
union {
void *dst_ptr;
int (*func_arg)(void *, const char *, const char *);
@@ -242,6 +244,11 @@ typedef struct OptionGroupDef {
* are terminated by a non-option argument (e.g. ffmpeg output files)
*/
const char *sep;
+ /**
+ * Option flags that must be set on each option that is
+ * applied to this group
+ */
+ int flags;
} OptionGroupDef;
typedef struct OptionGroup {
View
@@ -342,25 +342,19 @@ static void write_video_frame(AVFormatContext *oc, AVStream *st)
ret = av_interleaved_write_frame(oc, &pkt);
} else {
- /* encode the image */
- AVPacket pkt;
- int got_output;
-
+ AVPacket pkt = { 0 };
+ int got_packet;
av_init_packet(&pkt);
- pkt.data = NULL; // packet data will be allocated by the encoder
- pkt.size = 0;
- ret = avcodec_encode_video2(c, &pkt, frame, &got_output);
+ /* encode the image */
+ ret = avcodec_encode_video2(c, &pkt, frame, &got_packet);
if (ret < 0) {
fprintf(stderr, "Error encoding video frame: %s\n", av_err2str(ret));
exit(1);
}
-
/* If size is zero, it means the image was buffered. */
- if (got_output) {
- if (c->coded_frame->key_frame)
- pkt.flags |= AV_PKT_FLAG_KEY;
+ if (!ret && got_packet && pkt.size) {
pkt.stream_index = st->index;
/* Write the compressed frame to the media file. */
Oops, something went wrong.

0 comments on commit 5743095

Please sign in to comment.