--- tutorial03b.c.v0 2011-12-30 17:14:31.000000000 -0500 +++ tutorial03b.c 2011-12-30 18:24:36.000000000 -0500 @@ -28,9 +28,9 @@ #include #include -#include -#include -#include +#include "SDL.h" +#include "SDL_audio.h" +#include "SDL_thread.h" #ifdef __MINGW32__ #undef main /* Prevents SDL from overriding main() */ @@ -123,6 +123,7 @@ int audio_decode_frame(AVCodecContext *aCodecCtx, uint8_t *audio_buf, int buf_size) { +#if 0 static AVPacket pkt; static uint8_t *audio_pkt_data = NULL; static int audio_pkt_size = 0; @@ -161,6 +162,7 @@ audio_pkt_data = pkt.data; audio_pkt_size = pkt.size; } +#endif } void audio_callback(void *userdata, Uint8 *stream, int len) { @@ -230,8 +232,6 @@ SDL_DisplayMode mode; SDL_Rect rect; - SDL_Rect srcrect; - SDL_Rect dstrect; if(argc < 2) { @@ -256,11 +256,11 @@ videoStream=-1; audioStream=-1; for(i=0; inb_streams; i++) { - if(pFormatCtx->streams[i]->codec->codec_type==CODEC_TYPE_VIDEO && + if(pFormatCtx->streams[i]->codec->codec_type==AVMEDIA_TYPE_VIDEO && videoStream < 0) { videoStream=i; } - if(pFormatCtx->streams[i]->codec->codec_type==CODEC_TYPE_AUDIO && + if(pFormatCtx->streams[i]->codec->codec_type==AVMEDIA_TYPE_AUDIO && audioStream < 0) { audioStream=i; } @@ -361,13 +361,13 @@ printf("mode.w: %d\n", mode.w); // DEBUG printf("mode.h: %d\n", mode.h); // DEBUG - dst_w = mode.w; - dst_h = (int)rint(dst_w / aspect_ratio); + dst_w = originalVideoWidth; + dst_h = originalVideoHeight; printf("dst_w: %d\n", dst_w); // DEBUG printf("dst_h: %d\n", dst_h); // DEBUG - if ((win = SDL_CreateWindow("myPlayer", 0, 0, mode.w, mode.h, SDL_WINDOW_FULLSCREEN | SDL_WINDOW_BORDERLESS | SDL_WINDOW_OPENGL)) == NULL) + if ((win = SDL_CreateWindow("myPlayer", 0, 0, mode.w, mode.h, SDL_WINDOW_BORDERLESS | SDL_WINDOW_OPENGL)) == NULL) { fprintf(stderr, "SDL_CreateWindow FAILED: %s\n", SDL_GetError()); return -1; @@ -379,6 +379,8 @@ return -1; } + SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "1"); + SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255); // Set default colour to black. if (SDL_RenderClear(renderer) < 0) { @@ -389,8 +391,8 @@ if ((bitmapTex = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_YV12, SDL_TEXTUREACCESS_STREAMING, - mode.w, - mode.h)) == NULL) + originalVideoWidth, + originalVideoHeight)) == NULL) { fprintf(stderr, "SDL_CreateTexture FAILED: %s\n", SDL_GetError()); return -1; @@ -468,15 +470,13 @@ sws_scale(img_convert_ctx, pFrame->data, pFrame->linesize, 0, originalVideoHeight, pict.data, pict.linesize); + rect.w = mode.w; + rect.h = (int)rint(mode.w / aspect_ratio); rect.x = 0; - rect.y = (int)rint((mode.h - dst_h) / 2); - rect.w = dst_w; - rect.h = dst_h; + rect.y = (int)rint((mode.h - rect.h) / 2); - srcrect = rect; - dstrect = rect; + SDL_RenderClear(renderer); -/* if (SDL_UpdateTexture(bitmapTex, NULL, buffer, (dst_w * SDL_BYTESPERPIXEL(SDL_PIXELFORMAT_YV12))) < 0) { @@ -484,22 +484,7 @@ return -1; } - if (SDL_RenderCopy(renderer, bitmapTex, NULL, NULL) < 0) - { - fprintf(stderr, "SDL_RenderCopy FAILED: %s\n", SDL_GetError()); - return -1; - } -*/ - - - if (SDL_UpdateTexture(bitmapTex, &rect, buffer, - (dst_w * SDL_BYTESPERPIXEL(SDL_PIXELFORMAT_YV12))) < 0) - { - fprintf(stderr, "SDL_UpdateTexture FAILED: %s\n", SDL_GetError()); - return -1; - } - - if (SDL_RenderCopy(renderer, bitmapTex, &srcrect, &dstrect) < 0) + if (SDL_RenderCopy(renderer, bitmapTex, NULL, &rect) < 0) { fprintf(stderr, "SDL_RenderCopy FAILED: %s\n", SDL_GetError()); return -1;