History

examples/decoding_encoding: make operation logic more self-evident / predictable

Add a switch which controls which operation to perform. Useful to test only a single feature. Also the new behavior is more self-consistent.

Stefano Sabatini committed 14 years ago

Commit 60924df1 parent 3b0e2761 file · +18 −9Browse files

Showing the changes to doc/examples/decoding_encoding.c (1 of 1 file). Show all

Unified · Split

doc/examples/decoding_encoding.c+18−9
@@ -600,24 +600,33 @@ static void video_decode_example(const char *outfilename, const char *filename) · 599 unmodified lines
600600
601601 int main(int argc, char **argv)
602602 {
603− const char *filename;
603+ const char *output_type;
604604
605605 /* register all the codecs */
606606 avcodec_register_all();
607607
608− if (argc <= 1) {
609− audio_encode_example("test.mp2");
610− audio_decode_example("test.sw", "test.mp2");
608+ if (argc < 2) {
609+ printf("usage: %s output_type\n"
610+ "API example program to decode/encode a media stream with libavcodec.\n"
611+ "output_type must be choosen between 'h264', 'mp2', 'mpg'\n",
612+ argv[0]);
613+ return 1;
614+ }
615+ output_type = argv[1];
611616
617+ if (!strcmp(output_type, "h264")) {
612618 video_encode_example("test.h264", AV_CODEC_ID_H264);
619+ } else if (!strcmp(output_type, "mp2")) {
620+ audio_encode_example("test.mp2");
621+ audio_decode_example("test.sw", "test.mp2");
622+ } else if (!strcmp(output_type, "mpg")) {
613623 video_encode_example("test.mpg", AV_CODEC_ID_MPEG1VIDEO);
614− filename = "test.mpg";
624+ video_decode_example("test%02d.pgm", "test.mpg");
615625 } else {
616− filename = argv[1];
626+ fprintf(stderr, "Invalid output type '%s', choose between 'h264', 'mp2', or 'mpg'\n",
627+ output_type);
628+ return 1;
617629 }
618630
619− // audio_decode_example("test.sw", filename);
620− video_decode_example("test%02d.pgm", filename);
621−
622631 return 0;
623632 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t