Commit 5743095c authored by Michael Niedermayer's avatar Michael Niedermayer

Merge commit '9d3009c6'

* commit '9d3009c6':
  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: 's avatarMichael Niedermayer <michaelni@gmx.at>
parents 6b6b0e9d 9d3009c6
......@@ -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);
......
......@@ -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 {
......
......@@ -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. */
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment